Could you advise me?
I get stuck, can't to find are solution, if the variable "connection_cl" is not online, then the user has no possibility to switch "ON"/"OFF" the "ui_switch".
I made such a crutch, but I don't like it!
Maybe there are better solutions?
[{"id":"55387c15.afb574","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"3b774d47.d77032","type":"ui_switch","z":"55387c15.afb574","name":"","label":"Color lamp","tooltip":"","group":"2a370ae2.8d43d6","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"{\"state\":\"ON\"}","onvalueType":"json","onicon":"fa-lightbulb-o fa-3x","oncolor":"red","offvalue":"{\"state\":\"OFF\"}","offvalueType":"json","officon":"fa-lightbulb-o fa-3x","offcolor":"gray","x":290,"y":200,"wires":[["b7eba7fd.5188a8","72187439.3ccc0c"]]},{"id":"72187439.3ccc0c","type":"function","z":"55387c15.afb574","name":"","func":"var connection_cl = global.get('connection_cl') || \"\";\nvar flag = flow.get('flag') || \"\";\n\nvar p = {}; \np.state=msg.payload.state;\nmsg.payload=p;\n\nif ( p.state === \"ON\" && flag !=\"ON\" && connection_cl != 'OFF') { \n flow.set('flag',\"ON\");\n return [ msg, null ];\n} \nelse if ( p.state === \"OFF\" && flag !=\"OFF\" && connection_cl != 'OFF') {\n flow.set('flag',\"OFF\");\n return [ msg, null ];\n}\nelse if (p.state === \"OFF\" && flag !=\"OFF\" && connection_cl != 'ON') {\n flow.set('flag',\"OFF\");\n msg.payload={\"state\":\"OFF\"};\n return [ null, msg ];\n}\nelse if (p.state === \"ON\" && flag !=\"ON\" && connection_cl != 'ON') {\n flow.set('flag',\"OFF\");\n msg.payload={\"state\":\"OFF\"};\n return [ null, msg ];\n}\nelse {\n return[ null, null ]; \n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":460,"y":140,"wires":[[],["3b774d47.d77032"]]},{"id":"b7eba7fd.5188a8","type":"debug","z":"55387c15.afb574","name":"4444444444","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":240,"wires":[]},{"id":"d432c77.b95c938","type":"inject","z":"55387c15.afb574","name":"OFF","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"state\":\"OFF\"}","payloadType":"json","x":90,"y":220,"wires":[["3b774d47.d77032"]]},{"id":"3fb205c5.fa07da","type":"inject","z":"55387c15.afb574","name":"ON","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"state\":\"ON\"}","payloadType":"json","x":90,"y":160,"wires":[["3b774d47.d77032"]]},{"id":"2a370ae2.8d43d6","type":"ui_group","z":"","name":"Reboot","tab":"852f6d3.66c129","order":1,"disp":true,"width":"6","collapse":false},{"id":"852f6d3.66c129","type":"ui_tab","z":"","name":"SERVICE","icon":"fa-cog fa-2x","order":5,"disabled":false,"hidden":false}]