Axel
(Axel)
May 14, 2019, 7:36pm
1
Hello,
I’m trying to create a basic automation using a Xiaomi Square (WXKG11LM) to turn_on a light.
I have checked on forum and googled it but still doesn’t work after some tests…
Here is the automation :
- id : 'light_bulb_automation_click'
alias: Light Bulb Click
trigger:
platform: event
event_type: xiaomi_aqara.click
event_data:
entity_id: sensor.0x00158d000204a63d_click
click_type: single
action:
- service: light.toggle
entity_id:
- light.bulb_floor
Everywhere, i see binary_sensor instead of sensor that i have, could it be the issue ?
Thank you for your help.
Axel
(Axel)
May 15, 2019, 10:46am
2
Hello,
To complete the request, i can see the click status in the service tab.
I really don’t know what i missed.
Axel
Axel
(Axel)
May 15, 2019, 4:14pm
3
Hello,
Speaking alone but find my way.
Here is what i have done for someone looking to use it :
id : ‘light_bulb_automation_click’
alias: Light Bulb Click
initial_state: true
hide_entity: true
trigger:
platform: mqtt
topic: ‘zigbee2mqtt/0x00158d000204a63d’
condition:
condition: template
value_template: “{{ ‘single’ == trigger.payload_json.click }}”
action:
service: light.toggle
entity_id: light.bulb_floor
service: notify.ios_iphax
data:
title: “[LIGHT] {{states(‘light.bulb_floor’)}}”
message: “Floor Bulb”
apop
May 15, 2019, 4:35pm
4
Your initial automation would have worked if you were using the Xiaomi hub. Since you are using Zigbee2MQTT that’s why your latest attempt worked.
Axel
(Axel)
May 15, 2019, 4:46pm
5
Yes indeed.
It’s why i have changed and used the platform mqtt instead.
hijinx
(James)
May 15, 2019, 4:53pm
6
My suggestion would be to use node-red for this type of automation.
its expecially easy if you also use hassio since the add-on for nodered is all preconfigured for home assistant integration.
Using xiaomi buttons your automation is as simple as this:
Event from the button --> Switch for whether its one click or two --> action for each 1/2 clicks
123
(Taras)
May 15, 2019, 4:57pm
7
Look at the lists of entities shown on the States page. That’s where you will learn if the device is represented as a sensor
or binary_sensor
.
1 Like
Axel
(Axel)
May 16, 2019, 6:20am
8
@hijinx Indeed, i have nodered installed also but not yet try it. I’ll use for this automation and check how is it going.
hijinx
(James)
May 16, 2019, 9:32am
10
I’m putting all my automations through node-red now.
I much prefer it to yaml.
Axel
(Axel)
May 16, 2019, 10:45am
11
Ok.
With Nodered, just created the automation and click deploy directly work on Hassio ?
Axel
(Axel)
May 16, 2019, 10:52am
13
Ok let’s try later.
I’ll already created an automation for the Single and Double clicks :
Same logic as you but it’s for test.
Akriss
(kris)
June 20, 2019, 10:47pm
14
I was fumbling with this.
Then I came upon this post (#3 ) with the automation template you came up with.
Now it makes sense.
Thanks.
Umbe
(Umberto)
March 8, 2020, 5:45pm
15
Hi , just trying to make your script working but no luck.
- id : ‘click’
alias: Light Bulb Click
initial_state: true
hide_entity: true
trigger:
- platform: mqtt
topic: ‘zigbee2mqtt/0x00158d0002eb5a33’
condition:
condition: template
value_template: “{{ ‘single’ == trigger.payload_json.click }}”
action:
- entity_id: light.living_room
service: light.toggle
Invalid config for [automation]: [condition] is an invalid option for [automation]. Check: automation->trigger->0->condition. (See ?, line ?).
Any help?
thanks
123
(Taras)
March 8, 2020, 5:53pm
16
Try this:
- id: 'click'
alias: 'Light Bulb Click'
trigger:
platform: mqtt
topic: 'zigbee2mqtt/0x00158d0002eb5a33'
condition:
condition: template
value_template: "{{ trigger.payload_json.click == 'single' }}"
action:
service: light.toggle
entity_id: light.living_room
Notice the difference in indentation and the type of single and double quotes used.
Umbe
(Umberto)
March 16, 2020, 6:49pm
17
thanks
i solved
- id: welcome
alias: welcome_home
trigger:
- platform: state
entity_id: sensor.0x00158d0002eb5a33_click_1
to: single
condition: []
action:
- entity_id: light.living_room
service: light.toggle