-
Notifications
You must be signed in to change notification settings - Fork 20
Soil moisture level in irrigation controller #5
First of all: awesome project! I would like to know if you're interested in helping me with integrating a soil moisture sensor into the equation. It's a Vegetronix which simply outputs a value from 0-3.3v, depending on the moisture-level of the soil.
I'm perfectly comfortable with getting the output of the sensor available for ESPHome(by the ADC converter) and filter the results while adding some hysteresis with a template sensor. Either by using the Sonoff ADC pin, or pickup the value from a separate ESP through MQTT or Home Assistant. What I don't know is how to make that value prevent a scheduled irrigation to run.
Simply put: if the ADC voltage is equal or higher than a certain level between 0-3.3v -> don't run.
I think the most logical insertion point is in the automation:
- lambda: |- if (scheduled_runtime(id(irrigation_zone1_next).state.c_str())) { id(irrigation_zone1).turn_on(); } if (scheduled_runtime(id(irrigation_zone2_next).state.c_str())) { id(irrigation_zone2).turn_on(); } -
But how would you include the for example "soil_moisture state =>' 2" statement into that lambda code?
All reactions
Very cool addition! It sounds like you are on the right track. You need add an "and" to your if statement. It would be something like:
if (scheduled_runtime(id(irrigation_zone1_next).state.c_str()) and irrigation_zone1_soil_moisture.state < 2) {
id(irrigation_zone1).turn_on();
}
P.S. Sorry for the late answer. I hope you figured out the solution already.
Replies: 1 comment 2 replies
Very cool addition! It sounds like you are on the right track. You need add an "and" to your if statement. It would be something like:
if (scheduled_runtime(id(irrigation_zone1_next).state.c_str()) and irrigation_zone1_soil_moisture.state < 2) {
id(irrigation_zone1).turn_on();
}
P.S. Sorry for the late answer. I hope you figured out the solution already.
All reactions
No need for excuses! Your solution works perfectly, thank you!
I found one flaw in the (otherwise rock solid) performance of the controller. If -by whatever event- the power shuts down during an scheduled irrigation, the controller resumes to the state it was in before it was shut down. Except for the remaining time left. Instead of the scheduled duration the duration is set to about 38.000 minutes: the same state a button press would end up in.
This is a serious issue if there isn't any other control mechanism like soil moisture or maximum run time, potentially flooding your lawn (or in my case: indoor green wall and with that, the floor ;))
All reactions
I'm wondering if this is by design. The script carefully stores remaining_time1 and remaining_time1_previous. But do those values survive a reboot?