From 12d73e19cc250ec5012317393852b5b824904a16 Mon Sep 17 00:00:00 2001 From: Philipp Grimm Date: Mon, 13 May 2024 14:08:37 +0200 Subject: [PATCH] test fire_last_message_received --- custom_components/eltako/gateway.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/custom_components/eltako/gateway.py b/custom_components/eltako/gateway.py index ccdfcf84..ec6e4f95 100644 --- a/custom_components/eltako/gateway.py +++ b/custom_components/eltako/gateway.py @@ -62,7 +62,7 @@ def __init__(self, general_settings:dict, hass: HomeAssistant, self._attr_dev_type = dev_type self._attr_serial_path = serial_path self._attr_identifier = basename(normpath(serial_path)) - self.hass = hass + self.hass: HomeAssistant = hass self.dispatcher_disconnect_handle = None self.general_settings = general_settings self._attr_dev_id = dev_id @@ -105,9 +105,10 @@ def _fire_last_message_received_event(self): # 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) ) - ) + # self.hass.async_add_executor_job( + # self._last_message_received_handler( datetime.utcnow().replace(tzinfo=pytz.utc) ) + # ) + LOGGER.info("LAST RECEIVED MESSAGE") def set_received_message_count_handler(self, handler): @@ -120,9 +121,10 @@ def _fire_received_message_count_event(self): # 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 ) - ) + # self.hass.async_add_executor_job( + # self._received_message_count_handler( self._received_message_count ) + # ) + LOGGER.info("RECEIVED MESSAGE COUNT EVENT") def process_messages(self, data): """Received message from bus in HA loop. (Actions needs to run outside bus thread!)""" @@ -131,7 +133,8 @@ 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_create_task( + self.hass.async_add_executor_job( self._connection_state_handler( self._bus.is_active() ) )