New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebDAV camera #22607
WebDAV camera #22607
Conversation
As suggested by @dgomes in home-assistant#19758, here's a camera backed by image files on a WebDAV share. The entity exposes a stream and individual images, iterating through the images in sorted order by filename at a configurable rate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of the wait_and_advance() you could use async_track_time_change
from homeassistant.helpers.event
It is harsh time for new integration as we are doing refactoring, we are now requesting all components has to have a manifest file. Please rebase you branch against current You may need to do more rebase in the next few days as we are still in the progress of refactoring. |
This comment has been minimized.
This comment has been minimized.
Can you please rebase ? There several changes in the core that must be tested with this component before any merge. |
@jkeljo are you planning to continue here? |
Yep, definitely. Just a matter of finding some free time, hopefully in the next couple weeks. If it’s cluttering things up for you, feel free to close it out and I’ll open another when I can get back to it.
…On July 14, 2019 at 9:04:32 AM, Martin Hjelmare ***@***.******@***.***)) wrote:
@jkeljo(https://github.com/jkeljo) are you planning to continue here?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub(#22607), or mute the thread(https://github.com/notifications/unsubscribe-auth/ABTZNWKKNISVGJS7RDEZ3LTP7NFBBANCNFSM4HCTBN3A).
|
@jkeljo please close, since then you can open this PR again yourself, when you have time, and we can keep the comment history in one place. |
oops, waiting for @jkeljo to close, so he can also re-open it, compared to when I close it. |
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I think I was thinking in another language, since this was not valid Python. Result was that the thread that maintained the SocketIO connection to the table would die early on, so no status updates were actually flowing from the table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be wary of mixing sync and async calls in the same context. Coroutines should be awaited in async context and blocking (sync) I/O is not allowed in async context.
This component models a WebDAV share full of images as a camera. | ||
|
||
For more details about this platform, please refer to the documentation at | ||
https://home-assistant.io/components/camera.webdav/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't add the url to the docstring anymore. Just keep the very first line.
""" | ||
|
||
import logging | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this blank line. I recommend the isort tool to automatically sort and group imports.
|
||
import asyncio | ||
from datetime import timedelta | ||
from aiohttp import ClientError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a blank line between standard library and 3rd party import groups.
"webdav_root": path, | ||
} | ||
) | ||
session = async_get_clientsession(hass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called in async context. Currently we're in sync context.
SCAN_INTERVAL = timedelta(minutes=15) | ||
|
||
|
||
def setup_platform(hass, config, add_entities, discovery_info=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change def setup_platform
to async def async_setup_platform
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename add_entities
to async_add_entities
.
update_before_add=True, | ||
) | ||
except WebDavException as exception: | ||
_LOGGER.warning("Failed to connect to %s: %s", client.get_url(""), exception) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does client.get_url
make I/O?
while images_checked < len(self._files): | ||
self._image_number += 1 | ||
images_checked += 1 | ||
content_type = self._client.get_property( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes I/O so needs to be scheduled on the executor thread pool. Use await self.hass.async_add_executor_job(...)
.
"""Return True if the camera is playing through files in the share.""" | ||
return self._stop_advancing is not None | ||
|
||
def turn_on(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a coroutine and rename it to async_turn_on
.
self.hass, self._advance, self._image_interval | ||
) | ||
|
||
def turn_off(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
async def async_added_to_hass(self): | ||
"""Set up periodic image advancement.""" | ||
self._image_lock = asyncio.Lock() | ||
self.turn_on() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await self.async_turn_on()
This PR seems to have gone stale. Closing it. |
Breaking Change:
None
Description:
As suggested by @dgomes in #19758, here's a camera backed by image files on
a WebDAV share. The entity exposes a stream and individual images, iterating
through the images in sorted order by filename at a configurable rate.
Related issue (if applicable): N/A
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#9085
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: