I am using the Xiaomi Aqara Double switch (WXKG02LM).
Using Zigbee2MQTT I get proper messages: ‘zigbee2mqtt/0x00158d00023a892d’, payload: ‘{“battery”:100,“voltage”:3125,“linkquality”:5,“click”:“right”}’
Following this tutorial Home Assistant Tutorial I found out that my options are: xiaomi_aqara.clickclick_typesingle , both
I am using the Home Assistant webinterface for the automation.
If I don’t put a value in the Trigger >>> Payload, everything works. Meaning, the light turns on and off. BUT: I want to differentiate between the left and right button - and even both.
Again, the info page states: xiaomi_aqara.clickclick_typesingle , both
I spent an hour experimenting with different syntax combinations of:
single: left
Or as my mqtt receives the messages: “click”:“right”
I played with single and double quotation marks, curly brackets, colon, =, …
Didn’t try these WXKG02LM switches yet with the zigbee2mqtt, but use them still with my xiaomi hub.
But could it be that you mix up the HA fundamentals?
The “event” of these switches is “click” and the “event values” is “single” and “double”, but the “entities” are something like :
binary_sensor.wall_switch_left_158d000170eeab
binary_sensor.wall_switch_right_158d000170eeab
binary_sensor.wall_switch_both_158d000170eeab
(these are my xiaomi hub entities, zigbee2mqtt shows probably something else, but should be with left, right and both)
If zigbee2mqtt and HA are working correctly you should be able to find these entities in the “states” overview ( the “<>” under “Developer Tools” in HA sidepanel).
Seems like the whole automation got it’s own .yaml
Seems like the syntax has changed, as it’s a markup-language, that should be of importance… So my other automation that work have an ID and there are dashes…
What looks quite good to me but does not work (HomeAssistant won’t even boot properly):
Can you edit the previous post and format the yaml using the instructions in the blue box at the top of the page. I will then be able to paste that in to my configuration to see what is wrong.
In general, the types of quotes are interchangeable. Just make sure you don’t try and nest the same type.
Switching the Xiaomi Aqara Double switch (WXKG02LM) from Xiaomi gateway to zigbee2mqtt now works fine in my setup with left and right selections. For example the left button reacts correctly in following way:
Could you post your automation.yaml code about the above screenshot?
I’m trying to switch from xiaomi gateway to zigbee2mqtt my WXKG02LM…but w/o any kind of luck.
In HA, my switch is of type “sensor” and not “binary_sensor” as it should be…I don’t know why honestly
For your info, I have mqtt discovery set to “true” on zigbee2mqtt hassio addon
As I can see from your code, you have the same…issue…as I have.
With this kind of code (mine is very similar), when you reload your automations.yaml (configuration --> general) or restart HA server, the automations will be executed (with ‘initial_state: true’) in accordance with the last state of your buttons (i.e. if you have clicked the left button to toggle your switch off before HA restart, on the reboot the automation starts and it will toggle the switch on automatically…).
On the other side, if you do not set ‘initial_state’ (it will assume ‘false’, as you know) or set it to false, the automation will not be empowered on the next HA boot and you have to enable it by hand.
What can we do against this (for me, at least) very annoying…behaviour?
Hmm, didn’t notice this with restarts. Perhaps because I have, next to the automatons for this switch, also automation for the same lights to turn on by sunset and to turn off late evening.
And I do not restart HA often, so I have no real problem with this behaviour. Anyway, I didn’t notice any non logical behaviour.
Ok, this sounds well…nevertheless, do you know any kind of possible workaround?
For me, this behavior is not much appropriated, especially because I my automations very often and this thing append every time I reload .yaml file…
I’m sorry but this isn’t true…for me, at least.
I have just (re)tried, and I can confirm you that my automations get enabled (and triggered) on automations reload too.
See below the piece of my code I’m talking about
Are you sure the automation is getting triggered and it’s just not a “retain:” issue?
Can you look in the logbook and actually see that the automation indeed does get triggered.
And I just noticed that your trigger doesn’t include a “to:” statement (or equivalent). That means that every time there is a change in state of that topic the automation will trigger. Maybe the automation actually does get triggered because that topic is resent every time you restart. Try changing the trigger to something else to see if it fixes it.
Yea, I am sure that is not a retail issue.
In logbook I can see the automation get triggered every time I restart HA or reload automations.yaml.
The last part of your statement made me thinking…
I noticed since the beginning I linked the xiaomi dual switch with zigbee2mqtt that HA sees it as a “sensor” and not as “binary_sensor” as the addon wiki says too.
I have other sensors (aqara and mijia uman presence sensor) linked by zigbee2mqtt and each one of those is recognized rightly by HA as “binary_sensor”.
The xiami’s switches (I have two aqara dual wireless wall switch and two mijia single wireless switch) get seen as “sensor” though.
try to do this and see if you can figure out how to trigger it with a different trigger.
I don’t know why HA thinks it is a sensor instead of a binary sensor. I don’t use discovery and for pretty much this reason. If something doesn’t work quite right then you are fighting against the system automatically trying to insert stuff that you don’t want it to. And that makes troubleshooting difficult.
But thinking about it, it doesn’t really matter what kind of sensor it is. The automation will trigger every time the state of the sensor changes (or if it’s MQTT maybe whenever the topic is republished?). That’s why I suggested changing the trigger to find something else that might work.
hi I had the same issue, found out it had to do with the use of single quotes instead of double quotes.
this worked for me: '{{ ''left'' == trigger.payload_json.click }}'