Node red ZHA trigger - correct way of doing it?

Hi - I’ve got plenty of HA automations, but want to migrate over to node red as I find that has more scope. It’s also a little more reliable for time based triggers.

I have a load of zigbee (Aqara) sensors and buttons. I created an event listener for the ZHA event. I then have a switch for the ID of the device to see which sent the command.

Is this the correct way of doing it? I will be adding a lot more sensors in the coming weeks and would rather get it right from the beginning.

Thanks for any advice!

That is one way.
You can also use a function node if you find that easier. That means you code your way to get where the message should go.
That means you could condense the sequence to “blue nodes” (ZHA Event, and call services) and just the function node in between with multiple outputs.
It will make the sequence smaller, but depending on your preference perhaps harder to interpret/debug and follow.

You could also use more ZHA Event nodes.
That way you could split them better between lounge and Emily selector.

You could also use a device node for each button.

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/node/device.html

The device node is broken for me, with ZHA devices. They never gives an output.
Anyone else?

This is exactly how I am handling my ZigBee buttons. Works well, allowing me to separate single press, double press and hold event triggers. I usually have flows triggered by these for all buttons in the house.

Please, can you share node-red code for this?
I would like to go same way like you.

Is this what you are looking for?

I thought this would be more help than the raw node-red flow code itself as it helps show the logic and 2 different device cases. I have a total of 6 buttons that are a part of the entire flow, the 6 IEEE identifiers in the first switch node, all using the same logic.

2 Likes

Could you upload a higher resolution image? It is very blurry

2 Likes