Skip to content

Commit

Permalink
fix(binary_sensor): changes async_write_ha_state method to schedule_u…
Browse files Browse the repository at this point in the history
…pdate_ha_state in is_on()
  • Loading branch information
adutchak committed May 2, 2024
1 parent 6b70043 commit 7be2f0e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/dahua/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ def is_on(self):
This is the magic part of this sensor along with the async_added_to_hass method below.
The async_added_to_hass method adds a listener to the coordinator so when the event is started or stopped
it calls the async_write_ha_state function. async_write_ha_state gets the current value from this is_on method.
it calls the schedule_update_ha_state function. schedule_update_ha_state gets the current value from this is_on method.
"""
return self._coordinator.get_event_timestamp(self._event_name) > 0

async def async_added_to_hass(self):
"""Connect to dispatcher listening for entity data notifications."""
self._coordinator.add_dahua_event_listener(self._event_name, self.async_write_ha_state)
self._coordinator.add_dahua_event_listener(self._event_name, self.schedule_update_ha_state)

@property
def should_poll(self) -> bool:
Expand Down

0 comments on commit 7be2f0e

Please sign in to comment.