From 5027e1bcff99b5367f4d5a91b8f17570e9e2f6cc Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sat, 19 Mar 2022 10:24:32 -0700 Subject: [PATCH] Mark stream available on idle timeout (#68380) Mark stream as available on idle timeout so that the frontend can still interact with it. In particular, the Frontend won't interact with camera objects that are not available e.g. from picture glance card. Issue #67922 --- homeassistant/components/stream/__init__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/stream/__init__.py b/homeassistant/components/stream/__init__.py index 9ec389fb4a8..abaf367486d 100644 --- a/homeassistant/components/stream/__init__.py +++ b/homeassistant/components/stream/__init__.py @@ -371,17 +371,18 @@ class Stream: wait_timeout, redact_credentials(str(self.source)), ) - self._worker_finished() - - def _worker_finished(self) -> None: - """Schedule cleanup of all outputs.""" @callback - def remove_outputs() -> None: + def worker_finished() -> None: + # The worker is no checking availability of the stream and can no longer track + # availability so mark it as available, otherwise the frontend may not be able to + # interact with the stream. + if not self.available: + self._async_update_state(True) for provider in self.outputs().values(): self.remove_provider(provider) - self.hass.loop.call_soon_threadsafe(remove_outputs) + self.hass.loop.call_soon_threadsafe(worker_finished) def stop(self) -> None: """Remove outputs and access token."""