Excluding a group from another group to run rule syntax

I’m sure this is really simple to do, but I can’t find the documentation or a post on the right methods, assuming they exist.

I am treating groups like tags and not nesting them. In this case, I have a rule so that when I’m going to bed, I activate a switch that activates a timer lambda to perform various actions. Part of the timer allows certain lights to stay on but change state to act as a whole home nightlight and give me a few minutes to get things done before all lights are shut down (among other actions). I have a condition where I have one group gLightsInside, and I want to filter out all of the items from another group, gLightsNightlight. The goal is to turn off all members of gLightsInside EXCEPT those that are also members of gLightsNightlight. That way, I don’t have to turn all lights off and then switch the gLightsNightlight members on to a different state separately.

The following works to find the members of gLightsInside that are also members of gLightsNightlight:

	gLightsInside.members.filter[i | i.groupNames.contains("gLightsNightlight")].forEach[ s |
				logInfo("Test Rules","gLightsInside member is member of gLightsNightlight: " + s.name)
	]

but what I’m looking for is exactly the opposite filtering. I want to filter all members of gLightsInside that are NOT members of gLightsNightlight so I can turn them off. Then I can adjust gLightsNightlight members’ switches and dimmers accordingly. Is there a syntax something like

	gLightsInside.members.filter[i | i.groupNames.<NOTcontains>("gLightsNightlight")].forEach[ s |

...

that is available? Sorry if this is a stupid and obvious question, but I can’t seem to find the answer.

I put a not (“!”) on your condition in the quote above.
Should solve your problem

1 Like

Thanks! @george.erhan I figured I was missing something straightforward. Much appreciated! Works like a charm.