Plant Irrigation Control

Please help a newbie.

I’ve installed HA and also installed Sonoff Lan to control my eWelink micro controller that triggers solenoids to come on for a small duration on various times of the day.

I would like to automate this so that it does not come on the day and the next day if it is predicted to rain the next day.

Maybe there is already a topic on this but I tried looking for one and could not find it.

Hope I am making sense.

Thanks in advance
Norbert D’Souza

Wouldn’t it be better to use real data instead of predictions? I live in an area where rain-prediction is horrible and this may lead to no irrigation for days even if no rain.
Why not measure actual rainfall and based on current-rain or last-rain-datetime…do nothing for xyx hours?

EDIT: you could also try to install moisture sensors and base it on that?

Hi @vingerha,

Thank you so much for replying. I tried using moisture sensors and found that they are less reliable than rain-prediction (I live in Melbourne).

You are absolutely right and I am glad I brought this up here as I was thinking differently from you. Yes I should be measuring actual current rainfall and base my actions based on that.

Is there any previous discussion here on how this can be achieved?

Once again, thanks heaps for changing my line of thought.

So you need to get the state of rain…
Do you have a rain-sensor or does your weather authority provide reliable ‘past-rain’ data?

There is a current thread on DIY rainsensor
:umbrella: DIY Zigbee rain gauge - Share your Projects! - Home Assistant Community (home-assistant.io)

Thank you @vingerha,

As a newbie, I would like to try using the Forecast by Met.no integration first, and slowly migrate to sensors as electronics is not my forté.

Understood but that may be less easy than you think.
The forecast may have entries alike (per hour) rain - no rain - lot of rain - no rain…etc.
How to choose your actions based on that? Example, if the first ‘hit’ is rain and then many hours of no rain, then this may actually be interpreted as ‘no rain’. I know I am not making it easy but trying to find out with what you are happy (enough) with. I have no clue if Met. no provides mm (inch) rainfall predicitons?

EDIT: a rain sensor can also be a simple water-leak sensor that registers ‘water’ and you could even place/glue it in a glass/cup on a certain height so that it only triggers from a minimum amount of rain.

Датчик Утечки Воды | Water Sensor Zigbee Smart Life - Leakage Sensor - Aliexpress

Met.no has something called precipitation. Not 100% sure but I think its a measure of the amount of rainfall received or expected to receive?

let me try to install this on my dev…

So what you could do is measure the predicted future rainfall, alike this (I am no jinja expert so this may be done in a nicer way)

{% set fc = state_attr('weather.forecast_home_3','forecast') %}
{% set ns = namespace(total=0) %}
{% for i in range(0,fc|count) %}
{% set ns.total = ns.total + fc[i].precipitation %}
{% endfor %}
{{ns.total}}

for Melbourne this now gives (me) 4.8 mm
If you create a template sensor with that, you can then use the forecasted mm to steer your irrigation.

Thank you so much @vingerha.

Its quite late here, but if its ok with you I will pick your brain tomorrow after trying this out…

Of course, in the meantime… suggestion for rainfall sensor, you need to change the weater…home to match yours.

sensor:
  - platform: template
    sensors:
      forecast_precipitation:
        friendly_name: "Forecasted Precipiation"
        value_template: "{{ state_attr('weather.forecast_home','forecast') | sum(attribute='precipitation') }}"

with the state of above sensor you can run an automation that triggers the valves for a specific length…that is something you have to define yourselves

Where do I put this code?

Sorry if this sounds very basic but the fact is that I am absolutely new to this.

As this editing (adding template sensors) will happen quite a lot, you need to get up to speed youselves. Do read into the docs
Template - Home Assistant (home-assistant.io)

I modified it a bit so that it matches above doc, there are multiple ways of doing this hence

template:
  - sensor:
      - name: "Forecast Precipitation"
        state: "{{ state_attr('weather.forecast_home','forecast') | sum(attribute='precipitation') }}"

Copy into your configuration.yaml, beware of proper indentation as per above, always 2 spaces, python it picky

After copy/paste, you can try devtools > yaml (tab) and load it (or restart HA)