Skip to content

Events

Your device must be added to localtuya to use Events

Localtuya fires an events on homeassisstant that can be used on automation or monitoring your device behaviour from Developer tools -> events (1)

  1. to monitor your device subscribe to any event below and trigger action on the device using tuya app

With this you can automate devices such as scene remote (1) to trigger an action on homeassistant

  1. e.g. single click, double click or hold.
Event Data
localtuya_status_update {"data": {"device_id", "old_status", "new_status"} }
localtuya_device_dp_triggered {"data": {"device_id", "dp", "value"} }

Examples

# This will only triggers if status changed.
trigger:
  - platform: event
    event_type: localtuya_status_update
condition: []
action:
  - service: persistent_notification.create
    data:
      message: "{{ trigger.event.data }}"
# This will always triggers if DP used.
trigger:
  - platform: event
    event_type: localtuya_device_dp_triggered
condition: []
action:
  - service: persistent_notification.create
    data:
      message: "{{ trigger.event.data }}"
example of an automation to trigger a scene when the first button on a remote is single-clicked
trigger:
  - platform: event
    event_type: localtuya_device_dp_triggered
    event_data:
      device_id: bfa2f86e3068440a449dhd
      dp: "1" # quotes are important for dp
      value: single_click 
condition: []
action:
  - service: persistent_notification.create
    data:
      message: "{{ trigger.event.data }}"

Database flooding

If the recorder is enabled, devices like temperature sensors may update frequently (e.g., every second). This can cause excessive events and significantly increase database size. It is recommended to exclude localtuya events from the recorder to prevent database overload.

recorder:
  exclude:
    event_types:
      - localtuya_status_update
      - localtuya_device_dp_triggered