We have various Rollershutters around the house. I am in the process of making a rule that, if the “auto close when sun shines” switch is set to ON and certain criteria are met, the respective members closes. This way, I avoid writing the rule for every shutter. I tried implementing this designe pattern but get stuck on the filter bit. Here is (part of) the items file:
Group gZonAchter Group gZonAchterSwitch Rollershutter rolluikZolderRechts "Rolluik [%d %%]" <rollershutter> (gZonAchter) Rollershutter rolluikZolderLinks "Rolluik [%d %%]" <rollershutter> (gZonAchter) Switch rzrZon "Zon stand [MAP(zonstand.map):%s]" <sun> (gZonAchterSwitch) Switch rzlZon "Zon stand [MAP(zonstand.map):%s]" <sun> (gZonAchterSwitch)
So the Switch should define if the Shutter is in auto closing mode or not and the Rollershutter is the item that needs closing when certain conditions apply.
The rule should be something in the order of:
gZonAchter.members.forEach[ i | gZonAchterSwitch.members.filter [ j | j.state == ON ] sendCommand(DOWN)
Maybe my approach isn’t the right one so any hints/tips/trick in the right direction are appreciated.