Add reboot command to onvif camera component#29069
Conversation
|
Hi @KoljaWindeler, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
balloob
left a comment
There was a problem hiding this comment.
Please register the service under the onvif domain.
| ret = await self._camera.devicemgmt.SystemReboot() | ||
| _LOGGER.debug("Camera '%s' Reboot command returned '%s'", self._name, ret) | ||
| except exceptions.ONVIFError as err: | ||
| if "Bad Request" in err.reason: |
There was a problem hiding this comment.
Shouldn't we log anything in other error cases?
| camera for camera in all_cameras if camera.entity_id in entity_ids | ||
| ] | ||
| for camera in target_cameras: | ||
| await camera.async_perform_reboot() |
There was a problem hiding this comment.
Can we speed this up by awaiting all camera calls concurrently, eg by using asyncio.gather?
There was a problem hiding this comment.
possible i guess, but fairly unlikely if you ask me. To be honest: I'd improve it but don't know how asyncio,gather works.
There was a problem hiding this comment.
Awaiting asyncio.gather(*coros) will schedule all coroutines on the event loop and return when all are done. Exceptions are either propagated immediately or returned in the result list.
https://docs.python.org/3/library/asyncio-task.html#asyncio.gather
Awaiting tasks in loops, like the for loop here, should be avoided if the task order doesn't matter and there's not a problem with executing the tasks "at the same time". But some devices or APIs can't handle this so in those cases it's ok to keep awaiting in the loop.
| all_cameras = hass.data[ONVIF_DATA][ENTITIES] | ||
| entity_ids = await async_extract_entity_ids(hass, service) | ||
| target_cameras = [] | ||
| if not entity_ids: |
There was a problem hiding this comment.
We are dropping this logic for all other integrations in #29178. Let's not use it here.
|
This PR seems to have gone stale. Closing it. |
Description:
Addition to send a Reboot command to an onvif compatible camera. mine used to hang up approximately every three weeks. Triggering this service once a week provides stable operation.
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:
python3 -m script.hassfest.