Hey everyone, I wanted to share my recent experience with setting up a smart pump control system. It’s been quite the learning curve, but I think I’ve got it figured out! ![]()
So, my goal was to automate the watering of my garden using a smart pump. The idea was to have the pump run for 2 minutes, turn off for 30 seconds, and repeat this cycle four times. I set up a rule using OpenHAB, but initially, I ran into some issues. The pump wasn’t cycling correctly, and I kept getting errors related to the timer function. ![]()
After some research and trial and error, I realized the problem was with how I was initializing the timer and counter variables. I had to ensure that the counter reset properly after each cycle and that the timer was correctly tied to the duration set by my vRegnerDauer item. Here’s a snippet of the corrected rule:
plaintext
rule “Beregnung an”
when Item test_rainbird changed to ON or Item Beregnung_Timer30s changed from ON to OFF
then
val Dauer = (vRegnerDauer.state as DecimalType).intValue
if (!(BeregnungsCounter.state instanceof Number)) {
BeregnungsCounter.postUpdate(1)
}
if (BeregnungsCounter.state > 4) {
BeregnungsCounter.postUpdate(1)
}
if (BeregnungsCounter.state <= 4 && BeregnungsCounter.state >= 1) {
BeregnungsCounter.postUpdate(1 + (BeregnungsCounter.state as Number))
}
if (BeregnungsCounter.state >= 1 && BeregnungsCounter.state <= 4) {
TimerBeregnung = createTimer(now.plusMinutes(vRegnerDauer)) [| eg_az_l_stecker1.sendCommand(ON) ]
}
if (BeregnungsCounter.state <= 3) {
Beregnung_Timer30s.sendCommand(ON)
} else {
test_rainbird.sendCommand(OFF)
logInfo(“Beregnung”, “All 4 watering phases completed”)
}
end
This adjustment ensured that the pump cycles correctly and resets after four cycles. I also had to tweak the timer initialization to avoid the DateTime error I was encountering. ![]()
If anyone else is working on similar automation projects, I’d love to hear about your experiences or tips! Let’s keep the learning and sharing going! ![]()
Cheers,
[Your Name]