Using Group:Switch:OR

I have the following in my items file:

Group:Switch:OR(ON,OFF) Groupswitch_All_Lights “Alle Lichten [(%d)]” (gAll)

Dimmer Light_VH_Hal_Tafellamp “Haltafel lamp (HA) [%d %%]” (gAll,gSunset) {

and the following in my site file:

	Switch item=Groupswitch_All_Lights mappings=[OFF="UIT", ON="AAN"] 

when i press the button in the app for the Group switch I expect the light “Haltafel” to turn on/off. This does not happen. I see other people use “Groupswitch_All_Lights” in their dimmer declaration:

Dimmer Light_VH_Hal_Tafellamp “Haltafel lamp (HA) [%d %%]” (Groupswitch_All_Lights,gSunset)

that works, but this defeats the whole purpose of having groups…

What am I doing wrong?

You have to be able to tell openHAB what Items are members of a Group. It can’t magically tell what you intend to be part of a Group. There is nothing special about the name of the Group.

That is what the “(group1, group2,group3)” part of the Item definition is for, to tell openHAB that Light_VH_Hal_Tafellamp is a member of those groups.

I’m not sure what you think the whole purpose of having groups is, but it is clearly a mistaken understanding of how Groups work.

The whole purpose of Groups is to:

  • represent a group of similar Items on the sitemap as a single Item (e.g. have one switch for many lights) for information or to send the same command to all members

  • get an aggregate value from the states of all the Group members (e.g. max, min, avg, OR, AND)

  • easily change which persistence config applies to which Items through Group membership (e.g. create a Group called gChart, setup rrd4j.persist to save gChart* every minute, assign gChart to those Items you want to chart)

  • trigger a rule to run when any of the members receive an update

  • loop through all the members of a Group and do some action on each based on some other event (e.g. when Presence goes to OFF turn off all the lights via a Rule)

  • provide a way to create a subframe on your sitemap that includes all the members of the Group without manually defining each element

The purpose of a Group is not to free you from having to tell openHAB which of your Items represent a Light and automatically assign them to the GroupSwtich_All_Lights group.


Thank you for your detailed explanation. You have shown me some usefull information on groups. But i think my question was not clear enough.

I use groups to group items that belong together so i can, as you explained, send commands to them.

So i have a group lets say that is called gAll_Lights that I put in the definition of every light in the house.

I would like to be able to switch that group gAll_Lights on and off and was thinking the item group:switch was the way to do that. That did not work using the statements in my original post.

Group:Switch:OR(ON,OFF) Groupswitch_All_Lights “Alle Lichten [(%d)]” (gAll_Lights)

Instead I have to put the group:switch name in every light’s definition to make it work.

Hope my question is more clear and thanks again for taking the time to answer my questions.



thank you for your explanation.

I think I have found my mistake, I have found the following on the Internet :

Der Itemtyp „Group“
Wurden bei der bisherigen Definition der Items sinnvolle Gruppierungen geschaffen, ist es mit dem Itemtyp „Group“ möglich, ganze Gruppen zu schalten. Befinden sich beispielsweise alle Lichter in der Gruppe „All“, können diese mit dem folgenden Item zugleich ein- und ausgeschaltet werden:

Group:Switch:OR(ON, OFF) Lights "All Lights [(%d)]" (All)
Die Angabe „%d“ zeigt zudem die Anzahl der eingeschalteten Lichter auf der entsprechenden Stelle der Sitemap an.

I concluded out of the above that the group switch switched the group “All” in above example, but it is just the other way around; the group switch “Lights” in above example is part of the group “All”

My item file now looks like this:

Group:Dimmer:OR(ON,OFF) gLights_All	"Huis" 

Group:Dimmer:OR(ON,OFF) gLights_VH "Voorhuis" (gLights_All)
Group:Dimmer:OR(ON,OFF) gLights_AH "Achterhuis" (gLights_All)
Group:Dimmer:OR(ON,OFF) gLights_BU "Buiten" (gLights_All)

Group:Dimmer:OR(ON,OFF) gLights_VH_Studeerkamer "Studeerkamer"	<office> (gLights_VH)
Group:Dimmer:OR(ON,OFF) gLights_VH_Toilet "Toilet"	<toilet>	(gLights_VH)
Group:Dimmer:OR(ON,OFF)	gLights_VH_Meterkast "Meterkast" <wardrobe> (gLights_VH)
Group:Dimmer:OR(ON,OFF) gLights_VH_Keuken "Lichten keuken"	<kitchen>	(gLights_VH)
Group:Dimmer:OR(ON,OFF)	gLights_VH_Woonkamer "Woonkamer"	<video>	(gLights_VH)
Group:Dimmer:OR(ON,OFF)	gLights_VH_Hal "Hal"	<corridor>	(gLights_VH)

Group:Dimmer:OR(ON,OFF)	Dimmers_VH_Studeerkamer "Alle Lichten" (gLights_VH_Studeerkamer) //Dimmer voor alle studeerkamerverlichting
Group:Dimmer:AVG(ON,OFF) Dimmers_VH_Keuken "Alle Lichten" (gLights_VH_Keuken) // Dimmer voor alle keukenverlichting
Group:Dimmer:OR(ON,OFF)	Dimmers_VH_Woonkamer "Alle Lichten" (gLights_VH_Woonkamer) //Dimmer voor alle woonkamerverlichting
Group:Dimmer:OR(ON,OFF)	Dimmers_VH_Hal "Alle Lichten" (gLights_VH_Hal) //Dimmer voor alle halverlichting

Dimmer	Light_VH_Hal_Tafellamp	"Haltafel lamp (HA) [%d %%]" <slider>	(Dimmers_VH_Hal, gSunset)		{

Now I am able to send commands to “gLights_All” that is propagated to all participants.

kind regards


1 Like


I’m trying to use group switch as presence indicator, but, the group switch does not update when members of the group are updated.

These are items definitions:

Group:Switch:OR(ON, OFF) Smartphone_All_WiFi_State_Value "Connected to Wi-Fi" <network>

Switch Smartphone_One_WiFi_State_Value "Connected to Wi-Fi [MAP(]" <network> (Smartphone_All_WiFi_State_Value)

Switch Smartphone_Two_WiFi_State_Value "Connected to Wi-Fi [MAP(]" <network> (Smartphone_All_WiFi_State_Value)

In the sitemap definition I have following:

Switch item=Smartphone_All_WiFi_State_Value

I’ve tried removing mapping from the switches, but it didn’t help. I’ve also tried changing group item to:

Group:Switch:AND(OFF, ON) Smartphone_All_WiFi_State_Value "Connected to Wi-Fi" <network>

Whatever I do, the group switch is not updated when single switch or both switches are changed to, either ON or OFF. It just stays OFF. If I flip the group switch to ON, it turns ON both switches, but then immediately switches itself to OFF. I’m not sure what am I doing wrong. I’m using OH2 nightly on Windows 7, if it makes any difference.

Best regards,

How are you verifying the Group’s state? By watching events.log or by just looking at Basic UI or Classic UI?

If just looking at Classic UI, if you refresh the page does it show the correct value?

The problem may be in the UI refresh rather than the Group.


I was verifying it via Classic UI and HABDroid, but I think the problem isn’t refresh (I’ve tried refreshing manually), because, even when I turn group switch ON via UI, it changes the state of all the members, but group switch instantly goes to OFF again.

Best regards,

I recommend watching events.log and verify that the Group is indeed not getting the updates.

I am pointing in this direction because I have Groups defined almost identically to yours and they are working just fine. So there is something different or something else going wrong.

Hello @rlkoshak

I’ve found what the problem was. It looks like the group switch can’t be used with members that contain mapping. I’ve tried it before, but, it looks like a restart was needed after those changes. Looks like I’ll have to add separate items with mappings that will be updated via rules when master item receives change. Thank you for your help.

Best regards,

Hello, I don’t know if this is related to the topic but hope someone can guide me in the right direction.
I have changed things file to declare some of the online devices, items as switch all in the same group (Guests).
Everything works just fine until now.
I’m trying to amaze my friends with a doorbell that tells me who is ringing.
The principal should be :

  1. their phones will connect automatically in my network via WI-FI
  2. virtual switches will change status to ON
  3. They press an Amazon dash button at the door
  4. Rule when dash is pressed to play doorbell.mp3 and then say “please open the door for” + all the names of the switches in Guest group that is with the status ON.
    If all OFF just say "someone is at the front door "

I know is a silly rule but I have very limited programming language skills and usually I have to get fragments from multiple rules to make one.
Any help much appreciated!

This is probably best posted as a new thread.

Search the forum for “presence” and you will find dozens of postings showing how to detect the phones.

But be aware that timing may be an issue. Depending on your wifi signal, types of phones, etc your friend’s phones may not be detected until after they press the button. Also, there can be quite a delay for the time one presses a Dash button and the button press is detected.

1 Like