Node red - Velbus Glasspanel button - Hue lights(SOLVED)

Hi,
Might be a simple answer but I can’t get this to work.

What I want to do is use a button on a velbus glaspanel button and switch a hue light on and off with the same button.

I know how to use node red to switch on a hue light and change scenes etc. What I cannot get to work is how I use the input of the velbus button and use that as a trigger for the hue action of switching the hue light on and off. When I use the openhab item in node red and use the button as input it just does not register the pressed status of the button.

Anyone did something similar or point me in the right direction?>

Thanks

I might be able to assist Mr Verbist… :wink:

Have you seen these ??

What you need is a Function node to isolate the Button Events, then query the state of your Hue Lights and act accordingly.

You can have a seperate Flow or DSL rule to change the state of the feedback LEDs dependant on the state of the HUE Thing.

Give me a shout if you need more information… (you’re the one that got me on Slack in the first place)

A pair of DSL rules might look like this

rule "Velbus button to Hue lamp"
when
Channel "velbus:vmbgp1:xxxxxxx:ch1" triggered PRESSED
then

if (Hue_Lamp_Switch.state == ON)
{ Hue_Lamp_Switch.sendCommand(OFF)
}

else

{ Hue_Lamp_Switch.sendCommand(ON)
}

end


rule "Hue Lamp to Velbus feedback"

when

Item Hue_Lamp_Switch changed

then

if (triggeringItem.state == ON)
{
VelbusGP1ButtonFeedback.sendCommand("SET_LED")
}
else

{
VelbusGP1ButtonFeedback.sendCommand("CLEAR_LED")
}

end

hehehe I did. I try that. So you are saying that I need to do the actual function in Node Red and have the led on the glaspannel feedback via a rule?

I tried fiddling with the node red function. What I can’t seem to get is the state of the velbus button. When I monitor it the button just gives met NULL

Hi :smile:

You can do either, in either.

The DSL rule examples above deal with both the button to HUE and the HUE state back to the Feedback LEDs.

Which are you happier working in?

The only thing that you should need to change in the Function node is the button address

It’ll look something like

velbus:vmbgp4:xxxxxxx:ch1

If you’ve done that, the next question is…

Have you connected the input to the Function node to the openHAB2 events node, to get all the data?

What’s the code for the button your are trying to detect, as shown in PaperUi?

Then edit the function node

[

    {
        "id": "bfe462be.f71a5",
        "type": "function",
        "z": "f5370db.29be5f",
        "name": "Your Velbus Button",
        "func": "var event = msg.payload.event;\nvar channel = msg.payload.channel;\nvar newMsg = { payload: msg.payload.event };\nvar button = \"velbus:vmbxxx:xxxxxxxx:xx:input#CHx\"\n\nif  (channel === button )  {\n\tif (event === \"PRESSED\") {\n\t\treturn [msg, newMsg, null, null];\n\t}\n\tif (event === \"LONG_PRESSED\") {\n\t\treturn [msg, null, newMsg, null];\n\t}\n\tif (event === \"RELEASED\") {\n\t\treturn [msg, null, null, newMsg];\n\t}\n}\nreturn null;",
        "outputs": 4,
        "noerr": 0,
        "x": 310,
        "y": 140,
        "wires": [
            [],
            [
                ""
            ],
            [
                ""
            ],
            [
                ""
            ]
        ],
        "outputLabels": [
            "Whole Msg",
            "PRESSED",
            "LONG_PRESSED",
            "RELEASED"
        ]
    }
]

Got it all sorted out. Super easy actually using DSL rules. Thanks @MDAR for your continued help on velbus inside openhab…

Appreciate it

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.