Group rule to send lights off by using an OFF command ONLY to items that are ON

Hi All,

Using 2.4 stable, rules DSL and trying to send only the OFF command to items that are on. This is due to the fact there are so many lights that sending off commands to items already OFF seems pointless and a poor design.

So I have this rule, but in the karaf console I see OFF commands sent to all devices.

rule "Turn off All Lights"
when
       Item gAllLights received command OFF
then
         gAllLights?.members.filter[Lights | Lights.state==ON].forEach[ LightsON |
               LightsON.sendCommand(OFF)
            ]
end

The group is a switch:OR(ON,OFF)

I can’t see an issue with this rule but clearly something is wrong. The original post was here, where rossko helped and this is the same setup :frowning:

Thanks!

This should not be an issue, but…

When a command is sent to a group, it will be passed on to all members of the group. One way around this is to use a proxy Item and trigger the rule off of that Item. You also may be interested in this…

1 Like

thanks scott, ill give a proxy a go!

In this case the unwanted OFF commands on items that are alreadys OFF would have been sent even WITHOUT the rule. IMHO the question is how did the Group get this command.

I send the OFF command to the group using habpanel. Now im sending the off command to a proxy item, which is matched using a rule