Xiaomi switch - how are you able to capture the click

Hi,

I have a Xiaomi aqara switch that worked fine while ago with both Xiaomi Gateway and the Nortek stick. I am aware that the new HA is not recognizing the switch clicks. Recently due to my setup change - QNAP NAS>> Virtual Machine (8 GB RAM, 40GB HD)>> HASS OS (core version 2021.2.2, OS version version 5.11) >> Sonoff Zigbee bridge flashed with Tasmota - 6.7.8, I am able to capture only the switch power and not the clicks. I added “all events” node on node red and it is able to capture the clicks but under an “unidentified entity” How do I fix this?

Below is the debug logs when I press the switch. I get three events

  1. Pressing the switch - 2 events
  2. Releasing the switch - 1 event

How do I change the entity_id? How are you all fixing this issue? Thank you.

R

2/27/2021, 9:25:08 AMnode: 77ffaa0c.9700e4zha_event : msg.payload : Object

object

event_type: “zha_event”

entity_id: undefined

event: object

device_ieee: “00:15:8d:00:01:e8:6d:ec”

unique_id: “00:15:8d:00:01:e8:6d:ec:1:0x0006”

device_id: “7e5e5c96a396f3d1953505ae46979aeb”

endpoint_id: 1

cluster_id: 6

command: “click”

args: object

click_type: “single”

origin: “LOCAL”

time_fired: “2021-02-27T14:25:09.003056+00:00”

context: object

id: “32e0b6abe532597a7a0aab7c67610863”

parent_id: null

user_id: null

2 second event
2/27/2021, 9:25:08 AMnode: 77ffaa0c.9700e4zha_event : msg.payload : Object

object

event_type: “zha_event”

entity_id: undefined

event: object

device_ieee: “00:15:8d:00:01:e8:6d:ec”

unique_id: “00:15:8d:00:01:e8:6d:ec:1:0x0006”

device_id: “7e5e5c96a396f3d1953505ae46979aeb”

endpoint_id: 1

cluster_id: 6

command: “attribute_updated”

args: object

attribute_id: 0

attribute_name: “on_off”

value: true

origin: “LOCAL”

time_fired: “2021-02-27T14:25:09.003154+00:00”

context: object

id: “5a9fb87163528d45d3d03b46517a7354”

parent_id: null

user_id: null

  1. switch release
    2/27/2021, 9:26:41 AMnode: 77ffaa0c.9700e4zha_event : msg.payload : Object

object

event_type: “zha_event”

entity_id: undefined

event: object

device_ieee: “00:15:8d:00:01:e8:6d:ec”

unique_id: “00:15:8d:00:01:e8:6d:ec:1:0x0006”

device_id: “7e5e5c96a396f3d1953505ae46979aeb”

endpoint_id: 1

cluster_id: 6

command: “attribute_updated”

args: object

attribute_id: 0

attribute_name: “on_off”

value: false

origin: “LOCAL”

time_fired: “2021-02-27T14:26:42.065093+00:00”

context: object

id: “9c43b62755e20cc1400b265e235dddca”

parent_id: null

user_id: null

Hi
I just look for a trigger: zha_event with the device_ieee: “xx:xx:xx”. Then as an action look for the command: “click”. I use node-red and connect the HA automation to node-red via Mqtt so my automation action might look a little squirrly:
Trigger:
Event
zha_event
event data: device_ieee:

Action done in yaml

service: mqtt.publish
data_template:
topic: buttons/pressed/mancavedesklightbutton
payload: ‘{{trigger.event.data[’‘command’’]}}’

So when I see the command is click I know it’s been pressed.
Hope this helps

Thank you, I will try and let you know.

Thank you that worked. Any idea how can this be done using Nodered?

Hi
I’m just learning about all of this so I imagine there is a better way than mine. I use the above information I gave you in a HA automation. But 99% of what I do is in node-red so for the rest of the automation I use a MQTT In node in node-red with the topic of: buttons/pressed/mancavedesklightbutton. I then feed the output to a Switch Node looking for the “click” command in the msg.payload. If == to then I output from the switch node.
So you need to have a MQTT broker installed in supervisor (I just used the mosquitto broker) which allows the node-red mqtt in node to listen for the topic.
Node-RED-Home-Assistant