Skip to content
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

Fix bugs in nest stream expiration handling #130150

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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

Check warning on line 240 in homeassistant/components/nest/camera.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/nest/camera.py#L240

Added line #L240 was not covered by tests
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 @@
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

Check warning on line 253 in homeassistant/components/nest/camera.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/nest/camera.py#L253

Added line #L253 was not covered by tests

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