Groups in Rules Issues

Hi All,

I’m having an issue with a rule that worked in OH2 but doesn’t seem to work well in OH 2.1. The behavior is really odd in that when the switch changes to OFF everything in the gLights group receives the command. Maybe my rule is screwed up? The second problem is that when the switch changes to ON it’s only supposed to send commands to 4 lights but you can see that it’s also sending the OFF command as well. Also noticed that it’s sending some commands more than once. I’ve been struggling to get this to work so any help or guidance is appreciated.

The Group

Group gLights

Example Item

Switch DR_Light "Dining Room Light"   (gWakeup, gWatchTV, gBed, gLights ) ["Lighting"] {channel="zwave:device:51164f7d:node11:switch_binary"}

The Rule

rule "Presence if OFF"
when Item Presence changed 
then
	if (Presence.state==OFF)
	{
		gLights.members.forEach(s | if (s.state==ON) {
		logInfo("Logging info", "Presence is off and turning off Lights")
		gLights.sendCommand(OFF)
		})
	
	}
	else
	{
		Entryway.sendCommand(ON)
		DR_Light.sendCommand(ON)
		Stairs1.sendCommand(ON)
		LR_Lamp.sendCommand(ON)
	}
end

The log entry

2017-08-03 11:39:45.614 [ItemCommandEvent          ] - Item 'Presence' received command OFF
2017-08-03 11:39:45.614 [ItemStateChangedEvent     ] - Presence changed from ON to OFF
2017-08-03 11:39:45.830 [ItemCommandEvent          ] - Item 'gLights' received command OFF
2017-08-03 11:39:45.832 [ItemCommandEvent          ] - Item 'DR_Light' received command OFF
2017-08-03 11:39:45.833 [ItemCommandEvent          ] - Item 'gLights' received command OFF
2017-08-03 11:39:45.834 [ItemCommandEvent          ] - Item 'Entryway' received command OFF
2017-08-03 11:39:45.835 [ItemCommandEvent          ] - Item 'LR_Lamp' received command OFF
2017-08-03 11:39:45.845 [ItemCommandEvent          ] - Item 'TV_Lightstrip' received command OFF
2017-08-03 11:39:45.857 [ItemCommandEvent          ] - Item 'Kitchen' received command OFF
2017-08-03 11:39:45.858 [ItemCommandEvent          ] - Item 'Porch' received command OFF
2017-08-03 11:39:45.859 [ItemCommandEvent          ] - Item 'Deck' received command OFF
2017-08-03 11:39:45.859 [ItemCommandEvent          ] - Item 'Patrick_Lights' received command OFF
2017-08-03 11:39:45.860 [ItemCommandEvent          ] - Item 'Evie_Lights' received command OFF
2017-08-03 11:39:45.861 [ItemCommandEvent          ] - Item 'Stairs1' received command OFF
2017-08-03 11:39:45.869 [ItemCommandEvent          ] - Item 'Down_Bath' received command OFF
2017-08-03 11:39:45.870 [ItemCommandEvent          ] - Item 'Downstairs_Light1' received command OFF
2017-08-03 11:39:45.882 [ItemCommandEvent          ] - Item 'Garage' received command OFF
2017-08-03 11:39:45.883 [ItemStateChangedEvent     ] - DR_Light changed from ON to OFF
2017-08-03 11:39:45.884 [ItemCommandEvent          ] - Item 'DR_Light' received command OFF
2017-08-03 11:39:45.884 [ItemCommandEvent          ] - Item 'Entryway' received command OFF
2017-08-03 11:39:45.885 [ItemCommandEvent          ] - Item 'LR_Lamp' received command OFF
2017-08-03 11:39:45.896 [ItemCommandEvent          ] - Item 'TV_Lightstrip' received command OFF
2017-08-03 11:39:45.908 [ItemCommandEvent          ] - Item 'Kitchen' received command OFF
2017-08-03 11:39:45.909 [ItemCommandEvent          ] - Item 'Porch' received command OFF
2017-08-03 11:39:45.910 [ItemCommandEvent          ] - Item 'Deck' received command OFF
2017-08-03 11:39:45.910 [ItemCommandEvent          ] - Item 'Patrick_Lights' received command OFF
2017-08-03 11:39:45.911 [ItemCommandEvent          ] - Item 'Evie_Lights' received command OFF
2017-08-03 11:39:45.912 [ItemCommandEvent          ] - Item 'Stairs1' received command OFF
2017-08-03 11:39:45.921 [ItemCommandEvent          ] - Item 'Down_Bath' received command OFF
2017-08-03 11:39:45.921 [ItemCommandEvent          ] - Item 'Downstairs_Light1' received command OFF
2017-08-03 11:39:45.934 [ItemCommandEvent          ] - Item 'Garage' received command OFF
2017-08-03 11:39:45.949 [ItemStateChangedEvent     ] - LR_Lamp changed from ON to OFF
2017-08-03 11:39:52.163 [ItemStateChangedEvent     ] - LR_Lamp_Color changed from 0,0,100 to 0,0,0
2017-08-03 11:39:52.163 [ItemStateChangedEvent     ] - LR_Lamp_Dimmer changed from 100 to 0
2017-08-03 11:40:23.068 [ItemCommandEvent          ] - Item 'Presence' received command ON
2017-08-03 11:40:23.069 [ItemStateChangedEvent     ] - Presence changed from OFF to ON
2017-08-03 11:40:23.111 [ItemCommandEvent          ] - Item 'DR_Light' received command OFF
2017-08-03 11:40:23.111 [ItemCommandEvent          ] - Item 'Entryway' received command ON
2017-08-03 11:40:23.112 [ItemCommandEvent          ] - Item 'Entryway' received command OFF
2017-08-03 11:40:23.112 [ItemCommandEvent          ] - Item 'DR_Light' received command ON
2017-08-03 11:40:23.113 [ItemCommandEvent          ] - Item 'Stairs1' received command ON
2017-08-03 11:40:23.113 [ItemCommandEvent          ] - Item 'LR_Lamp' received command OFF
2017-08-03 11:40:23.119 [ItemCommandEvent          ] - Item 'LR_Lamp' received command ON
2017-08-03 11:40:23.131 [ItemCommandEvent          ] - Item 'TV_Lightstrip' received command OFF
2017-08-03 11:40:23.148 [ItemStateChangedEvent     ] - Entryway changed from OFF to ON
2017-08-03 11:40:23.148 [ItemStateChangedEvent     ] - DR_Light changed from OFF to ON
2017-08-03 11:40:23.148 [ItemStateChangedEvent     ] - LR_Lamp changed from OFF to ON
2017-08-03 11:40:23.150 [ItemStateChangedEvent     ] - DR_Light changed from ON to OFF
2017-08-03 11:40:23.151 [ItemStateChangedEvent     ] - Entryway changed from ON to OFF
2017-08-03 11:40:23.151 [ItemStateChangedEvent     ] - Stairs1 changed from OFF to ON
2017-08-03 11:40:23.158 [ItemCommandEvent          ] - Item 'Kitchen' received command OFF
2017-08-03 11:40:23.159 [ItemCommandEvent          ] - Item 'Porch' received command OFF
2017-08-03 11:40:23.159 [ItemCommandEvent          ] - Item 'Deck' received command OFF
2017-08-03 11:40:23.160 [ItemCommandEvent          ] - Item 'Patrick_Lights' received command OFF
2017-08-03 11:40:23.161 [ItemCommandEvent          ] - Item 'Evie_Lights' received command OFF
2017-08-03 11:40:23.162 [ItemCommandEvent          ] - Item 'Stairs1' received command OFF
2017-08-03 11:40:23.162 [ItemStateChangedEvent     ] - Stairs1 changed from ON to OFF
2017-08-03 11:40:23.172 [ItemCommandEvent          ] - Item 'Down_Bath' received command OFF
2017-08-03 11:40:23.172 [ItemCommandEvent          ] - Item 'Downstairs_Light1' received command OFF
2017-08-03 11:40:23.184 [ItemCommandEvent          ] - Item 'Garage' received command OFF
2017-08-03 11:40:23.389 [ItemCommandEvent          ] - Item 'Stairs2' received command OFF
2017-08-03 11:40:23.390 [ItemCommandEvent          ] - Item 'Stairs2' received command OFF

this will send OFF to the group every time the rule finds an item in that group that has an ON state.

The correct way would be:
s.sendCommand(OFF)

1 Like

You need to give your Group a type or else it doesn’t process updates like it used to. This was one of the breaking changes that was announced as part of OH 2. Group:Switch gLights should be sufficient.

Which switch?

Which switch?

Post your openhab.log entries as well and add some additional logging to your rule.

That makes sense. Thanks for the correction.

1 Like

Thanks. I didn’t realize about the group types.

The switch I was referencing:

Switch Presence

I’ll post the openhab log when I have time to test it again later this afternoon.

Thanks again for the help,

Hi Rich,

So I went through the logs and I got to say I feel pretty stupid. I found that I had a ‘test.rules’ file that I forgot about that was triggering all the confusion. Once I saw that everything works as it should again. So between yourself and @Dim everything is as it should be.

Thanks for pointing me in the right direction.