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

4 Likes

More Infos please

This would be an exceptionally useful response to all those trying to find a way to detect events from ZHA devices in Home Assistant.

If only it was readable, so close so very close, the effort tag went into producing it and only to be defeated by too few pixels making it unreadable :slight_smile:

Arrrgh the frustration, so close to working out how to do it and spoilt … :slight_smile:

I have a simplified version in a short pdf. Not sure how I can post the file - if you know a way, let me know and I will share it. Otherwise, posting the images will likely have the same resolution problem.

I also have a JSON of the entire flow that this simplified version of my Button Inputs Flow is puuled from. It has all the nodes and the shenanigans that I use to accomplish what I want.