diff --git a/openevsehttp/__main__.py b/openevsehttp/__main__.py index ffe8901..6fdc135 100644 --- a/openevsehttp/__main__.py +++ b/openevsehttp/__main__.py @@ -239,8 +239,9 @@ def _start_listening(self): _LOGGER.debug("Using new event loop...") if not self._ws_listening: + _LOGGER.debug("Setting up websocket ping...") + self._loop.create_task(self.repeat(300, self.websocket.keepalive)) self._loop.create_task(self.websocket.listen()) - self._loop.create_task(self.repeat(300, self.websocket.keepalive())) pending = asyncio.all_tasks() self._ws_listening = True try: @@ -311,10 +312,8 @@ async def repeat(self, interval, func, *args, **kwargs): *args and **kwargs are passed as the arguments to func. """ while True: - await asyncio.gather( - func(*args, **kwargs), - asyncio.sleep(interval), - ) + await asyncio.sleep(interval) + await func(*args, **kwargs) async def get_schedule(self) -> Union[Dict[str, str], Dict[str, Any]]: """Return the current schedule."""