diff --git a/hass_nabucasa/iot.py b/hass_nabucasa/iot.py index 37a6ec090..e0be4b042 100644 --- a/hass_nabucasa/iot.py +++ b/hass_nabucasa/iot.py @@ -63,6 +63,11 @@ def package_name(self) -> str: """Return the package name for logging.""" return __name__ + @property + def ws_heartbeat(self) -> float | None: + """Server to connect to.""" + return 300 + @property def ws_server_url(self) -> str: """Server to connect to.""" diff --git a/hass_nabucasa/iot_base.py b/hass_nabucasa/iot_base.py index e76abe691..da9e1ff81 100644 --- a/hass_nabucasa/iot_base.py +++ b/hass_nabucasa/iot_base.py @@ -75,6 +75,11 @@ def package_name(self) -> str: """Return package name for logging.""" raise NotImplementedError + @property + def ws_heartbeat(self) -> float | None: + """Server to connect to.""" + return None + @property def ws_server_url(self) -> str: """Server to connect to.""" @@ -202,6 +207,7 @@ async def _handle_connection(self) -> None: try: self.client = await self.cloud.websession.ws_connect( self.ws_server_url, + heartbeat=self.ws_heartbeat, headers={ hdrs.AUTHORIZATION: f"Bearer {self.cloud.id_token}", hdrs.USER_AGENT: self.cloud.client.client_name,