In the same button come on a lock/unlock

hi every one , my question is how i can creat a push button that combine two differents states (when i push it ,the icon UNLOCK come on ,and the LOCK come on when i push the second time ) in the normal case the button is locked ,i tried to do that by making a function node which the input for it ,the payload coming from the output of the button when i click on it ,a msg sent to it ,and in this function i made some conditions ,i tried to make a static counter in this function however anything happen ,(the icon and the payload intented is working well )

note: outputBUtton is linked to the input function and vise-versa

Hello @amine1.

Are you talking about a Node-red dashboard button?

[{"id":"1feefcdebb5a9145","type":"ui_button","z":"728eca0c6ed52fad","name":"","group":"a6e358b.672ffa8","order":0,"width":"2","height":"1","passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","className":"","icon":"{{myicon}}","payload":"toggle","payloadType":"str","topic":"topic","topicType":"msg","x":490,"y":360,"wires":[["3f437fac800bf596","7aa5d8ce5322d823"]]},{"id":"6a54132a78a841b8","type":"change","z":"728eca0c6ed52fad","name":"","rules":[{"t":"set","p":"myicon","pt":"msg","to":"alarm_off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":460,"wires":[["6de3da3af6d617fa"]]},{"id":"4e69efe4e7b72cb5","type":"change","z":"728eca0c6ed52fad","name":"","rules":[{"t":"set","p":"myicon","pt":"msg","to":"alarm_on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":420,"wires":[["6de3da3af6d617fa"]]},{"id":"3f437fac800bf596","type":"switch","z":"728eca0c6ed52fad","name":"flow.icon?","property":"icon","propertyType":"flow","rules":[{"t":"eq","v":"alarm_off","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":300,"y":440,"wires":[["4e69efe4e7b72cb5"],["6a54132a78a841b8"]]},{"id":"6de3da3af6d617fa","type":"change","z":"728eca0c6ed52fad","name":"","rules":[{"t":"set","p":"icon","pt":"flow","to":"myicon","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":440,"wires":[["1feefcdebb5a9145"]]},{"id":"7aa5d8ce5322d823","type":"link out","z":"728eca0c6ed52fad","name":"Use the button press","mode":"link","links":[],"x":700,"y":360,"wires":[],"l":true},{"id":"a6e358b.672ffa8","type":"ui_group","name":"Demo","tab":"4e528085.a1bfa","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"4e528085.a1bfa","type":"ui_tab","name":"Demo","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Nope, you totally lost me there.

yeah exactly what i want thank you so much

Here's a link to a tutorial I wrote for my IoT students.
It shows how to create buttons with different actions.
e.g. On and Off, toggle, reset, etc..

Hope you find it useful.

http://resources-area.co.uk/node-red-flows/having_fun_with_buttons.pdf

2 Likes

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