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

Increase homeassistant lovelace connect timeout and make it configurable #770

Merged
merged 1 commit into from
Jan 11, 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
5 changes: 4 additions & 1 deletion pychromecast/controllers/homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


APP_NAMESPACE = "urn:x-cast:com.nabucasa.hast"
DEFAULT_HASS_CONNECT_TIMEOUT = 30


class HomeAssistantController(BaseController):
Expand All @@ -22,12 +23,14 @@ def __init__(
refresh_token,
app_namespace=APP_NAMESPACE,
app_id=APP_HOMEASSISTANT_LOVELACE,
hass_connect_timeout=DEFAULT_HASS_CONNECT_TIMEOUT,
):
super().__init__(app_namespace, app_id)
self.hass_url = hass_url
self.hass_uuid = hass_uuid
self.client_id = client_id
self.refresh_token = refresh_token
self.hass_connect_timeout = hass_connect_timeout
# {
# connected: boolean;
# showDemo: boolean;
Expand Down Expand Up @@ -100,7 +103,7 @@ def _connect_hass(self, callback_function=None):
self._hass_connecting_event.set()
raise

self._hass_connecting_event.wait(10)
self._hass_connecting_event.wait(self.hass_connect_timeout)
try:
if not self._hass_connecting_event.is_set():
self.logger.warning("_connect_hass failed for %s", self.hass_url)
Expand Down