Filter Deconz Event from Switches - beginner

I’m new to Node-RED and not much of a programmer. I have done some automations with time, motion sensors, lights etc but having problems with my switches that is connected via Deconz to Hassio.

I have managed to get them into Node-RED with an “event all” followed by a function to read the output via msg.payload to debug.

if (msg.payload.event_type === “deconz_event”)
{ return msg ; }
else { return null;}

The debug gives me this very useful info like this
2/16/2019, 6:23:16 PMnode: 37f1b8dd.30efe8deconz_event : msg.payload : Object
object
event_type: “deconz_event”
event: object
id: “sovrum”
event: 1002

I want to filter this on booth
id: “sovrum” # Switch
event: 1002 # 1xxx = the button and xxx2 how I’m pushing the button.

As I said, I’m not much of a programmer so I need help on how to filter this and most of all, is there some smart way to simplify this? I have about 20 buttons of 7 different types by Philips, Ikea and Xiaomi.

I have read a lot of posts to try to figure this out myself cause I can’t imagine I’m the first with this problem, without getting any wiser :slight_smile:

1 Like

I am gonna eventually move to deconz. So i can’t give you exact details but a switch node you can have multiple outputs, just add them in the configuration. Iif 'id’s are buttons or devices just add their different names

image

So for each output you’re gonna perform an automation from there you can start using the call service or state nodes.

Also if you the events node you can just filter by adding the event name

2 Likes

After som tinkering I realized it should be “payload.event.id” :slight_smile:

Thanks mate

2 Likes

After some more tinkering, this is what I came up with.

Is this a good way to do it or is there a simpler one?

In Switch type, I’m figuring out which type of switch it is to make it easier to know what commands that is possible to send from the switch. Off course I don’t need this switch but that would make it harder to get an overview of what kind of switch it is and what it’s capable off.

Which switch is where I finding out which the switch I’m gonna use for the automation.

Button action, in the example I use a Philips Hue Dimmer Switch with 4 buttons and two actions per button.

2 Likes

Yes that’s the way. I use to have similar for when using xiaomi gw for events.
To know better which type of click you can configure the output labels of the switch to assign a name so when you hover over the output circle displays the label.

1 Like

You mind to share your node?
I am aiming for something similiar but still new to nodered :slight_smile:

Is this a good way to do it or is there a simpler one?

“Simple” is a matter of opinion I think. Personally I use a “sugarcoater”, which gives me easier access to the name of the switch and the event code, and then tunnels it through a link node. The benefit is that all traffic goes through the same event node, and get processed by the same sugarcoats, but the individual flows can be separated so it won’t get big and messy over time.

This screenshot shows the simple version, in reality I process it a bit more for my personal needs. The two link nodes are connected, but the top one is also connected to a lot of other flows.

sugarcoat

2 Likes

Hello! That is exactly what i’m searching for, is it possible to share the flow ?

:grin:

Hello subzero79

Thank you for your reference.
With your help, I can now also filter the “event” and then start further events accordingly !!!

Great and thanks again !!! Have here two screenshots …

First I filter only the ads from the “events: all” node…


… and now I sort the respective number to an exit with the “switch” node…

:+1::grinning::checkered_flag:

1 Like

Can I ask how your switch node looks in the sugarcoats?

In my house the convention is that all switches ends in _switch, the switch node just filters out events where the entity doesn’t end in _switch, like this :slight_smile:

Ok thanks. I wasnt able to get mine to work, but I used the link feature so that helped me clean up my nodes pretty much.

Pulling up this old thread:
Got the whole setup working. Yet on a hue dimmer when doing long press, it first fires a short press Event.
If i hang 2 lights behind a switch, both get turned on.
Yet with a long press i would expect only the light to turn on that is behind the long press event.
Anybody an idea how to avoid this?

Don’t use the short press event for the first action. Use the "release after short press"event for the first action.
This only gets sent after a short press.

Oh man, thank you so much :slight_smile:

Hello,

i am also trying ti use the switch to filter the brightness event but unfortunaletty this does not seem to work.


However if i remove the brightness attribute the debug node behind the switch gets the payload.

Any ideas?

thanks in advance.
Markus

I second the request for sharing this flow. Simple or not I like the way you are thinking! Would love the help. Thanks