Rules Trigger every item in group but 1

Hey all,

I have a very simple question, is it possible to use rules to tigger every item in a group except for 1?

Simple answer: no

Okay thanks. i know i can create a separate group without the one item in it and trigger that group or list every item individually but wanted to know if there was an easier way.

With an If / else Statement its possible.
You must Loop it with all Members of the Group

if ( != "Item Name that not Trigger")

This rule turns off all the lights in the apartment, but the lights in the living room don’t when the TV is on. I hope you can write your rule with it :slight_smile: Of course you can also do it without a timer, I have the timer in it because I have many radio actuators.

var Timer timer_Komplette_Beleuchtung_mit_Ausnhamen_ausschalten = null
var Counter_Komplette_Beleuchtung_mit_Ausnhamen_ausschalten = 0

rule "Komplette Beleuchtung mit Ausnhamen ausschalten"
  Item Komplette_Beleuchtung_AUS changed from OFF to ON
  Counter_Komplette_Beleuchtung_mit_Ausnhamen_ausschalten = 0
  timer_Komplette_Beleuchtung_mit_Ausnhamen_ausschalten = createTimer(now.plusMillis(100), [|
    Counter_Komplette_Beleuchtung_mit_Ausnhamen_ausschalten += 1
      if(Counter_Komplette_Beleuchtung_mit_Ausnhamen_ausschalten <= gLight.members.size) {
        var gLight_item = gLight.members.sortBy[name].get(Counter_Komplette_Beleuchtung_mit_Ausnhamen_ausschalten -1)
        if(gLight_item.state == ON) {
          if ( == "Stehlampe_Wohnzimmer_Schrank_Switch" || == "Stehlampe_Wohnzimmer_Sofa_Switch") {
        if (TV_Main_Switch_WZ.state == OFF && Apple_TV_Main_Switch_WZ.state == OFF){
              gLight.members.sortBy[name].get(Counter_Komplette_Beleuchtung_mit_Ausnhamen_ausschalten -1).sendCommand(OFF)
          } else {
              gLight.members.sortBy[name].get(Counter_Komplette_Beleuchtung_mit_Ausnhamen_ausschalten -1).sendCommand(OFF)
    } else {
      } else {
          timer_Komplette_Beleuchtung_mit_Ausnhamen_ausschalten = null
1 Like

Using a “Member of” trigger, the rule will trigger when any member changes/updates, so the answer to your question is no. However, you can trigger on all members and ignore the times when a particular Item causes the trigger…

from core.rules import rule
from core.triggers import when

@rule("Test rule")
@when("Member of gMotion changed")
def motion_sensor_changed(event):
    if event.itemName != "Item_I_Dont_Want_To_Trigger_This_Rule_On":
        # do stuff

Hey guys, thank you very much for the responses! I think i might have misspoken when i wrote the title . let me elaborate a bit on what i want to do.

I have a leaving scene that turns off all lights but i want it to turn off all lights except for the one above the exterior door (so i can set the alarm and see when its dark outside). In a perfect world the rule would say ‘turn all lights in Group_name off except for Light_Name’

Kevin’s @ei_Gelb_Geek example has the parts you need.
How to iterate through the members of a group, how to compare the name of an Item to single it out.

1 Like

Thanks! I am somewhat new so ill check it out.

There’s more in that example than you need, but if you can grow your own rule stage by stage you’ll get something out of the exercise.
See also

1 Like