One swtich state change others on UI aswell

How can i create an item, when it is triggered, it changes the state of two other switches as well?

Group Bedroom "Bedroom" <bedroom> (Home)
    Switch Bedroom_Small_Lamp_One "Bedroom Small Lamp One" <light> (Bedroom, Lights) [ "Lighting" ] { mqtt=">[broker:bedroom/smalllamp/one/off:command:OFF:0],>[broker:bedroom/smalllamp/one/on:command:ON:1]"}
    Switch Bedroom_Small_Lamp_Two "Bedroom Small Lamp Two" <light> (Bedroom, Lights) [ "Lighting" ] { mqtt=">[broker:bedroom/smalllamp/two/off:command:OFF:0],>[broker:bedroom/smalllamp/two/on:command:ON:1]"}
    Switch Bedroom_Small_Lamps "Bedroom Small Lamps" <light> (Bedroom, Lights) [ "Lighting" ] { mqtt=">[broker:bedroom/smalllamps/off:command:OFF:0],>[broker:bedroom/smalllamps/on:command:ON:1]"}

So when i trigger Small Lamps, it shoud change both the lamp switch to ON as well.

Thanks in advance.

There are three approaches.

  1. Group
Group Bedroom "Bedroom" <bedroom> (Home)

Group:Switch allBedroom_Small_Lamps "Bedroom Small Lamps" <light> (Bedroom, Lights) [ "Lighting" ]

    Switch Bedroom_Small_Lamp_One "Bedroom Small Lamp One" <light> (Bedroom, Lights, allBedroom_Small_Lamps) [ "Lighting" ] { mqtt=">[broker:bedroom/smalllamp/one/off:command:OFF:0],>[broker:bedroom/smalllamp/one/on:command:ON:1]"}
    Switch Bedroom_Small_Lamp_Two "Bedroom Small Lamp Two" <light> (Bedroom, Lights, allBedroom_Small_Lamps) [ "Lighting" ] { mqtt=">[broker:bedroom/smalllamp/two/off:command:OFF:0],>[broker:bedroom/smalllamp/two/on:command:ON:1]"}
    Switch Bedroom_Small_Lamps "Bedroom Small Lamps" <light> (Bedroom, Lights, allBedroom_Small_Lamps) [ "Lighting" ] { mqtt=">[broker:bedroom/smalllamps/off:command:OFF:0],>[broker:bedroom/smalllamps/on:command:ON:1]"}

From a Rule to send a command to all the small lamps:

allBedroom_Small_Lamps.sendCommand(ON)

On the sitemap use:

Switch item=allBedroom_Small_Lamps
  1. Rule
rule "Bedroom_Small_Lamps received command"
when
    Item Bedroom_Small_Lamps received command
then
    Bedroom_Small_Lamp_One.sendCommand(receivedCommand)
    Bedroom_Small_Lamp_Two.sendCommand(receivedCommand)
end
  1. Send message to multiple MQTT topics
Switch Bedroom_Small_Lamps "Bedroom Small Lamps" <light> (Bedroom, Lights) [ "Lighting" ] 
{ mqtt=">[broker:bedroom/smalllamps/off:command:OFF:0],>[broker:bedroom/smalllamps/on:command:ON:1],
        >[broker:bedroom/smalllamp/two/off:command:OFF:0],>[broker:bedroom/smalllamp/two/on:command:ON:1],
        >[broker:bedroom/smalllamp/one/off:command:OFF:0],>[broker:bedroom/smalllamp/one/on:command:ON:1]"}
1 Like

Hello,

Thanks for the answer, sadly all of them work but none of them do what i want. I don’t want to do the logic in openhab i have a node-red layer which will analyse the mqtt comands. What i want is that the UI reflect on the change of when i trigger small lamps switchit trigger the switch on the UI for the two individual switches as well. Can it be done somehow?

Thanks in advance.

If the lights are actually turned OFF then the UI will show them as OFF. If the lights are ON, or nothing has told OH that the lights have turned OFF then there is nothing you can do. OH has to be told that the light has become a new state.

And these sorts of details like the fact that you are using NodeRed are pretty important to include in your original posting in the future.