I need GROUP help!

Now that I have a better understanding of groups, I’m having an issue making it work.

In my items file I have the following:

Group gLights
Switch Corner "Breakfast" [ "Switchable" ] (gLights) {channel="zwave:device:ad34b696:node2:switch_binary"}
Switch All_Off "Everything" [ "Switchable" ] (gLights) { autoupdate="false",tcp=">[ON:10.5.1.6:3040:'MAP(off.map)'],>[OFF:10.5.1.6:3040:'MAP(off.map)']"}
Group:Switch:OR(ON,OFF) gLights "House" [ "Switchable" ]

In my sitemap file I have

		Switch item=All_Off mappings=[ON="Go!"]

		Switch item=House mappings=[ON="Turn House Off"]

Yet these switches do not fire…the All_Off one previously worked before I added it to the group gLights

In the log I see…

2017-05-06 11:15:36.814 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'All_Off' for widget org.eclipse.smarthome.model.sitemap.Switch
2017-05-06 11:15:36.815 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'All_Off' for widget org.eclipse.smarthome.model.sitemap.Switch
2017-05-06 11:15:36.815 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Switch
2017-05-06 11:15:36.815 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'House' for widget org.eclipse.smarthome.model.sitemap.Switch
2017-05-06 11:15:36.815 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'House' for widget org.eclipse.smarthome.model.sitemap.Switch
2017-05-06 11:15:36.815 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Switch

It may be something simple but I’m just not seeing what it is…

Any suggestions?

Shouldn’t it be:

Group:Switch:OR(ON,OFF) House (gLights) 

I tried that and received:

2017-05-06 18:28:42.125 [INFO ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/House' for the unknown item 'House'

Item with name (not label) “House” is not defined in your *.items file, so it won’t work like this.

One way to do it would be:

In *.items file:

Group gAll
Group:Switch:OR(ON, OFF)	gHouse		"Entire House [(%d)]"	(gAll)
Group:Switch:OR(ON, OFF)	gLights		"All Lights [(%d)]"		(gHouse)

Switch Corner		"Breakfast"		[ "Switchable" ] (gLights) {channel="zwave:device:ad34b696:node2:switch_binary"}
Switch Some_Light	"Everything"	[ "Switchable" ] (gLights) {autoupdate="false",tcp=">[ON:10.5.1.6:3040:'MAP(off.map)'],>[OFF:10.5.1.6:3040:'MAP(off.map)']"}

Note: On the second switch, for both actions (ON & OFF), you are using the same map file (off.map). Is this correct?

Then, in your *.sitemap:

sitemap Home label="Home"
{
	Frame {
		Text label="Master House Control" icon="house" {
			Switch item=gHouse	 mappings=[OFF="G.All OFF"]
			Switch item=gHouse	 mappings=[ON="G.All ON"]
		}
		Text label="Master Lights Control" icon="light" {
			Switch item=gLights	mappings=[OFF="G.All OFF"]
			Switch item=gLights	mappings=[ON="G.All ON"]
		}
	}
}

Tips & Tricks: Use “g” in front of all your Group names (e.g. gAll, gLights, etc) to be able to identify them easier in your configs.

@Dim

Thank you for your assistance with this…I have a couple of questions if I may so I can better understand the syntax.

  1. I thought you needed to declare the group before you could add members? I see you declared gAll, but I don’t see gLights?

  2. Why is there a need for two switches? Is Group:Switch not really a switch?

  3. What is the %d for?

Many thanks,

Squid

1 Like

Correct (first declare the group, the add the other items and/or groups as members)

The gLights Group is being defined in the following line:

Group:Switch:OR(ON, OFF)	gLights		"All Lights [(%d)]"		(gHouse)

The Group gLights has 2 extra characteristics (versus the simple gAll Group)
(a) A type (Switch)
(b) A Function (OR) with 2 conditions (ON, OFF)

If at least 1 member of the Group is in state “ON”, then the Group state will become “ON” also (otherwise: “OFF”)

See more on Group Functions here: http://docs.openhab.org/configuration/items.html#group-item-types
Note: A Group is just another Item (type).

The Group:Switch is the type of the Group. This is to control it’s behavior. When you flick the switch of the Group, all Group member items will receive the same command (ON or OFF).

It’s a label parameter for counting the members of the Group in the specific State (ON in this case)
In the sitemap, it will show how many Items (Switches) are in this state within the Group.

Tips & Tricks: Use a separate *.items file for all your group definitions (example: gGroups.items file) to help you organize your OH2 configs :slight_smile:
You can use the Group names then in other files (e.g. ZWave.items) since OH2 will read all *.items files.