[SOLVED] Reducing the impact of turning off MANY lights? How to optimise

Because it is incomplete. What is an instance of SwitchItem?
Once again, in this situation, the complete statement is
Lights instanceOf SwitchItem

But as discussed that won’t work because it will ignore Dimmer types as well as Group types it finds among the “top” group’s members.

No, this what the filtering is about. In the first version of the rule, we used the filter only to find things that are ON.
But as you have some things that are Groups that can also be ON, we have to miss those out as well.
And now there are Dimmers, which aren’t ON but 55% in their basic state.

It might be more comprehensible writing it out longhand, and doesn’t take much more processing.

gAllLights?.allMembers.forEach[ someItem |
      if (someItem instanceOf SwitchItem && someItem.state == ON) {
         someItem.sendCommand(OFF)
      } else if (someItem instanceOf DimmerItem && someItem.state > 0) {
         someItem.sendCommand(OFF)
      } //else if any other type we do nothing
]
1 Like