Maintained buttons

I see the buttons in the UI. How do I get to work like the slider switch?

So if I press the button, sets the payload to true. Press again, set payload to false.

TIA.

If you are talking about the new dashboard and can wait a short while, I believe there may be plans to allow the switch node to look like a button.

Alternatively you can get the button to send eg "toggle" and use a function node to toggle a context variable between true and false.

But what's my payload going to be? Right now, I have just a payload is true when clicked

image

you could add a contrib node to get alternating output
node-red-contrib-toggle

[{"id":"1e4ee55fa6e990ee","type":"inject","z":"4cde86148e5b95f7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":228.00001907348633,"y":800.000078201294,"wires":[["c38f433ecd940c54"]]},{"id":"c38f433ecd940c54","type":"toggle","z":"4cde86148e5b95f7","name":"","onOffTopic":"","onValue":"On","onType":"str","offValue":"Off","offType":"str","toggleTopic":"","toggleValue":"","toggleType":"any","passOnOff":"ifChanged","x":353.0000190734863,"y":800.000078201294,"wires":[["24b2eb79b970f701"]]},{"id":"24b2eb79b970f701","type":"switch","z":"4cde86148e5b95f7","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"On","vt":"str"},{"t":"eq","v":"Off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":478.0000190734863,"y":800.000078201294,"wires":[["4e1c978d3e9b64d6"],["4e1c978d3e9b64d6"]]},{"id":"4e1c978d3e9b64d6","type":"debug","z":"4cde86148e5b95f7","name":"debug 2705","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":658.0000190734863,"y":800.000078201294,"wires":[]}]

toggle

or you could achieve the same in a function node as @jbudd suggested.

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