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.
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
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
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
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.
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.
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.
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
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.