Xiaomi wireless button light automation (with zigbee2mqtt)

Hello!

I have a problem with the Xiaomi Wireless Button and Aqara Light Bulb. I use homeassistant with zigbee2mqtt addon. I can’t be able to automate the bulb with the button.

Here is my code from the automation.yaml:

- id: toggle_my_light
  alias: Toggle dining light on single press
  trigger:
    - platform: event
      event_type: xiaomi_aqara.click
      event_data:
        entity_id: sensor.0x00158d00026db4f3_click
        click_type: single
  action:
    service: switch.toggle
    entity_id: light.0x00158d0002d755c6_light

When I click the button, nothing happens. But it zigbee2mqtt logs there are logs about clicks:

  zigbee2mqtt:info 6/5/2019, 6:03:11 PM MQTT publish: topic 'zigbee2mqtt/0x00158d00026db4f3', payload '{"linkquality":44,"battery":100,"voltage":3072,"click":"single"}'
  zigbee2mqtt:info 6/5/2019, 6:03:11 PM MQTT publish: topic 'zigbee2mqtt/0x00158d00026db4f3', payload '{"linkquality":44,"battery":100,"voltage":3072,"click":""}'

What am I doing wrong? Should I add something to the confugiration.yaml? Maybe xiaomi_aqara from here? But where I can find the key from zigbee2mqtt?

I found a solution here!

Here is the working solution:

- id: toggle_my_light
  alias: Turn_on_off_yeelight
  trigger:
      platform: state
      entity_id: sensor.0x00158d00026db4f3_click
      to: 'single'
  action:
      service: light.toggle
      entity_id: light.0x00158d0002d755c6_light

I think that problem was with the xiaomi_aqara: it works only when homeassistant is connected to the Aqara Hub. But I use zigbee2mqtt instead of it.

1 Like