Not sure if this is of any value for people around, I’ve got two of the valves installed and solved the timeout problem with a simple rule:
var Timer waterTimer1 = null
var Timer waterTimer2 = null
rule "Continuous water flow 1"
when
Item Ventil1_OnOff changed to ON
then
logInfo("continuousWaterFlow", "Rule triggered...")
if (waterTimer1 !== null) {
logInfo("continuousWaterFlow", "...but timer already intitialised. Rescheduling now.")
waterTimer1.reschedule(now);
return;
}
waterTimer1 = createTimer(now, [ |
if (Ventil1_OnOff.state == ON) {
Ventil1_OnOff.sendCommand("ON")
logInfo("continuousWaterFlow", "Sent 'on' command to valve, rescheduling timer. ")
waterTimer1.reschedule(now.plusSeconds(40))
} else {
logInfo("continuousWaterFlow", "State switched to 'off' stopped sending commands")
waterTimer1.cancel()
}
])
end
rule "Continuous water flow 2"
when
Item Ventil2_OnOff changed to ON
then
logInfo("continuousWaterFlow", "Rule triggered...")
if (waterTimer2 !== null) {
logInfo("continuousWaterFlow", "...but timer already intitialised. Rescheduling now.")
waterTimer2.reschedule(now);
return;
}
waterTimer2 = createTimer(now, [ |
if (Ventil2_OnOff.state == ON) {
Ventil2_OnOff.sendCommand("ON")
logInfo("continuousWaterFlow", "Sent 'on' command to valve, rescheduling timer. ")
waterTimer2.reschedule(now.plusSeconds(40))
} else {
logInfo("continuousWaterFlow", "State switched to 'off' stopped sending commands")
waterTimer2.cancel()
}
])
end
Based on this: Design Pattern: Looping Timers
With that rule in a rules file, I am able to just switch the valves like there is no timeout.
Any hints for further improvement apreciated! ![]()