Dashboard switches only 1 out of 4 at a time

Ah yes, I hadn't worked right through the thread so missed that. To allow that they have to be fed in the far side of the switches and the topics have to be added. Do there have to be any interlocks preventing the scheduler overriding the manual switches?

[{"id":"210dd745.423ec","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"c693d07a.37b098","type":"ui_switch","z":"210dd745.423ec","name":"","label":"switch 1","tooltip":"","group":"4cd9dff5.4db82","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":[["2ec36a42.a48f16","8319ba0f.73e4c8"]]},{"id":"a45bc731.71085","type":"ui_switch","z":"210dd745.423ec","name":"","label":"switch 3","tooltip":"","group":"4cd9dff5.4db82","order":3,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"switch_3","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":500,"y":360,"wires":[["2ec36a42.a48f16","20904510.8bccda"]]},{"id":"3a81299c.c9403e","type":"ui_switch","z":"210dd745.423ec","name":"","label":"switch 2","tooltip":"","group":"4cd9dff5.4db82","order":2,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"switch_2","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":498,"y":212,"wires":[["2ec36a42.a48f16","a60f3245.f2dbd"]]},{"id":"2ec36a42.a48f16","type":"switch","z":"210dd745.423ec","name":"On?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":690,"y":260,"wires":[["e00c58d4.0c4ff"],["531f3b11.570004"]]},{"id":"e00c58d4.0c4ff","type":"link out","z":"210dd745.423ec","name":"","links":["dd88ecb6.c345e8"],"x":775,"y":240,"wires":[]},{"id":"531f3b11.570004","type":"link out","z":"210dd745.423ec","name":"","links":["2aac949.4f9c26c"],"x":775,"y":280,"wires":[]},{"id":"dd88ecb6.c345e8","type":"link in","z":"210dd745.423ec","name":"On","links":["e00c58d4.0c4ff"],"x":55,"y":200,"wires":[["978c6ae0.8124f8"]]},{"id":"2aac949.4f9c26c","type":"link in","z":"210dd745.423ec","name":"Off","links":["531f3b11.570004"],"x":95,"y":300,"wires":[["ce3cf09f.bffac"]]},{"id":"ca746160.464138","type":"comment","z":"210dd745.423ec","name":"On","info":"","x":90,"y":160,"wires":[]},{"id":"6577645d.3b0684","type":"comment","z":"210dd745.423ec","name":"Off","info":"","x":110,"y":260,"wires":[]},{"id":"ce3cf09f.bffac","type":"change","z":"210dd745.423ec","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":[["a45bc731.71085","3a81299c.c9403e","c693d07a.37b098","146d0ea7.9abda1"]]},{"id":"146d0ea7.9abda1","type":"ui_switch","z":"210dd745.423ec","name":"","label":"switch 4","tooltip":"","group":"4cd9dff5.4db82","order":3,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"switch_4","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":500,"y":442,"wires":[["2ec36a42.a48f16","9afcc3bc.3e6448"]]},{"id":"978c6ae0.8124f8","type":"function","z":"210dd745.423ec","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":[["c693d07a.37b098"],["3a81299c.c9403e"],["a45bc731.71085"],["146d0ea7.9abda1"]]},{"id":"cf3d25d1.86ec28","type":"comment","z":"210dd745.423ec","name":"On","info":"","x":750,"y":200,"wires":[]},{"id":"a61da379.74c888","type":"comment","z":"210dd745.423ec","name":"Off","info":"","x":750,"y":320,"wires":[]},{"id":"80150df7.e7c1c8","type":"inject","z":"210dd745.423ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"switch_1","payload":"true","payloadType":"bool","x":290,"y":20,"wires":[["2ec36a42.a48f16"]]},{"id":"1d34e16f.a8d64f","type":"inject","z":"210dd745.423ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"switch_3","payload":"true","payloadType":"bool","x":290,"y":360,"wires":[["2ec36a42.a48f16"]]},{"id":"6a2fcbe8.d41034","type":"inject","z":"210dd745.423ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"switch_4","payload":"true","payloadType":"bool","x":290,"y":460,"wires":[["2ec36a42.a48f16"]]},{"id":"c3863f2f.b61ce8","type":"inject","z":"210dd745.423ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"switch_1","payload":"false","payloadType":"bool","x":290,"y":60,"wires":[["2ec36a42.a48f16"]]},{"id":"e0262026.a7d2f","type":"inject","z":"210dd745.423ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"switch_3","payload":"false","payloadType":"bool","x":290,"y":400,"wires":[["2ec36a42.a48f16"]]},{"id":"857c9d97.0496b","type":"inject","z":"210dd745.423ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"switch_4","payload":"false","payloadType":"bool","x":290,"y":500,"wires":[["2ec36a42.a48f16"]]},{"id":"b7248f18.19e838","type":"inject","z":"210dd745.423ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"switch_2","payload":"true","payloadType":"bool","x":290,"y":100,"wires":[["2ec36a42.a48f16"]]},{"id":"d7b44bff.43b8b8","type":"inject","z":"210dd745.423ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"switch_2","payload":"false","payloadType":"bool","x":290,"y":140,"wires":[["2ec36a42.a48f16"]]},{"id":"8319ba0f.73e4c8","type":"debug","z":"210dd745.423ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":680,"y":60,"wires":[]},{"id":"a60f3245.f2dbd","type":"debug","z":"210dd745.423ec","name":"sw 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":120,"wires":[]},{"id":"20904510.8bccda","type":"debug","z":"210dd745.423ec","name":"sw 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":646,"y":353,"wires":[]},{"id":"9afcc3bc.3e6448","type":"debug","z":"210dd745.423ec","name":"sw 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":646,"y":453,"wires":[]},{"id":"4cd9dff5.4db82","type":"ui_group","z":"","name":"Lamp","tab":"103e0c2a.3791ac","order":1,"disp":true,"width":"6","collapse":false},{"id":"103e0c2a.3791ac","type":"ui_tab","z":"","name":"Switches","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
1 Like

that's a question for @freak23

and

  • can more than one automatic sprinkler be on at the same time?
  • should an automatic sprinkler going on turn off all the other sprinklers?

I don't think so. I will try your example later and will give you an feedback. The schedule is so or so only switching one switch at a time.

  • Only one sprinkler should be turned on at a time, no more than one!

Thank's guys for all your help and advise!

Colin, this is exactly what I was looking for! The example work's great. But in my case I use GPIO pin numbers as string payload, because I send those payloads to my Wemos D1 mini to control a relay board. Your example uses boolean payloads with true and/or false. I think I will try to adapt your great example and use the string payloads instead of the boolean ones. I guess that will be a bit tricky, but otherwise I can't use your great idea.

I don't understand what you mean by using the pin number as the payload. Surely the pin number should be in the topic and the value (0/1) in the payload.

When I turn switch1 to „ON“ my payload is a string followed by the GPIO pin number with state „0“ for the relay board to turn the relay on. I took a screenshot for better understanding:

That is not a good way to do it, I don't think. Put the identifier in the topic and the value, 1 or 0, in the payload. I think you will get continuous grief with it the way you have. Any time you need that format you just need to use
msg.topic + ":" + msg.payload
or rather neater

`${msg.topic}:${msg.payload}`

Those are backticks by the way.

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