mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Ring camera improvements (#22526)
* Ring camera improvements Expose last_video_id attribute. Fix missing last_video_url Only update last_video_id when video is ready * Fix formatting
This commit is contained in:
parent
c31ab7a175
commit
daf6b01b98
@ -157,14 +157,23 @@ class RingCam(Camera):
|
|||||||
self._camera.update()
|
self._camera.update()
|
||||||
self._utcnow = dt_util.utcnow()
|
self._utcnow = dt_util.utcnow()
|
||||||
|
|
||||||
last_recording_id = self._camera.last_recording_id
|
try:
|
||||||
|
last_event = self._camera.history(limit=1)[0]
|
||||||
|
except (IndexError, TypeError):
|
||||||
|
return
|
||||||
|
|
||||||
if self._last_video_id != last_recording_id or \
|
last_recording_id = last_event['id']
|
||||||
self._utcnow >= self._expires_at:
|
video_status = last_event['recording']['status']
|
||||||
|
|
||||||
|
if video_status == 'ready' and \
|
||||||
|
(self._last_video_id != last_recording_id or
|
||||||
|
self._utcnow >= self._expires_at):
|
||||||
|
|
||||||
|
video_url = self._camera.recording_url(last_recording_id)
|
||||||
|
if video_url:
|
||||||
_LOGGER.info("Ring DoorBell properties refreshed")
|
_LOGGER.info("Ring DoorBell properties refreshed")
|
||||||
|
|
||||||
# update attributes if new video or if URL has expired
|
# update attributes if new video or if URL has expired
|
||||||
self._last_video_id = self._camera.last_recording_id
|
self._last_video_id = last_recording_id
|
||||||
self._video_url = self._camera.recording_url(self._last_video_id)
|
self._video_url = video_url
|
||||||
self._expires_at = FORCE_REFRESH_INTERVAL + self._utcnow
|
self._expires_at = FORCE_REFRESH_INTERVAL + self._utcnow
|
||||||
|
Loading…
x
Reference in New Issue
Block a user