Skip to content

Commit

Permalink
Fix bugs in nest stream expiration handling (#130150)
Browse files Browse the repository at this point in the history
  • Loading branch information
allenporter authored and frenck committed Nov 8, 2024
1 parent 1bb0ced commit 864b4d8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions homeassistant/components/nest/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ def _stream_expires_at(self) -> datetime.datetime | None:
async def _async_refresh_stream(self) -> None:
"""Refresh stream to extend expiration time."""
now = utcnow()
for webrtc_stream in list(self._webrtc_sessions.values()):
for session_id, webrtc_stream in list(self._webrtc_sessions.items()):
if session_id not in self._webrtc_sessions:
continue
if now < (webrtc_stream.expires_at - STREAM_EXPIRATION_BUFFER):
_LOGGER.debug(
"Stream does not yet expire: %s", webrtc_stream.expires_at
Expand All @@ -247,7 +249,8 @@ async def _async_refresh_stream(self) -> None:
except ApiException as err:
_LOGGER.debug("Failed to extend stream: %s", err)
else:
self._webrtc_sessions[webrtc_stream.media_session_id] = webrtc_stream
if session_id in self._webrtc_sessions:
self._webrtc_sessions[session_id] = webrtc_stream

async def async_camera_image(
self, width: int | None = None, height: int | None = None
Expand Down

0 comments on commit 864b4d8

Please sign in to comment.