diff --git a/tibber/home.py b/tibber/home.py index 7ed1786..7168501 100644 --- a/tibber/home.py +++ b/tibber/home.py @@ -493,9 +493,12 @@ def rt_unsubscribe(self) -> None: @property def rt_subscription_running(self) -> bool: """Is real time subscription running.""" - if not self._tibber_control.realtime.subscription_running: - return False - return not self._last_rt_data_received < dt.datetime.now(tz=dt.UTC) - dt.timedelta(seconds=60) + return self._tibber_control.realtime.subscription_running + + @property + def rt_data_stale(self) -> bool: + """Is real time data stale.""" + return self._last_rt_data_received < dt.datetime.now(tz=dt.UTC) - dt.timedelta(seconds=60) async def get_historic_data( self, diff --git a/tibber/realtime.py b/tibber/realtime.py index 5bdf645..f02761b 100644 --- a/tibber/realtime.py +++ b/tibber/realtime.py @@ -111,9 +111,7 @@ async def _watchdog(self) -> None: assert isinstance(self.sub_manager.transport, TibberWebsocketsTransport) await asyncio.sleep(60) - _retry_count = 0 - next_test_all_homes_running = dt.datetime.now(tz=dt.UTC) while self._watchdog_running: await asyncio.sleep(5) if ( @@ -122,28 +120,10 @@ async def _watchdog(self) -> None: > dt.datetime.now( tz=dt.UTC, ) - and dt.datetime.now(tz=dt.UTC) > next_test_all_homes_running ): - is_running = True - for home in self._homes: - _LOGGER.debug( - "Watchdog: Checking if home %s is alive, %s, %s", - home.home_id, - home.has_real_time_consumption, - home.rt_subscription_running, - ) - if not home.rt_subscription_running: - is_running = False - next_test_all_homes_running = dt.datetime.now(tz=dt.UTC) + dt.timedelta(seconds=60) - break - _LOGGER.debug( - "Watchdog: Home %s is alive", - home.home_id, - ) - if is_running: - _retry_count = 0 - _LOGGER.debug("Watchdog: Connection is alive") - continue + _retry_count = 0 + _LOGGER.debug("Watchdog: Connection is alive") + continue self.sub_manager.transport.reconnect_at = dt.datetime.now(tz=dt.UTC) + dt.timedelta(seconds=self._timeout) _LOGGER.error(