Switching several lights at once

Is there a smart/easy way to switch several lights off ? At the moment im using Link in and Linkt out with a button on the dashboard, but I only have a few light running and if i manage to get the Tradfri into Node Red there will be many more and more to come :wink:
At the end I would like to have buttons for house on/off, outside on/off, window light on/off.
Can I assign the lights to a specific topic and switch a topic on/off ?

This is a common requirement for home automation and easy enough to resolve.

Set aside a MQTT topic naming convention for groups of lights. Create a short flow that starts with an MQTT input and results in outputs to all of the lights in the group. From your Dashboard, simply set up a switch that results in an output to that group topic name.

If you end up with loads of lights and groups, you may wish to consider some level of automation of the group definitions and that is also possible. You would define a data object with the mappings, key'd on the group topic name and create a generic flow that listents for the group topics, reads the object and outputs messages for each matching light.

I'm not sure if I can follow you ....
So I give my shellies a topic using the shelly app, something like shellies/homelight/shelly-XXXXXX

I assume this will only work if the lights all use the same payload to work ?

You could send different on payloads and have lights in multiple groups.

Here is an example the msg.lights could be stored in context, i have added them in message for ease.

[{"id":"5e8f9c5.9937164","type":"inject","z":"7f59364f045fd16d","name":"","props":[{"p":"payload"},{"p":"command","v":"{\"binary\":\"on\",\"dimmer\":100}","vt":"json"},{"p":"lights","v":"[{\"name\":\"lounge1\",\"type\":\"dimmer\",\"topic\":\"shelly/lounge1/cmnd\",\"group\":\"lounge\"},{\"name\":\"lounge2\",\"type\":\"binary\",\"topic\":\"shelly/lounge2/cmnd\",\"group\":\"lounge\"},{\"name\":\"lounge3\",\"type\":\"dimmer\",\"topic\":\"shelly/lounge3/cmnd\",\"group\":\"lounge\"},{\"name\":\"bed1\",\"type\":\"dimmer\",\"topic\":\"shelly/bed1/cmnd\",\"group\":\"bed1\"},{\"name\":\"hall1\",\"type\":\"binary\",\"topic\":\"shelly/hall1/cmnd\",\"group\":\"hall\"}]","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"lounge\", \"hall\"]","payloadType":"json","x":450,"y":80,"wires":[["c2f4bee9.3a8738"]]},{"id":"c2f4bee9.3a8738","type":"change","z":"7f59364f045fd16d","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.lights[$.group in $$.payload]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":140,"wires":[["74661fcd.0af728"]]},{"id":"74661fcd.0af728","type":"split","z":"7f59364f045fd16d","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":510,"y":200,"wires":[["d3190504.057b8"]]},{"id":"d3190504.057b8","type":"change","z":"7f59364f045fd16d","name":"","rules":[{"t":"move","p":"payload.topic","pt":"msg","to":"topic","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"$lookup($$.command, $$.payload.type)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":200,"wires":[["d68cf124.8737f"]]},{"id":"d68cf124.8737f","type":"debug","z":"7f59364f045fd16d","name":"mqtt node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":200,"wires":[]}]

If they don't, you will have to change the payload in the group light process flow.

It doesn't really matter what topics the outputs use - choose a topic for your groups, maybe lighting/group/01-Living-Room or whatever you like.

Then in the group listening flow, set an MQTT-in node to listen for lighting/group/01-Living-Room and connect that to several MQTT-out nodes, 1 to each of your Shelly switches.

On your Dashboard, add a UI switch node and output the state of that switch to MQTT with the topic lighting/group/01-Living-Room.

The result being that every time you change that UI switch, all of the Shelly's will also change state.

If the UI switch isn't sending the payload that the Shelly's need to receive, add a change node to the group listening flow to convert the two input states to the appropriate output states.

THX for the more detailed explanation. I will try this aver the weekend and hope to get it running :wink: