Upon thinking about it I’m not so sure that I would implement this using lambdas. I think it can be implemented with just a couple of rules. You would:
have an item that you send a command to that triggered the main rule
the main rule has an if clause to see if the controller switch is ON or OFF. If OFF set the cancel flag. If ON execute the irrigation logic
The irrigation logic
starts the first zone
has a while loop that periodically checks for the cancel, if cancelled the irrigation stops
inside the while loop check to see if it is time to move to the next zone, when it is the off the current zone and start the next. Keep the amount of time to run each zone in a group and use Item names so it is ready to construct the name on one from the other. Examples are [here](Design Pattern: Working with Groups in Rules
set up persistence on the zones so we can call lastUpdate
So, for example:
int zone =0
while(!cancelled && zone < gZones.members.size){
var currZone = gZones.members.filter[z|z.name == "IrrigationZone"+zone].head as SwitchItem
var Number timeMins = gZoneTimes.members.filter[t|t.name == currZone.name+"Time"].head.state as Number
if(now.minusMinutes(timeMins).isBefore(currZone.lastUpdate.millis) {
zone = zone +1
currZone.sendCommand(OFF)
}
else {
if(currZone.state != ON) currZone.sendCommand(ON)
Thread::sleep(5000)
}
}
gZones.members.forEach(z|z.sendCommand(OFF)
I just tried in the above on my phone. There are probably errors.