Is it possible to create a group switch?

I would like to create a group switch that is something like 'Upstairs Lights", but still be able to toggle the individual. So for example, I could have:

  1. Upstairs Hallway Lights: On
  2. Master Bedroom Light: Off

But if I toggle the ‘Upstairs Lights’ switch they will both turn off or on. In other words, I don’t want the individual switches to change the state of the ‘grouped’ switch.

Is this possible? If so, how? Thanks!! I’m getting myhead wrapped around this thing, so if you point me in the right direction, I can probably figure it out.

Items may be added to special class of Item called a Group.

If you send a command to Group from rule or UI, that command gets passed to each individual member Item of the Group.

It doesn’t seem I can add a group to the Cloud Connector Exposed items though, or am I missing something?

never mind…I think I had an error in my items file. I think I got it…I’ll report back in a bit.

So I exposed the group in the config of the cloud connector, but it isn’t showing in the items on myopenhab. I do remember last time I added stuff it took a while, so I’ll let it go for a bit and see if it shows.

I don’t do myopenhab, but I think you need some change in Item state to trigger the “upload”.

Groups are special Items, so far as state goes. You cannot directly update a Group state, it can only be assigned by some aggregating function - something like SUM that takes all the member states into account. And that’s only going to work when you give the Group a type, a flavour if you like, so that it can look a bit like a regular Item.

Example (in xxx.items file form, you can do similar things in PaperUI)
Group:Number:SUM someGroup "My group" ...

For a Group of switches, this is fairly typical
Group:Switch:OR(ON,OFF) ...

I understand the first part (and suspected that may be why I don’t see it in MyOpenHAB), but I didn’t follow what I actually need to do. Below is the actual content that is relevant from my items file:

Group Upstairs 

Switch Upstairs_Hallway_Lights "Upstairs Hallway Lights" <switch> (Upstairs) [ "Lighting" ] 
Switch Upstairs_Back_Hallway_Lights "Upstairs Back Hallway Lights" <switch> (Upstairs) [ "Lighting" ]
Switch Stairs_Lights "Stairs Lights" <switch> (Upstairs) [ "Lighting" ]

Group:Switch:OR(ON,OFF) Upstairs

This will give the Group a state. If any of is members are ON, the Group will have state ON. Otherwise it’ll be OFF.

I’ve no clue if that is all that’s needed to sort out your myopenhab issue, but you can now make the Group change state by operating a member Item.

Bonus; put the Group in your sitemap as a master switch in your UI.

So I removed the existing Upstairs group (not sure if that was right), and added the Group:switch…

I then added “Default item=Upstairs label=“upstairs master”” to my sitemap, but it didn’t actually create a master switch, it just created another group, with 3 switches inside.

Currently I have a webserver running at my house, and I am using the REST API to do what I want, but I’m just concerned that it may be a security risk. But at least it is working right now.

As was already said the “:Switch:OR(ON,OFF)” added to a group gives it a state. So as @rossko57 wrote above you want it like this:

Group:Switch:OR(ON,OFF) Upstairs

And if you want to use it in your Sitemap as a switch you have to create a switch there and not a default type:

Switch item=Upstairs label="Upstairs master switch" icon="firstfloor"



As Johannes says, use a Switch widget in your sitemap, not let it default (to a Group widget, naturally enough). Sitemap does what you tell it to.

It’s not obvious that sitemap lets you choose any widget to display/control any Item (although not all combinations make sense)
Displaying your Group Item in a Text widget for example will show you the status without the switching control knob.

You can give your Group an <icon>, just like the real switches.

Thanks everyone! I got it to work! Really appreciate the help! Learned a lot in the process as well.

Now using, and my Google Home, I can say things like “OK, Google, turn off the downstairs lights”, and they all turn off.

The only weird thing is that sometime the basic UI doesn’t update 100% correctly. probably 50% of the time, the dimmers will not go to 0 or 100%, they will settle someplace in the middle. I have already changed some of the settings in the actual dimmer switch to alleviate this same problem seen when I manually update the dimmer level (by pressing the hardware), but it still has issues in the above scenario. If I repeat the command, then it fixes it though, so not a huge deal, or if I wait for a while between command (which is probably likely in the real world), then there is no issue.