Aqara switch automations

I have a Xiaomi Aqara switch that I want to toggle on/off a light source.
I have set up this in my automations.yaml
When I press the Aqara switch nothing is happening. Can someone plase help?

- alias: Test toggle light
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
        entity_id: binary_sensor.switch_158d000201c99b
        click_type: single
  action:
    service: light.toggle
    entity_id: light.fibaro_system_fgd212_dimmer_2_level_2

Try fixing the indentation

- alias: Test toggle light
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.switch_158d000201c99b
      click_type: single
  action:
    service: light.toggle
    entity_id: light.fibaro_system_fgd212_dimmer_2_level_2

Also, is the automation turned on? (as per my example below)
image

The indentation has been corrected. The automation is on.
When I trigger the automation in “states” in home assistant it works. But when I press the Aqara switch button nothing is happening.
The Aqara button is paired in Deconz. When I look at it in VNC it reacts (blinkling blue) when I press the button.

If you’re using deconz the entit_id will not be like that and you need to trigger on a deconz_event. I asume you switched from the xiaomi gateway?
Check the docs. implementation with Deconz is slightly different but the docs explain how to do it.

Have you ensured that you have the right event type?

Normally if you are running this through Deconz, the event type is deconz_event. See below a simple trigger I’m using on a aqara button through deconz.

trigger:
  platform: event
  event_type: deconz_event
  event_data:
    id: lumi_sensor_switch_aq2_11
    event: 1002

Hello
I did not have the correct event type. deconz_event works!

I have another strange behavior right now. I have two of thees Aqara switches, and have set up two automations controling different lights each.
But when I click one of the buttons both lights are toggled. This is the same for both buttons. What am I doing wrong now?

- alias: Trådløs bryter spisestue
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      entity_id: lumi.remote.b1acn01
      event : 1002
  action:
    service: light.toggle
    entity_id: light.lys_spisestue

- alias: Toggle light test
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      entity_id: lumi.sensor_switch.aq2
      event : 1002
  action:
    service: light.toggle
    entity_id: light.fibaro_system_fgd212_dimmer_2_level_2

I’m still looking for the aswer to this question. I have googled a lot but can’t find the solution on my own. Can someone please help?

Have you got any associations in the Phoscon app between the light.lys_spisestue and the switches ?

I have not made any associations in Phoscon. The switches and the light.lys_spisestue have just been added normally. The fibaro unit at the bottom of the automation is offcourse z-wave.

Google is not going to help, there is definitely something you’re missing in your configuration. Carefully check your automations and scripts. I assume you are no longer using the Xiaomi gateway?

I never had the Xiaomi gateway, it was a mistake from my side to use the wrong event_type. I’m using a Raspbee on my Raspberry Pi3 with deconz.
I will try to comment out the automations one by one to see what happens.

Not sure about this, but I havn’t seen any entity_id’s that contains dots after the domain, i.e. remote.b1acn01, it is usually underscores as in remote_b1acn01.

I think the name is correct for the switches.
From what I have read in the forums is that under deconz_event it should be id: not entity_id:
I changed my automation but now it is not working at all.

- alias: toggle light test
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: lumi.sensor_switch.aq2
      event: 1002
  action:
    service: light.toggle
    entity_id: light.fibaro_system_fgd212_dimmer_2_level_2

ok, if you have these entity_id’s in the dev-state panel, it shoud be correct, I just have never seen entity id:s like that. My deconz entities all have underscores instead.

I changed the id: to trykkbryter or switch_15 and now it works!
Thanks for the help guys :grinning:

- alias: 'toggle light test'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: trykkbryter
      event: 1002
  action:
    service: light.toggle
    entity_id: light.fibaro_system_fgd212_dimmer_2_level_2
1 Like