Hi all, I think it’s something simple, but I’m trying to link a Xiaomi Smart button to a set of lights using an automation.
I’ve got the button connected via deCONZ so HA sees only the battery sensor; so I’ve dug around in the log files and found the event ID for a button press. I’ve written an automation but it’s not working, so I’m hoping someone can tell me what I’m doing wrong.
This is the automation
- alias: 'Toggle Bedroom Lights'
initial_state: 'off'
trigger:
platform: event
event_type: deconz_event
event_data:
id: sensor.switch_12_battery_level
event: 1002
action:
service: light.toggle
entity_id: light.bedroom_main
And this is the log file entry for a button press
2019-07-18 14:27:53 DEBUG (MainThread) [pydeconz.websocket] Websocket data: {"e":"changed","id":"12","r":"sensors","state":{"buttonevent":1002,"lastupdated":"2019-07-18T13:27:54"},"t":"event","uniqueid":"00:15:8d:00:02:3e:79:bb-01-0006"}
VolkerKa
(Volker Ka)
July 18, 2019, 6:49pm
2
Hello thekevinkalis,
I’m not a professional but maybe I can help you. I’ve attached my automation here
- alias: Power Button
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: tradfri_fernbedienung
event: 1002
action:
service: switch.toggle
entity_id: switch.0320018160019479e078
id: 6bf0a3fd9b82431199495fc1094ac3d5
The automation runs without problems. The right formatting is especially important!
I suspect the problem is in these lines:
alias
initial_state
???
Good luck
walaj
(Jon Waland)
July 19, 2019, 12:45am
3
thekevinkalis:
initial_state: ‘off’
this means the automation is not waiting for trigger, and probably not what you meant?
(the alias is fine)
Assuming the automation still doesn’t work, use the developer/states page to view the status of the switch as it changes…
walaj
(Jon Waland)
July 19, 2019, 12:48am
4
and then the developer event listener:
Hi, I see what you mean about the initial_state, it’s actually unnecessary as far as the automation goes.
I finally got it working by changing the ID to ‘smart_button’, that’s actually what it says in the developers page for events.
1 Like