Enable/disable button via switch

I want enable/disable a button with switch, but not working for me. What is wrong ? :

[{"id":"fb381298223f4873","type":"ui_button","z":"59fb2f9263e14661","name":"","group":"8c11279992e11f1f","order":7,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"{{background}}","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":560,"y":1200,"wires":[[]]},{"id":"e1130c8f9458f535","type":"ui_switch","z":"59fb2f9263e14661","name":"","label":"switch","tooltip":"","group":"8c11279992e11f1f","order":8,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"background","topicType":"msg","style":"","onvalue":"transparent","onvalueType":"str","onicon":"","oncolor":"","offvalue":"red","offvalueType":"str","officon":"","offcolor":"","animate":false,"className":"","x":370,"y":1200,"wires":[["fb381298223f4873","49f2d117ee53df6e"]]},{"id":"49f2d117ee53df6e","type":"debug","z":"59fb2f9263e14661","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":1260,"wires":[]},{"id":"8c11279992e11f1f","type":"ui_group","name":"OPERATIVNÍ ZMĚNY","tab":"befeb13c.bfa17","order":1,"disp":true,"width":8,"collapse":false,"className":""},{"id":"befeb13c.bfa17","type":"ui_tab","name":"TOPENÍ ETATHERM","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Your switch sends msg.payload "red" or "transparent".
Your button gets it's background colour from msg.background.

Either change the button to get it's background colour from msg.payload or use a change node to copy msg.payload into msg.background.

Note that gives you an invisible button but it's not disabled. To disable it you need to send boolean true or false as msg.enabled.
You can do that with a change node. First copy msg.payload into msg.enabled, then change "red" to true or "transparent" to false.

working thanks

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