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
This commit is contained in:
Allen Porter 2022-03-19 10:24:32 -07:00 committed by GitHub
parent 8220817d47
commit 5027e1bcff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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."""