Node Red - help with a button

How do you configure a button in node red? Can it be done with out button control in HE?

Here is what I did, it sends an event every time I push the button.

[{"id":"8ec73998.611c08","type":"hubitat device","z":"83bcdcf4.a69c4","name":"Becca Room: Button","server":"f17566a9.c052b8","deviceId":"2783","attribute":"pushed","sendEvent":true,"x":170,"y":440,"wires":[["4e0113c7.a8f8bc"]]},{"id":"f17566a9.c052b8","type":"hubitat config","z":"","name":"","usetls":false,"host":"192.168.2.3","port":"80","appId":"3424","nodeRedServer":"http://192.168.2.9:1880","webhookPath":"/hubitat/webhook","autoRefresh":true}]

yah, i've got that node, but i just want to single tap one time to turn on and again to turn a switch off. Is that possible? I'm not sure how to set it up to accomplish that.

The first time it will init the flow var, then it will toggle after that.

[{"id":"8ec73998.611c08","type":"hubitat device","z":"83bcdcf4.a69c4","name":"Becca Room: Button","server":"f17566a9.c052b8","deviceId":"2783","attribute":"pushed","sendEvent":true,"x":170,"y":440,"wires":[["4e0113c7.a8f8bc"]]},{"id":"c59bbf7.5a2384","type":"switch","z":"83bcdcf4.a69c4","name":"Check on","property":"RoomActive","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":520,"y":440,"wires":[["7f8e0e1c.881f9"],["3fb9d70.45dbc2a"]]},{"id":"7f8e0e1c.881f9","type":"change","z":"83bcdcf4.a69c4","name":"Set Active False","rules":[{"t":"set","p":"RoomActive","pt":"flow","to":"false","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"Active","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":420,"wires":[["9c4f9ea3.df6e2","7bef2392.f769fc"]]},{"id":"3fb9d70.45dbc2a","type":"change","z":"83bcdcf4.a69c4","name":"Set Active True","rules":[{"t":"set","p":"RoomActive","pt":"flow","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"Active","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":460,"wires":[["9c4f9ea3.df6e2"]]},{"id":"4e0113c7.a8f8bc","type":"switch","z":"83bcdcf4.a69c4","name":"Check on","property":"RoomActive","propertyType":"flow","rules":[{"t":"nnull"},{"t":"null"}],"checkall":"true","repair":false,"outputs":2,"x":300,"y":540,"wires":[["c59bbf7.5a2384"],["e0f6d067.1f35d"]]},{"id":"e0f6d067.1f35d","type":"change","z":"83bcdcf4.a69c4","name":"Set Active True","rules":[{"t":"set","p":"RoomActive","pt":"flow","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"Active","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":580,"wires":[["c59bbf7.5a2384"]]},{"id":"f17566a9.c052b8","type":"hubitat config","z":"","name":"","usetls":false,"host":"192.168.2.3","port":"80","appId":"3424","nodeRedServer":"http://192.168.2.9:1880","webhookPath":"/hubitat/webhook","autoRefresh":true}]

checking it out ...

in the set active true/false block you only need to set the flow. active to true/false, the other 2 sets are for my ultimate boolean that is next.

so then i flow this into a switch?

That should work, connect the set active true to the switch on, and the false to switch off.

Ok, that's what I did. I need to go test it. I'm sure it's exactly what I'm looking for.

I would hope that one click would turn on, the next click would turn off :slight_smile:

1 Like

would you be willing to explain the check on set active nodes in it? How does that work?

renamed for better example:)
The check null checks if the local var flow.RoomActive has been set, if not set active true, then both go to check on, where if RoomAvtive is true, it goes to set active false, and if RoomActive is false, it goes to set RoomActive true. The check on and the set blocks create the toggle. if it is false, set it to true, if it is true, set it to false. it would probably be easier to do it with check the switch. if switch on, turn it off, but I have my Boolean and a slightly different need. But this shows how to toggle.

1 Like

simple method:

[{"id":"60c3937d.db2fdc","type":"hubitat device","z":"83bcdcf4.a69c4","name":"Becca Room: Button","server":"f17566a9.c052b8","deviceId":"2783","attribute":"pushed","sendEvent":true,"x":160,"y":720,"wires":[["9ba286a1.104b48"]]},{"id":"16ddfa03.c95096","type":"hubitat command","z":"83bcdcf4.a69c4","name":"Becca Room: Light on","server":"f17566a9.c052b8","deviceId":"2971","command":"off","commandArgs":"","x":860,"y":780,"wires":[[]]},{"id":"d10586e7.2d8248","type":"hubitat command","z":"83bcdcf4.a69c4","name":"Becca Room: Light off","server":"f17566a9.c052b8","deviceId":"2971","command":"off","commandArgs":"","x":860,"y":680,"wires":[[]]},{"id":"9ba286a1.104b48","type":"hubitat device","z":"83bcdcf4.a69c4","name":"Becca Room: Light","server":"f17566a9.c052b8","deviceId":"2971","attribute":"switch","sendEvent":false,"x":430,"y":720,"wires":[["2639194f.ac5f46"]]},{"id":"2639194f.ac5f46","type":"switch","z":"83bcdcf4.a69c4","name":"Check on","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":600,"y":720,"wires":[["d10586e7.2d8248"],["16ddfa03.c95096"]]},{"id":"f17566a9.c052b8","type":"hubitat config","z":"","name":"","usetls":false,"host":"192.168.2.3","port":"80","appId":"3424","nodeRedServer":"http://192.168.2.9:1880","webhookPath":"/hubitat/webhook","autoRefresh":true}]

1 Like

Here is a screen cap of my den pico sequence.. The toggle subflow can actually be a simple change node with jsonata ..

set msg.command = jsonata / payload.value = "on" ? "off" : "on"

2 Likes

the simple method confuses me. But I can't see the attributes you you have to for the light and why the check on works?

The button block is to get the event that the button was pushed.
The light device block has send event off, and the attribute is switch. So that the payload value is now that of the switch you want to turn on or off.
The check on switch block checks the payload value coming from the switch to see if the light is currently on or off.
If the switch is on, turn it off, and vice versa.

2 Likes

Love this, it's made it into my NR

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