This is a setup for exterior watering base on soil moisture.
I have d1-mini v3 connected via MQTT, updating from ADC for 30 sec and then going into deep sleep for 60 minutes.
My goal is to trigger a switch (water valve) when the moisture is below a value that I can set from input_number slider
I figured in the sensor I would add something like (haven’t figured it out yet) on_value launch HA automation but looking at HA automation in the “below” field it is expecting a value and not entity value (or I could be wrong)
Then I figure it might be best to just compare from within EspHome and I found this post that is similar to what I want to do. But since I am using MQTT I am not able to have
platform: homeassistant.
What you could do is create a helper (number / slider) and then use that helper in your automation. You then use the helper as your slider to adjust the value.
Yes this is what I did as per the first image on my post, I’ve created a few number sliders for the different zones. Where I am stuck is not knowing which is the best solution and then how to apply it.
I want to compare the ADC values from the sensor with set values in the number sliders and trigger a switch if ADC < set value.
OK for anyone with the same requirements, I have now a working solution. I left the EspHome as is and I made one automation per esp device, this is the working code for one of them:
I could not use the “below” in the trigger but using template is working.
I realize ow that I have a serious problem with my naming convention, as my system is growing I am starting to wonder what is what but that is another future chapter.
Me again…
I am left with a small issue.
Lets say I set the input_number to trigger at 50
If the sensor is at 51 and on the next wake up it goes to 40, the automation will be triggered. All good so far.
However, if I don’t add enough water and the next wake up goes to 49, even if it is still under 50 it will not trigger until if first goes above 50.
How can it trigger always when it wakes up below 50?
Hi,
As a first phase, when the moisture goes down, I trigger the water relays for 3 minutes.
At some point (when I acquire better knowledge) I will create another set of input_numbers to set the time delay of each water relay because my environment includes plants in hanging pots, plants in large boxes under a roof and plants exposed to the weather.
As for what I have now it is near perfect with the only exception that if the automation is triggered, the water relay will turn on but if not enough water to bring the moisture sensor equal or above the threshold, the automation will not happen again. This is confusing and I wonder why it will run only once. I played with the condition mode but makes no difference. There must be some kind of retain/reset somewhere to allow the automation to run everytime the esp wakes up and publish a value that is below the minimum set value.
EDIT: as a side note, my esp sensors are running off batteries so they sleep most of the time.
This sounds like a problem of your own creation. Why use an arbitrary time value that has little correlation to moisture content. Hence the hint to stop using time, and keep the pump running until the desired moisture value it achieved. No retriggers, no weather concerns, a direct correlation.
When the ESP is on it consumes 72mA and when it is in deep sleep it consumes 170uA
I am using Lithium AA batteries
Based on this web site
if I run 30 seconds and sleep 60 minutes the batteries should last 130 days (120 days is plenty)
if I change the run time to 60 seconds, the battery life goes down to 74 days which is not enough.
I pretty much finalized my project and it is working well. As for the small issue I had, it is actually not an issue. As the moisture sensor drops below threshold the pump is activated. It is very unlikely that any amount of water will not bring the moisture level above the threshold so it is no longer an issue.
Thanks to all who participated in this thread, it is awesome to be able to share and exchange opinions and knowledge.