Dashboard switches only 1 out of 4 at a time

Hi friends,

I‘m facing a problem with the programming of a function within the dashboard switches and can’t figure it out. So I‘ve created my own sprinkler system with some switches on the dashboard to turn the valves on. Now I‘m trying to get a function, that allows me to switch only 1 out of 4 switches at the same time. The other 3 switches shouldn’t be selectable when one is active. So that only one valve at a time can be activated.
Here is my actual flow and dashboard:


You will need to paste the code for the flow so we can help

Also for clarity - do you want to disable the other switches - or if someone selects one that is not on - then turn off the current one and enable the new selection ?

Craig

Thank you for your answer. If it would be possible to disable the other inactive switches when one is active, that‘s what I’m looking for.
Here is the flow code:

[{"id":"38809b3a.58cd9c","type":"tab","label":"Sprinkleranlage","disabled":false,"info":""},{"id":"5554b91.e47c5c8","type":"ui_switch","z":"38809b3a.58cd9c","name":"Sprinkler 1","label":"","tooltip":"","group":"7ac10d8b.33990c","order":1,"width":7,"height":1,"passthru":true,"decouple":"false","topic":"Garten","style":"","onvalue":"12:0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"12:1","offvalueType":"str","officon":"","offcolor":"","x":330,"y":40,"wires":[["5e8f7886.8206d"]]},{"id":"5f4e6a96.1c10ec","type":"ui_switch","z":"38809b3a.58cd9c","name":"Sprinkler 2","label":"","tooltip":"","group":"4b24a0ab.2348d","order":1,"width":7,"height":1,"passthru":true,"decouple":"false","topic":"Garten","style":"","onvalue":"13:0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"13:1","offvalueType":"str","officon":"","offcolor":"","x":330,"y":100,"wires":[["5e8f7886.8206d"]]},{"id":"5e8f7886.8206d","type":"tcp out","z":"38809b3a.58cd9c","host":"192.168.178.71","port":"8088","beserver":"client","base64":false,"end":false,"name":"","x":590,"y":140,"wires":[]},{"id":"a6326390.e165","type":"light-scheduler","z":"38809b3a.58cd9c","d":true,"settings":"5fcb38a8.34f038","events":"[]","topic":"Garten","name":"Sprinkler 1","onPayload":"12:0","onPayloadType":"str","offPayload":"12:1","offPayloadType":"str","onlyWhenDark":false,"scheduleRndMax":0,"sunElevationThreshold":"0","sunShowElevationInStatus":true,"outputfreq":"output.statechange","x":70,"y":40,"wires":[["5554b91.e47c5c8"]]},{"id":"aa71c273.c00f68","type":"light-scheduler","z":"38809b3a.58cd9c","d":true,"settings":"5fcb38a8.34f038","events":"[]","topic":"Garten","name":"Sprinkler 2","onPayload":"13:0","onPayloadType":"str","offPayload":"13:1","offPayloadType":"str","onlyWhenDark":false,"scheduleRndMax":0,"sunElevationThreshold":"0","sunShowElevationInStatus":true,"outputfreq":"output.statechange","x":70,"y":100,"wires":[["5f4e6a96.1c10ec"]]},{"id":"993693d0.cdb788","type":"ui_text","z":"38809b3a.58cd9c","group":"a5e3e502.b04a","order":1,"width":0,"height":0,"name":"LED","label":"","format":"<font color={{msg.color}}><i class=\"fa fa-circle\" style=\"font-size:24px;\"></i></font>","layout":"col-center","x":530,"y":280,"wires":[]},{"id":"18c13633.cae062","type":"function","z":"38809b3a.58cd9c","name":"Ventile online","func":"msg.color = (msg.payload == false)?\"red\":\"lime\";\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":280,"wires":[["993693d0.cdb788"]]},{"id":"d1ccf698.e60a28","type":"debug","z":"38809b3a.58cd9c","name":"Debug msg","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":330,"y":340,"wires":[]},{"id":"6ea4662b.5be26","type":"ping","z":"38809b3a.58cd9c","mode":"timed","name":"Netzwerk Ping Ventile","host":"192.168.178.71","timer":"20","inputs":0,"x":100,"y":280,"wires":[["d1ccf698.e60a28","18c13633.cae062"]]},{"id":"5d2213d0.5d550c","type":"ui_switch","z":"38809b3a.58cd9c","d":true,"name":"Sprinkler 3","label":"","tooltip":"","group":"d55c8b42.e1c6c","order":1,"width":7,"height":1,"passthru":true,"decouple":"false","topic":"Garten","style":"","onvalue":"14:0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"14:1","offvalueType":"str","officon":"","offcolor":"","x":330,"y":160,"wires":[["5e8f7886.8206d"]]},{"id":"c03b3eb7.d5f978","type":"ui_switch","z":"38809b3a.58cd9c","d":true,"name":"Sprinkler 4","label":"","tooltip":"","group":"922dd3.fadfda3","order":1,"width":7,"height":1,"passthru":true,"decouple":"false","topic":"Garten","style":"","onvalue":"15:0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"15:1","offvalueType":"str","officon":"","offcolor":"","x":330,"y":220,"wires":[["5e8f7886.8206d"]]},{"id":"12876681.bb66f1","type":"light-scheduler","z":"38809b3a.58cd9c","d":true,"settings":"5fcb38a8.34f038","events":"[]","topic":"Garten","name":"Sprinkler 3","onPayload":"14:0","onPayloadType":"str","offPayload":"14:1","offPayloadType":"str","onlyWhenDark":false,"scheduleRndMax":0,"sunElevationThreshold":"0","sunShowElevationInStatus":true,"outputfreq":"output.statechange","x":70,"y":160,"wires":[["5d2213d0.5d550c"]]},{"id":"fe5a0a42.7a8b68","type":"light-scheduler","z":"38809b3a.58cd9c","d":true,"settings":"5fcb38a8.34f038","events":"[]","topic":"Garten","name":"Sprinkler 4","onPayload":"15:0","onPayloadType":"str","offPayload":"15:1","offPayloadType":"str","onlyWhenDark":false,"scheduleRndMax":0,"sunElevationThreshold":"0","sunShowElevationInStatus":true,"outputfreq":"output.statechange","x":70,"y":220,"wires":[["c03b3eb7.d5f978"]]},{"id":"7ac10d8b.33990c","type":"ui_group","z":"","name":"Sprinkleranlage 1","tab":"c37530d3.f88968","order":2,"disp":true,"width":"7","collapse":false},{"id":"4b24a0ab.2348d","type":"ui_group","z":"","name":"Sprinkleranlage 2","tab":"c37530d3.f88968","order":3,"disp":true,"width":"7","collapse":false},{"id":"5fcb38a8.34f038","type":"light-scheduler-settings","z":"","name":"my settings","latitude":"53.5237498","longitude":"9.3979698"},{"id":"a5e3e502.b04a","type":"ui_group","z":"","name":"Online Status Sprinklerventile","tab":"c37530d3.f88968","order":1,"disp":true,"width":7,"collapse":false},{"id":"d55c8b42.e1c6c","type":"ui_group","z":"","name":"Sprinkleranlage 3","tab":"c37530d3.f88968","order":4,"disp":true,"width":7,"collapse":false},{"id":"922dd3.fadfda3","type":"ui_group","z":"","name":"Sprinkleranlage 4","tab":"c37530d3.f88968","order":5,"disp":true,"width":7,"collapse":false},{"id":"c37530d3.f88968","type":"ui_tab","z":"","name":"Bewässerung","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Nope something wrong with that - i can not import it.

Also when you paste put ``` before and after the code so the system treats it as a code block please

Craig

I used the forum function </> Hopefully this time the code is useable for u

Here without the forum function </>

[{"id":"38809b3a.58cd9c","type":"tab","label":"Sprinkleranlage","disabled":false,"info":""},{"id":"5554b91.e47c5c8","type":"ui_switch","z":"38809b3a.58cd9c","name":"Sprinkler 1","label":"","tooltip":"","group":"7ac10d8b.33990c","order":1,"width":7,"height":1,"passthru":true,"decouple":"false","topic":"Garten","style":"","onvalue":"12:0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"12:1","offvalueType":"str","officon":"","offcolor":"","x":330,"y":40,"wires":[["5e8f7886.8206d"]]},{"id":"5f4e6a96.1c10ec","type":"ui_switch","z":"38809b3a.58cd9c","name":"Sprinkler 2","label":"","tooltip":"","group":"4b24a0ab.2348d","order":1,"width":7,"height":1,"passthru":true,"decouple":"false","topic":"Garten","style":"","onvalue":"13:0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"13:1","offvalueType":"str","officon":"","offcolor":"","x":330,"y":100,"wires":[["5e8f7886.8206d"]]},{"id":"5e8f7886.8206d","type":"tcp out","z":"38809b3a.58cd9c","host":"192.168.178.71","port":"8088","beserver":"client","base64":false,"end":false,"name":"","x":590,"y":140,"wires":[]},{"id":"a6326390.e165","type":"light-scheduler","z":"38809b3a.58cd9c","d":true,"settings":"5fcb38a8.34f038","events":"[]","topic":"Garten","name":"Sprinkler 1","onPayload":"12:0","onPayloadType":"str","offPayload":"12:1","offPayloadType":"str","onlyWhenDark":false,"scheduleRndMax":0,"sunElevationThreshold":"0","sunShowElevationInStatus":true,"outputfreq":"output.statechange","x":70,"y":40,"wires":[["5554b91.e47c5c8"]]},{"id":"aa71c273.c00f68","type":"light-scheduler","z":"38809b3a.58cd9c","d":true,"settings":"5fcb38a8.34f038","events":"[]","topic":"Garten","name":"Sprinkler 2","onPayload":"13:0","onPayloadType":"str","offPayload":"13:1","offPayloadType":"str","onlyWhenDark":false,"scheduleRndMax":0,"sunElevationThreshold":"0","sunShowElevationInStatus":true,"outputfreq":"output.statechange","x":70,"y":100,"wires":[["5f4e6a96.1c10ec"]]},{"id":"993693d0.cdb788","type":"ui_text","z":"38809b3a.58cd9c","group":"a5e3e502.b04a","order":1,"width":0,"height":0,"name":"LED","label":"","format":"<font color={{msg.color}}><i class=\"fa fa-circle\" style=\"font-size:24px;\"></i></font>","layout":"col-center","x":530,"y":280,"wires":[]},{"id":"18c13633.cae062","type":"function","z":"38809b3a.58cd9c","name":"Ventile online","func":"msg.color = (msg.payload == false)?\"red\":\"lime\";\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":280,"wires":[["993693d0.cdb788"]]},{"id":"d1ccf698.e60a28","type":"debug","z":"38809b3a.58cd9c","name":"Debug msg","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":330,"y":340,"wires":[]},{"id":"6ea4662b.5be26","type":"ping","z":"38809b3a.58cd9c","mode":"timed","name":"Netzwerk Ping Ventile","host":"192.168.178.71","timer":"20","inputs":0,"x":100,"y":280,"wires":[["d1ccf698.e60a28","18c13633.cae062"]]},{"id":"5d2213d0.5d550c","type":"ui_switch","z":"38809b3a.58cd9c","d":true,"name":"Sprinkler 3","label":"","tooltip":"","group":"d55c8b42.e1c6c","order":1,"width":7,"height":1,"passthru":true,"decouple":"false","topic":"Garten","style":"","onvalue":"14:0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"14:1","offvalueType":"str","officon":"","offcolor":"","x":330,"y":160,"wires":[["5e8f7886.8206d"]]},{"id":"c03b3eb7.d5f978","type":"ui_switch","z":"38809b3a.58cd9c","d":true,"name":"Sprinkler 4","label":"","tooltip":"","group":"922dd3.fadfda3","order":1,"width":7,"height":1,"passthru":true,"decouple":"false","topic":"Garten","style":"","onvalue":"15:0","onvalueType":"str","onicon":"","oncolor":"","offvalue":"15:1","offvalueType":"str","officon":"","offcolor":"","x":330,"y":220,"wires":[["5e8f7886.8206d"]]},{"id":"12876681.bb66f1","type":"light-scheduler","z":"38809b3a.58cd9c","d":true,"settings":"5fcb38a8.34f038","events":"[]","topic":"Garten","name":"Sprinkler 3","onPayload":"14:0","onPayloadType":"str","offPayload":"14:1","offPayloadType":"str","onlyWhenDark":false,"scheduleRndMax":0,"sunElevationThreshold":"0","sunShowElevationInStatus":true,"outputfreq":"output.statechange","x":70,"y":160,"wires":[["5d2213d0.5d550c"]]},{"id":"fe5a0a42.7a8b68","type":"light-scheduler","z":"38809b3a.58cd9c","d":true,"settings":"5fcb38a8.34f038","events":"[]","topic":"Garten","name":"Sprinkler 4","onPayload":"15:0","onPayloadType":"str","offPayload":"15:1","offPayloadType":"str","onlyWhenDark":false,"scheduleRndMax":0,"sunElevationThreshold":"0","sunShowElevationInStatus":true,"outputfreq":"output.statechange","x":70,"y":220,"wires":[["c03b3eb7.d5f978"]]},{"id":"7ac10d8b.33990c","type":"ui_group","z":"","name":"Sprinkleranlage 1","tab":"c37530d3.f88968","order":2,"disp":true,"width":"7","collapse":false},{"id":"4b24a0ab.2348d","type":"ui_group","z":"","name":"Sprinkleranlage 2","tab":"c37530d3.f88968","order":3,"disp":true,"width":"7","collapse":false},{"id":"5fcb38a8.34f038","type":"light-scheduler-settings","z":"","name":"my settings","latitude":"53.5237498","longitude":"9.3979698"},{"id":"a5e3e502.b04a","type":"ui_group","z":"","name":"Online Status Sprinklerventile","tab":"c37530d3.f88968","order":1,"disp":true,"width":7,"collapse":false},{"id":"d55c8b42.e1c6c","type":"ui_group","z":"","name":"Sprinkleranlage 3","tab":"c37530d3.f88968","order":4,"disp":true,"width":7,"collapse":false},{"id":"922dd3.fadfda3","type":"ui_group","z":"","name":"Sprinkleranlage 4","tab":"c37530d3.f88968","order":5,"disp":true,"width":7,"collapse":false},{"id":"c37530d3.f88968","type":"ui_tab","z":"","name":"Bewässerung","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

no you have some weird characters in there that are showing up as square boxes in the export.

Craig

I've just edited your post so the flow can be imported

If you want to use the </> select your code then click that button

Also, when you paste a flow, let people know what 'extra' nodes you have installed. If your case you have node-red-contrib-light-scheduler which someone else will have to install to look at your flow.

Thank you for your help zenofmud! Yes, u are right, I use the node-red-contrib-light-scheduler and the dashboard of corse to have the sprinkler turn on automatically.

NOTE: in your switches, (s1 for example) you have the 'On' payload as '12:0' and the 'Off' as '12:1'. A one (1) normally represents ON (true) while zero (0) represents OFF (false)

If I understand you correctly you:

  • if s1 is turned on, turn s2, s3 and s4 are disabled
  • if s2 is turned on, turn s1, s3 and s4 are disabled
  • if s3 is turned on, turn s1, s2 and s4 are disabled
  • if s4 is turned on, turn s1, s2 and s3 are disabled
    how will those switches become enabled?

you can send a msg to a switch node with msg.enabled set to boolean false and it will disable the switch

be warned, this can get tricky because if you pass thru any incoming message to the switch node, then turning on s1 will send a disable to s2 which will disable the switch on the dashboard but still cause the node s2 to output a msg which will cause s1 to be disabled which will output a msg causing s2 to be disabled and you get in a tight loop and have to stop NR.

That‘s because the connected relay board ist inverted. Means on digitalWrite“high“ the relay is not active and on digitalWrite“low“ the relay board is active.

Exactly, when I turn one switch at the dashboard to „ON“, the other switches shouldn’t be selectable anymore until the active „ON“ switch is turned back to „OFF“

I would use the Editor Switch node straight after your Dashboard switch node and then the change node to send the disable messages to each of the other dashboard switches,

Something like this

[{"id":"aa4a6733.5abe78","type":"ui_switch","z":"6b000f73.b47a6","name":"Test Dash switch 1","label":"switch","tooltip":"","group":"600bfa6b.a6d0f4","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":250,"y":620,"wires":[["f22249e3.4bacc8"]]},{"id":"dd2abea2.7a9a8","type":"change","z":"6b000f73.b47a6","name":"Disable other switches","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":620,"wires":[["894541cb.2e2de","195f0104.7a94af","8ab99835.bc6848"]]},{"id":"f22249e3.4bacc8","type":"switch","z":"6b000f73.b47a6","name":"DIsabel or enable SW2, SW3, SW4","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"},{"t":"eq","v":"false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":520,"y":620,"wires":[["dd2abea2.7a9a8"],["689d8921.a09018"]]},{"id":"689d8921.a09018","type":"change","z":"6b000f73.b47a6","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":660,"wires":[["894541cb.2e2de","195f0104.7a94af","8ab99835.bc6848"]]},{"id":"894541cb.2e2de","type":"ui_switch","z":"6b000f73.b47a6","name":"","label":"switch","tooltip":"","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":true,"onvalueType":"bool","onicon":"","oncolor":"","offvalue":false,"offvalueType":"bool","officon":"","offcolor":"","x":1130,"y":600,"wires":[[]]},{"id":"195f0104.7a94af","type":"ui_switch","z":"6b000f73.b47a6","name":"","label":"switch","tooltip":"","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":true,"onvalueType":"bool","onicon":"","oncolor":"","offvalue":false,"offvalueType":"bool","officon":"","offcolor":"","x":1130,"y":640,"wires":[[]]},{"id":"8ab99835.bc6848","type":"ui_switch","z":"6b000f73.b47a6","name":"","label":"switch","tooltip":"","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":true,"onvalueType":"bool","onicon":"","oncolor":"","offvalue":false,"offvalueType":"bool","officon":"","offcolor":"","x":1130,"y":680,"wires":[[]]},{"id":"600bfa6b.a6d0f4","type":"ui_group","z":"","name":"Lamp","tab":"594e8662.c1e098","order":1,"disp":true,"width":"6","collapse":false},{"id":"594e8662.c1e098","type":"ui_tab","z":"","name":"Switches","icon":"dashboard","order":1,"disabled":false,"hidden":false}]  

But the number of wires you are going to have going around between all of these is going to make it very messy very quickly

Craig

How about this for a concept, you may have to tweak it for your particular on/off values.

[{"id":"a6b8d811.283ac8","type":"ui_switch","z":"bdd7be38.d3b55","name":"","label":"switch 1","tooltip":"","group":"bef6a5e.c1dbcd8","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"switch_1","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":483,"y":743,"wires":[["257e1993.9f0ba6"]]},{"id":"978f7768.6ecd18","type":"ui_switch","z":"bdd7be38.d3b55","name":"","label":"switch 3","tooltip":"","group":"bef6a5e.c1dbcd8","order":3,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"switch_3","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":483,"y":923,"wires":[["257e1993.9f0ba6"]]},{"id":"e650dda1.3a7d7","type":"ui_switch","z":"bdd7be38.d3b55","name":"","label":"switch 2","tooltip":"","group":"bef6a5e.c1dbcd8","order":2,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"switch_2","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":481,"y":835,"wires":[["257e1993.9f0ba6"]]},{"id":"257e1993.9f0ba6","type":"switch","z":"bdd7be38.d3b55","name":"On?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":624,"y":831,"wires":[["930d9a9b.cb9d9"],["a1aeb375.a6c828"]]},{"id":"930d9a9b.cb9d9","type":"link out","z":"bdd7be38.d3b55","name":"","links":["279b3ad8.f29b36"],"x":744,"y":825,"wires":[]},{"id":"a1aeb375.a6c828","type":"link out","z":"bdd7be38.d3b55","name":"","links":["abdd87d.c2e7d78"],"x":742,"y":910,"wires":[]},{"id":"279b3ad8.f29b36","type":"link in","z":"bdd7be38.d3b55","name":"On","links":["930d9a9b.cb9d9"],"x":41,"y":761,"wires":[["740e9872.dde1d8"]]},{"id":"abdd87d.c2e7d78","type":"link in","z":"bdd7be38.d3b55","name":"Off","links":["a1aeb375.a6c828"],"x":52,"y":990,"wires":[["dca1f57f.25d3e"]]},{"id":"2bb255d6.bd5112","type":"comment","z":"bdd7be38.d3b55","name":"On","info":"","x":72,"y":725,"wires":[]},{"id":"dedebe21.3f2f18","type":"comment","z":"bdd7be38.d3b55","name":"Off","info":"","x":85,"y":955,"wires":[]},{"id":"dca1f57f.25d3e","type":"change","z":"bdd7be38.d3b55","name":"Enable all","rules":[{"t":"set","p":"enabled","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":161,"y":990,"wires":[["978f7768.6ecd18","e650dda1.3a7d7","a6b8d811.283ac8","d446ca91.8afa88"]]},{"id":"d446ca91.8afa88","type":"ui_switch","z":"bdd7be38.d3b55","name":"","label":"switch 4","tooltip":"","group":"bef6a5e.c1dbcd8","order":3,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"switch_4","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":483,"y":1005,"wires":[["257e1993.9f0ba6"]]},{"id":"740e9872.dde1d8","type":"function","z":"bdd7be38.d3b55","name":"Enable/Disable","func":"const disabledMsg = {payload: false, enabled: false}\nlet msgs\nswitch(msg.topic) {\n  case \"switch_1\":\n    msgs = [msg, disabledMsg, disabledMsg, disabledMsg]\n    break;\n  case \"switch_2\":\n    msgs = [disabledMsg, msg, disabledMsg, disabledMsg]\n    break;\n  case \"switch_3\":\n    msgs = [disabledMsg, disabledMsg, msg, disabledMsg]\n    break;\n  default:\n    msgs = [disabledMsg, disabledMsg, disabledMsg, msg]\n} \nreturn msgs;","outputs":4,"noerr":0,"initialize":"","finalize":"","x":150,"y":827,"wires":[["a6b8d811.283ac8"],["e650dda1.3a7d7"],["978f7768.6ecd18"],["d446ca91.8afa88"]]},{"id":"362ab9da.37e786","type":"comment","z":"bdd7be38.d3b55","name":"On","info":"","x":722,"y":788,"wires":[]},{"id":"e4d9e4d7.0d16e","type":"comment","z":"bdd7be38.d3b55","name":"Off","info":"","x":723,"y":948,"wires":[]},{"id":"bef6a5e.c1dbcd8","type":"ui_group","z":"","name":"Lamp","tab":"e0ca01b7.c8d428","order":1,"disp":true,"width":"6","collapse":false},{"id":"e0ca01b7.c8d428","type":"ui_tab","z":"","name":"Switches","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

@craigcurtin Craig, the problem is that - a I understand it - each switch needs to control ALL the other switches which can cause a feedback loop. if you try it (I did) you may/will to stop/start NR to get out of it (and you may have to start NR in safe mode node-red --safe)

Thank you craig for your example and zenofmud thanks to try it and figure out, that something is wrong with it. I‘ll skip to try it :wink:

Colin, thank you as well, I will try your example.

In fact the function node can be simplified to

// note this relies on the topics being of the form string_digit
const disabledMsg = {payload: false, enabled: false}
let msgs = [disabledMsg, disabledMsg, disabledMsg, disabledMsg]

const switchNum = Number(msg.topic.split("_")[1])
msgs[switchNum - 1] = msg

return msgs;

The trick is to disable passthrough and set the switch to show the state of the input rather than the output. Then to make the switch change when you click it the value has to be fed back round to the input, which is handled by the function node in my example. The function node also disables the other switches. When any switch is switched off then all of the switches can be set off and enabled which is done by the lower path in my suggestion.

@Colin - the issue I see with your idea (I like the idea) is that he also has 'light scheduler' nodes feeding the switches. If you set 'Switch icon shows state of input' and one of them triggers, the dashboard won't show the switch is on/off.

Here is your example with added injects. NOTE: if you check off ' Pass though msg if payload matches new state:' in any of the switches, it will put you into a loop.

[{"id":"67832e1e.8f684","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"67d2fbf9.ea6fe4","type":"ui_switch","z":"67832e1e.8f684","name":"","label":"switch 1","tooltip":"","group":"5a634559.789cbc","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"switch_1","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":500,"y":120,"wires":[["5f0e0553.1a4fa4","6a639ceb.6cef9c"]]},{"id":"ec4c9328.ccda1","type":"ui_switch","z":"67832e1e.8f684","name":"","label":"switch 3","tooltip":"","group":"5a634559.789cbc","order":3,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"switch_3","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":500,"y":360,"wires":[["5f0e0553.1a4fa4","6103c33d.e1852c"]]},{"id":"884c9d7d.ae9","type":"ui_switch","z":"67832e1e.8f684","name":"","label":"switch 2","tooltip":"","group":"5a634559.789cbc","order":2,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"switch_2","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":498,"y":212,"wires":[["5f0e0553.1a4fa4","815d9181.8e61d8"]]},{"id":"5f0e0553.1a4fa4","type":"switch","z":"67832e1e.8f684","name":"On?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":690,"y":260,"wires":[["ab744ebc.47b808"],["524bc6ca.215ac"]]},{"id":"ab744ebc.47b808","type":"link out","z":"67832e1e.8f684","name":"","links":["7fc5286b.a0f5a"],"x":775,"y":240,"wires":[]},{"id":"524bc6ca.215ac","type":"link out","z":"67832e1e.8f684","name":"","links":["9463d364.fda3e"],"x":775,"y":280,"wires":[]},{"id":"7fc5286b.a0f5a","type":"link in","z":"67832e1e.8f684","name":"On","links":["ab744ebc.47b808"],"x":55,"y":200,"wires":[["c827781c.c21e4"]]},{"id":"9463d364.fda3e","type":"link in","z":"67832e1e.8f684","name":"Off","links":["524bc6ca.215ac"],"x":95,"y":300,"wires":[["3e17ccc.ab9d4b4"]]},{"id":"22d75234.72ecfe","type":"comment","z":"67832e1e.8f684","name":"On","info":"","x":90,"y":160,"wires":[]},{"id":"fc0a3261.270c68","type":"comment","z":"67832e1e.8f684","name":"Off","info":"","x":110,"y":260,"wires":[]},{"id":"3e17ccc.ab9d4b4","type":"change","z":"67832e1e.8f684","name":"Enable all","rules":[{"t":"set","p":"enabled","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":300,"wires":[["ec4c9328.ccda1","884c9d7d.ae9","67d2fbf9.ea6fe4","3899a1a9.f8e62e"]]},{"id":"3899a1a9.f8e62e","type":"ui_switch","z":"67832e1e.8f684","name":"","label":"switch 4","tooltip":"","group":"5a634559.789cbc","order":3,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"switch_4","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":500,"y":442,"wires":[["5f0e0553.1a4fa4","20540c63.6a8134"]]},{"id":"c827781c.c21e4","type":"function","z":"67832e1e.8f684","name":"Enable/Disable","func":"const disabledMsg = {payload: false, enabled: false}\nlet msgs\nswitch(msg.topic) {\n  case \"switch_1\":\n    msgs = [msg, disabledMsg, disabledMsg, disabledMsg]\n    break;\n  case \"switch_2\":\n    msgs = [disabledMsg, msg, disabledMsg, disabledMsg]\n    break;\n  case \"switch_3\":\n    msgs = [disabledMsg, disabledMsg, msg, disabledMsg]\n    break;\n  default:\n    msgs = [disabledMsg, disabledMsg, disabledMsg, msg]\n} \nreturn msgs;","outputs":4,"noerr":0,"x":240,"y":200,"wires":[["67d2fbf9.ea6fe4"],["884c9d7d.ae9"],["ec4c9328.ccda1"],["3899a1a9.f8e62e"]]},{"id":"4a93d159.8d4fd8","type":"comment","z":"67832e1e.8f684","name":"On","info":"","x":750,"y":200,"wires":[]},{"id":"6fc8573d.8844f","type":"comment","z":"67832e1e.8f684","name":"Off","info":"","x":750,"y":320,"wires":[]},{"id":"c98aed4d.f5df88","type":"inject","z":"67832e1e.8f684","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":20,"wires":[["67d2fbf9.ea6fe4"]]},{"id":"2fb3d872.76557","type":"inject","z":"67832e1e.8f684","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":360,"wires":[["ec4c9328.ccda1"]]},{"id":"498ec6d.096d0b8","type":"inject","z":"67832e1e.8f684","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":460,"wires":[["3899a1a9.f8e62e"]]},{"id":"ffccb1cb.f520f","type":"inject","z":"67832e1e.8f684","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":60,"wires":[["67d2fbf9.ea6fe4"]]},{"id":"f5613a40.c82918","type":"inject","z":"67832e1e.8f684","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":400,"wires":[["ec4c9328.ccda1"]]},{"id":"c9fe15b1.b49ab","type":"inject","z":"67832e1e.8f684","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":500,"wires":[["3899a1a9.f8e62e"]]},{"id":"9abd4e8e.5ffd2","type":"inject","z":"67832e1e.8f684","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":100,"wires":[["884c9d7d.ae9"]]},{"id":"9dc86c96.22d9b","type":"inject","z":"67832e1e.8f684","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":140,"wires":[["884c9d7d.ae9"]]},{"id":"6a639ceb.6cef9c","type":"debug","z":"67832e1e.8f684","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":680,"y":60,"wires":[]},{"id":"815d9181.8e61d8","type":"debug","z":"67832e1e.8f684","name":"sw 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":120,"wires":[]},{"id":"6103c33d.e1852c","type":"debug","z":"67832e1e.8f684","name":"sw 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":646,"y":353,"wires":[]},{"id":"20540c63.6a8134","type":"debug","z":"67832e1e.8f684","name":"sw 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":646,"y":453,"wires":[]},{"id":"5a634559.789cbc","type":"ui_group","z":"","name":"Lamp","tab":"4755c9d7.d61628","order":1,"disp":true,"width":"6","collapse":false},{"id":"4755c9d7.d61628","type":"ui_tab","z":"","name":"Switches","icon":"dashboard","order":1,"disabled":false,"hidden":false}]