From 0125823a0e3abe2cfc11773599007f5d5e0ada3f Mon Sep 17 00:00:00 2001 From: Philipp Grimm Date: Mon, 13 May 2024 14:32:38 +0200 Subject: [PATCH] test fire_last_message_received --- custom_components/eltako/gateway.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/custom_components/eltako/gateway.py b/custom_components/eltako/gateway.py index e298c5dd..27927664 100644 --- a/custom_components/eltako/gateway.py +++ b/custom_components/eltako/gateway.py @@ -102,17 +102,10 @@ def set_last_message_received_handler(self, handler): def _fire_last_message_received_event(self): if self._last_message_received_handler: - # self.hass.async_create_task( - # self._last_message_received_handler( datetime.utcnow().replace(tzinfo=pytz.utc) ) - # ) - # self.hass.async_add_executor_job( - # self._last_message_received_handler( datetime.utcnow().replace(tzinfo=pytz.utc) ) - # ) asyncio.ensure_future( self._last_message_received_handler( datetime.utcnow().replace(tzinfo=pytz.utc) ), loop= self._loop ) - LOGGER.info("LAST RECEIVED MESSAGE") def set_received_message_count_handler(self, handler): @@ -122,12 +115,10 @@ def set_received_message_count_handler(self, handler): def _fire_received_message_count_event(self): self._received_message_count += 1 if self._received_message_count_handler: - # self.hass.async_create_task( - # self._received_message_count_handler( self._received_message_count ) - # ) - # self.hass.async_add_executor_job( - # self._received_message_count_handler( self._received_message_count ) - # ) + asyncio.ensure_future( + self._received_message_count_handler( self._received_message_count ), + loop= self._loop + ) LOGGER.info("RECEIVED MESSAGE COUNT EVENT") def process_messages(self, data): @@ -137,9 +128,9 @@ def process_messages(self, data): def process_connection_status_signal(self, data): if self._connection_state_handler: - # self.hass.async_create_task( - self.hass.async_add_executor_job( - self._connection_state_handler( self._bus.is_active() ) + asyncio.ensure_future( + self._connection_state_handler( self._bus.is_active() ), + loop= self._loop )