Toggle lights with different states

Hi,

I'm looking for an easy way to know whether at least one light in a light group has the state 'on'. This is because I want to toggle multiple lights with one single button, but without using a toggle function. (because this will turn on the lights that were off and vice versa)
I spent a substantial amount of time on the forum to figure this out, but I could not really find what I'm looking for. (including is this topic: How can I toggle a group of lights (that don't go out of sync) - #15 by GoBooth)

When I try putting multiple states in a row only when the first (or the last (i'm not sure)) light is on, it turns this light off. If one of the other lights is on, it will turn on all the lights.

I also had a look into getting the state of the light group, but this was without succes.

If anyone has additional advice on my flow, this would be greatly appreciated. these are my first steps into node red and home assistant.

I use node red v1.2.9
I mainly use 'standard' nodes and this pallette: node-red-contrib-zigbee2mqtt-devices

Anyway, here's my flow.
thanks in advance! :smile:

[{"id":"ee0bd82f.20f068","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"ef596bbe.4c2418","type":"send-messages","z":"ee0bd82f.20f068","name":"","bridge":"992797f5.ab0668","x":1820,"y":440,"wires":[]},{"id":"6e73a3bb.46b10c","type":"ikea-remote","z":"ee0bd82f.20f068","name":"sensor.knop_slaapkamer","bridge":"992797f5.ab0668","deviceName":"knop_slaapkamer","x":210,"y":280,"wires":[["f76c3492.eb0fb8"],["3edfed02.eec332"],["4240fa6e.b6c414"],["45c49905.449268"],["18170761.075969"]]},{"id":"3edfed02.eec332","type":"override-action","z":"ee0bd82f.20f068","name":"brightness step up","value":50,"mode":"brightness_step","x":250,"y":420,"wires":[["32727b16.0f0894"]]},{"id":"4240fa6e.b6c414","type":"override-action","z":"ee0bd82f.20f068","name":"brightness step down","value":"-50","mode":"brightness_step","x":240,"y":480,"wires":[["32727b16.0f0894"]]},{"id":"c6c22115.3306b","type":"scene-in","z":"ee0bd82f.20f068","name":"br_test1","scene":"br_test1","active":true,"x":220,"y":640,"wires":[["21510058.41b45"]]},{"id":"39210b36.1b8144","type":"scene-selector","z":"ee0bd82f.20f068","name":"scene switch","scenes":["br_test1","br_test2","br_test3"],"wrapAround":true,"changedOutputOnly":false,"x":770,"y":100,"wires":[]},{"id":"393247f7.54b428","type":"scene-in","z":"ee0bd82f.20f068","name":"br_test2","scene":"br_test2","active":true,"x":220,"y":680,"wires":[["8302b941.3fecc8"]]},{"id":"45c49905.449268","type":"change","z":"ee0bd82f.20f068","name":"","rules":[{"t":"set","p":"command","pt":"msg","to":"next","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":140,"wires":[["39210b36.1b8144"]]},{"id":"2adcac49.d1cc04","type":"inject","z":"ee0bd82f.20f068","name":"","props":[{"p":"command","v":"next","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":520,"y":100,"wires":[["39210b36.1b8144"]]},{"id":"192d3e.eb8dc2c2","type":"scene-in","z":"ee0bd82f.20f068","name":"br_test3","scene":"br_test3","active":true,"x":220,"y":720,"wires":[["4ea723de.58cd3c"]]},{"id":"21510058.41b45","type":"generic-lamp","z":"ee0bd82f.20f068","device":"4c60c8c4.aa5078","name":"light.slaapkamer1","state":"ON","brightness":"255","temperature":50,"red":0,"green":0,"blue":0,"transition":"0","delay":0,"x":450,"y":640,"wires":[["fd22f5ea.8cf838"]]},{"id":"2936fc1d.abe164","type":"send-messages","z":"ee0bd82f.20f068","name":"","bridge":"992797f5.ab0668","x":1100,"y":640,"wires":[]},{"id":"fd22f5ea.8cf838","type":"generic-lamp","z":"ee0bd82f.20f068","device":"f59fc00a.ef9ac","name":"light.slaapkamer2","state":"OFF","brightness":"50","temperature":50,"red":0,"green":0,"blue":0,"transition":"0","delay":0,"x":670,"y":640,"wires":[["d8114c18.324e6"]]},{"id":"d8114c18.324e6","type":"generic-lamp","z":"ee0bd82f.20f068","device":"187b62b3.c01a8d","name":"light.slaapkamer3","state":"OFF","brightness":"50","temperature":50,"red":0,"green":0,"blue":0,"transition":"0","delay":0,"x":890,"y":640,"wires":[["2936fc1d.abe164"]]},{"id":"8302b941.3fecc8","type":"generic-lamp","z":"ee0bd82f.20f068","device":"4c60c8c4.aa5078","name":"light.slaapkamer1","state":"OFF","brightness":"255","temperature":50,"red":0,"green":0,"blue":0,"transition":"0","delay":0,"x":450,"y":680,"wires":[["60863b15.719254"]]},{"id":"69edfb73.103864","type":"send-messages","z":"ee0bd82f.20f068","name":"","bridge":"992797f5.ab0668","x":1100,"y":680,"wires":[]},{"id":"60863b15.719254","type":"generic-lamp","z":"ee0bd82f.20f068","device":"f59fc00a.ef9ac","name":"light.slaapkamer2","state":"ON","brightness":"255","temperature":50,"red":0,"green":0,"blue":0,"transition":"0","delay":0,"x":670,"y":680,"wires":[["c4e2e0b.3f8752"]]},{"id":"c4e2e0b.3f8752","type":"generic-lamp","z":"ee0bd82f.20f068","device":"187b62b3.c01a8d","name":"light.slaapkamer3","state":"OFF","brightness":"50","temperature":50,"red":0,"green":0,"blue":0,"transition":"0","delay":0,"x":890,"y":680,"wires":[["69edfb73.103864"]]},{"id":"4ea723de.58cd3c","type":"generic-lamp","z":"ee0bd82f.20f068","device":"4c60c8c4.aa5078","name":"light.slaapkamer1","state":"OFF","brightness":"255","temperature":50,"red":0,"green":0,"blue":0,"transition":"0","delay":0,"x":450,"y":720,"wires":[["493861d1.72264"]]},{"id":"efc2bdd5.3982b","type":"send-messages","z":"ee0bd82f.20f068","name":"","bridge":"992797f5.ab0668","x":1100,"y":720,"wires":[]},{"id":"493861d1.72264","type":"generic-lamp","z":"ee0bd82f.20f068","device":"f59fc00a.ef9ac","name":"light.slaapkamer2","state":"OFF","brightness":"50","temperature":50,"red":0,"green":0,"blue":0,"transition":"0","delay":0,"x":670,"y":720,"wires":[["ab46d41b.cd7008"]]},{"id":"ab46d41b.cd7008","type":"generic-lamp","z":"ee0bd82f.20f068","device":"187b62b3.c01a8d","name":"light.slaapkamer3","state":"ON","brightness":"255","temperature":50,"red":0,"green":0,"blue":0,"transition":"0","delay":0,"x":890,"y":720,"wires":[["efc2bdd5.3982b"]]},{"id":"32727b16.0f0894","type":"generic-lamp","z":"ee0bd82f.20f068","device":"4c60c8c4.aa5078","name":"light.slaapkamer","state":"ON","brightness":"255","temperature":50,"red":0,"green":0,"blue":0,"transition":"0","delay":0,"x":1640,"y":440,"wires":[["ef596bbe.4c2418"]]},{"id":"18170761.075969","type":"change","z":"ee0bd82f.20f068","name":"","rules":[{"t":"set","p":"command","pt":"msg","to":"previous","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":180,"wires":[["39210b36.1b8144"]]},{"id":"f76c3492.eb0fb8","type":"get-lamp-state","z":"ee0bd82f.20f068","name":"get slaapkamerstatus1","device":"85d4c5.ad9a8b38","x":520,"y":320,"wires":[["97c6198f.6a9418"]]},{"id":"109c0319.44fccd","type":"override-state","z":"ee0bd82f.20f068","name":"off","state":"OFF","x":1430,"y":300,"wires":[["32727b16.0f0894"]]},{"id":"51714d2.81b56b4","type":"switch","z":"ee0bd82f.20f068","name":"","property":"payload.state","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1250,"y":320,"wires":[["109c0319.44fccd"],["839d2528.1f1858"]]},{"id":"839d2528.1f1858","type":"override-state","z":"ee0bd82f.20f068","name":"on","state":"ON","x":1430,"y":360,"wires":[["32727b16.0f0894"]]},{"id":"97c6198f.6a9418","type":"get-lamp-state","z":"ee0bd82f.20f068","name":"get slaapkamerstatus2","device":"f59fc00a.ef9ac","x":760,"y":320,"wires":[["e664698d.a81b58"]]},{"id":"e664698d.a81b58","type":"get-lamp-state","z":"ee0bd82f.20f068","name":"get slaapkamerstatus3","device":"187b62b3.c01a8d","x":1020,"y":320,"wires":[["51714d2.81b56b4"]]},{"id":"992797f5.ab0668","type":"zigbee2mqtt-bridge-config","name":"z2m","broker":"709e476d.b531e8","baseTopic":"zigbee2mqtt","enabledLogging":false,"allowDeviceStatusRefresh":true},{"id":"4c60c8c4.aa5078","type":"zigbee2mqtt-device-config","name":"light.slaapkamer","bridge":"992797f5.ab0668","deviceName":"slaapkamer","brightnessSupport":true,"temperatureSupport":false,"colorSupport":false,"genericMqttDevice":false,"statusTopic":"","commandTopic":"","refreshTopic":""},{"id":"f59fc00a.ef9ac","type":"zigbee2mqtt-device-config","name":"light.slaapkamer2","bridge":"992797f5.ab0668","deviceName":"slaapkamer2","brightnessSupport":true,"temperatureSupport":false,"colorSupport":false,"genericMqttDevice":false,"statusTopic":"","commandTopic":"","refreshTopic":""},{"id":"187b62b3.c01a8d","type":"zigbee2mqtt-device-config","name":"light.slaapkamer3","bridge":"992797f5.ab0668","deviceName":"slaapkamer3","brightnessSupport":true,"temperatureSupport":false,"colorSupport":false,"genericMqttDevice":false,"statusTopic":"","commandTopic":"","refreshTopic":""},{"id":"85d4c5.ad9a8b38","type":"zigbee2mqtt-device-config","name":"light.slaapkamer1","bridge":"992797f5.ab0668","deviceName":"slaapkamer1","brightnessSupport":true,"temperatureSupport":false,"colorSupport":false,"genericMqttDevice":false,"statusTopic":"","commandTopic":"","refreshTopic":""},{"id":"709e476d.b531e8","type":"mqtt-broker","name":"Zigbee2mqtt","broker":"192.168.178.29","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

You have 10 non standard nodes. I think they are HA standard nodes.
I do not use HA so can not get your flow working.

Here is an example of 3 different inputs, each pair of injects represents an input/entity. Of the 3 inputs only one has to be true to output true.
hope it helps, wish i could help more but as said do not use HA.

[{"id":"cbbcb4e0.bb2fb","type":"inject","z":"5a245aa1.510164","name":"true","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic_one","payload":"true","payloadType":"bool","x":70,"y":2020,"wires":[["3fbf2b17.bb7b94"]]},{"id":"3fbf2b17.bb7b94","type":"join","z":"5a245aa1.510164","name":"join","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":290,"y":2140,"wires":[["df2cce01.a7a3c8"]]},{"id":"df2cce01.a7a3c8","type":"change","z":"5a245aa1.510164","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"$count($keys(payload))","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"(payload.topic_one or payload.topic_two or payload.topic_three) ? true : false","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":2160,"wires":[["2d5170bc.6c0ae"]]},{"id":"eb0354e.0410ea8","type":"inject","z":"5a245aa1.510164","name":"false","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic_one","payload":"false","payloadType":"bool","x":70,"y":2060,"wires":[["3fbf2b17.bb7b94"]]},{"id":"e718b71a.a5651","type":"inject","z":"5a245aa1.510164","name":"false","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic_two","payload":"false","payloadType":"bool","x":70,"y":2180,"wires":[["3fbf2b17.bb7b94"]]},{"id":"f11b3bf3.fbd988","type":"inject","z":"5a245aa1.510164","name":"true","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic_two","payload":"true","payloadType":"bool","x":70,"y":2140,"wires":[["3fbf2b17.bb7b94"]]},{"id":"9737c419.e72398","type":"inject","z":"5a245aa1.510164","name":"false","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic_three","payload":"false","payloadType":"bool","x":70,"y":2300,"wires":[["3fbf2b17.bb7b94"]]},{"id":"a85e7f30.5f83f","type":"inject","z":"5a245aa1.510164","name":"true","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"topic_three","payload":"true","payloadType":"bool","x":70,"y":2260,"wires":[["3fbf2b17.bb7b94"]]},{"id":"d8a6b6e1.2d4648","type":"inject","z":"5a245aa1.510164","name":"reset","props":[{"p":"reset","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":330,"y":2320,"wires":[["3fbf2b17.bb7b94","2d5170bc.6c0ae"]]},{"id":"2d5170bc.6c0ae","type":"rbe","z":"5a245aa1.510164","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":530,"y":2200,"wires":[["61c50e09.5bad7"]]},{"id":"61c50e09.5bad7","type":"debug","z":"5a245aa1.510164","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":680,"y":2240,"wires":[]}]

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