Capture switch click event in Node-red

Hi All

I am trying to migrate an automation over to Node-red and the part where i need to capture a click event (single) from a Xiaomi wireless switch has me stumped. Xiaomi switches don’t seem to change a state to on/off but the click event can be used in HASS, how do i capture this in Node-red.

This is my yaml code in HASS.

alias: toggle door sensors automation
trigger:
platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d0001240338
click_type: single
action:
service: automation.toggle
data:
entity_id: automation.sensors_active

I’m stuck with this issue as well. Have you had any luck figuring it out?

+1
Looking for a solution here as well…

Hi
I managed to do what i required by using the Xiaomi node in Node-red

node-red-contrib-mi-devices
This way i got status of the click event from the gateway itself

2 Likes

Hi there, first post here. This is what i figure out using the home assistant flow, I’ve used two switches nodes, the first one selects the entity_id, the next one switches in between click_type.

Now with round xiaomi button turns one light on single click and a different one on double.

Left the flow in gist