Skip to content

Commit

Permalink
test fire_last_message_received
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmpp committed May 13, 2024
1 parent 7fb07a5 commit 12d73e1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions custom_components/eltako/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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!)"""
Expand All @@ -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() )
)

Expand Down

0 comments on commit 12d73e1

Please sign in to comment.