Skip to content

Commit

Permalink
Fix device_triggered event.
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed Mar 24, 2024
1 parent 95a5efd commit 40cd09c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/localtuya/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@ def _handle_event(self, old_status: dict, new_status: dict, deviceID=None):

def fire_event(event, data: dict):
event_data = {CONF_DEVICE_ID: deviceID or self._device_config.id}
event_data.update(data)
event_data.update(data.copy())
# Send an event with status, The default length of event without data is 2.
if len(event_data) > 2:
if len(event_data) > 1:
self._hass.bus.async_fire(f"localtuya_{event}", event_data)

event = "states_update"
Expand All @@ -483,7 +483,7 @@ def fire_event(event, data: dict):
# Device triggered event.
if old_status and new_status is not None:
event = device_triggered
data = {"states": old_status.update(new_status)}
data = {"states": new_status}
fire_event(event, data)

if self._interface is not None:
Expand Down

0 comments on commit 40cd09c

Please sign in to comment.