After a few tries, I figured it out. Writing all the steps here in case somebody is new to this.
-
In your HA, go to developer tools > events (
/developer-tools/event) and start listening tozha_event. -
In the Aqara switch press the button once. The response will be something like:
{ "event_type": "zha_event", "data": { "device_ieee": "00:11:22:33:44:55:66:77", "unique_id": "00:33:44:45:62:6a:e4:d1:1:0x0012", "endpoint_id": 1, "cluster_id": 18, "command": "single", "args": { "value": 1 } }, "origin": "LOCAL", "time_fired": "2020-06-29T07:53:39.352842+00:00", "context": { "id": "2a7f8a62bc1041139fdf8a6d287e7fdd", "parent_id": null, "user_id": null } }You need the things listed under
data. -
In the Automations UI, add a new automation:
-
Add a new trigger
-
Select “Event” from the dropdown
-
set
zha_eventas the event type -
In the event data you want the unique stuff that’s under
datain the previous step, but converted into YAML.For single click, it should be:
device_ieee: '00:11:22:33:44:55:66:77' unique_id: '00:33:44:45:62:6a:e4:d1:1:0x0012' command: single args: value: 1For double click, it should be:
device_ieee: '00:11:22:33:44:55:66:77' unique_id: '00:33:44:45:62:6a:e4:d1:1:0x0012' command: double args: value: 2For shake, it should be:
device_ieee: '00:11:22:33:44:55:66:77' unique_id: '00:33:44:45:62:6a:e4:d1:1:0x0012' command: shake args: value: 18
-
In the end, the entry in automations.yaml should look like:
- id: ikealight
alias: IKEA light toggle
trigger:
- event_data:
device_ieee: 00:11:22:33:44:55:66:77
unique_id: 00:33:44:45:62:6a:e4:d1:1:0x0012
command: single
args:
value: 1
event_type: zha_event
platform: event
action:
- entity_id: light.ikea
service: light.toggle