I have some sprinklers in my backyard. Because of the water pressure isn’t enough to can activate all, I want to make a logic, that only one of them can be active.
Using OH25 I’ve used this rule … (see below relevant parts of the rule)
I guess there is a new and better solution available in OH3. Not?
Or any other suggestions?
Additionally I’m using timers to walk through all sprinkler valves after a defined time per sprinkler. But this will become another topic if needed.
rule "pi2_spX_timer"
when
Item pi2_sp1 changed to ON or
Item pi2_sp2 changed to ON or
Item pi2_sp3 changed to ON or
Item pi2_sp4 changed to ON or
Item pi2_sp5 changed to ON or
Item pi2_sp6 changed to ON or
Item tasmota_sp7 changed to ON or
Item tasmota_sp8 changed to ON or
Item tasmota_sp9 changed to ON
then
pi2_sp_timer?.cancel
// pi2_auto_timer?.cancel
if ( triggeringItem.name.toString() != "pi2_sp1" ) {
sendCommand("pi2_sp1", "OFF")
}
if ( triggeringItem.name.toString() != "pi2_sp2" ) {
sendCommand("pi2_sp2", "OFF")
}
if ( triggeringItem.name.toString() != "pi2_sp3" ) {
sendCommand("pi2_sp3", "OFF")
}
if ( triggeringItem.name.toString() != "pi2_sp4" ) {
sendCommand("pi2_sp4", "OFF")
}
if ( triggeringItem.name.toString() != "pi2_sp5" ) {
sendCommand("pi2_sp5", "OFF")
}
if ( triggeringItem.name.toString() != "pi2_sp6" ) {
sendCommand("pi2_sp6", "OFF")
}
if ( triggeringItem.name.toString() != "tasmota_sp7" ) {
sendCommand("tasmota_sp7", "OFF")
}
if ( triggeringItem.name.toString() != "tasmota_sp8" ) {
sendCommand("tasmota_sp8", "OFF")
}
if ( triggeringItem.name.toString() != "tasmota_sp9" ) {
sendCommand("tasmota_sp9", "OFF")
}
....
....
end
It’s not clear how your sprinklers start, but I suspect that using UI rules in OH3 you could greatly reduce this logic. Using the UI, rules can have a condition that must be satisfied before the rule is run. If all your sprinklers are in a group that has that has an aggregation function which sets the group to ON if any on sprinkler is ON then you can use that group in the rule condition. So: If the group is ON (i.e., any one sprinkler is currently ON) then the rule doesn’t even run. At that point the rule script is reduced to passing the ON command to whatever sprinkler is indicated by the rule trigger.
I’ve created some items for sprinkler and some helper.
Sprinkler<n> -> Valve number
Sprinkler<n>_Duration -> Duration per sprinkler in minutes
Sprinkler<n>_nextSprinkler -> To can run through all sprinkler in a specific order .
Sprinkler<n>_lastUpdate -> Last stop time. For statistics.
There will be some other switches to can start automatically and with a specific valve.
My plan is to start a valve using a timer for specified defined time. After that it should check if the automatic is furthermore active and start the next valve. Using additional items, especially “nextSprinkler” I can reduce a lot of code of my current rule.
I guess I will combine both rules into one to be sure that only one valve is open. Before summer it should be finished. I will let you know about the result.