Smart Sprinkler Automation (skip watering if there is rain in next 48 hours - 2 days)

I haven’t upgraded to 0.115.2 yet. I’ll do it today and will let you know.

Just checked and I have the same problem! we need to report the issue.

Issue reported.

Thanks, appreciate that.

Thank you to @arvage and @123 for this post. I’m new to HA (and Python, YAML, Jinja and the template language) so this post helped me a lot in getting my watering system going. I ran into a few problems and I thought I’d share the details in case it helps any other newbies.

The first problem is that (for me) forecast precipitation is always null so the only useful forecast value is condition, I’m using the next 4 days with this code:

  - platform: template
    sensors:
      rainy_day:
        friendly_name: "Rain in next 48 Hours"
        value_template: >-
          {% set p0 = state_attr('weather.openweathermap', 'forecast')[0].condition == 'rainy' %}
          {% set p1 = state_attr('weather.openweathermap', 'forecast')[1].condition == 'rainy' %}
          {% set p2 = state_attr('weather.openweathermap', 'forecast')[2].condition == 'rainy' %}
          {% set p3 = state_attr('weather.openweathermap', 'forecast')[3].condition == 'rainy' %}
          {{ 'Yes' if p0 or p1 or p2 or p3 else 'No' }}

image

forecast precipitation is always null unless there will rain.

I see there is now a PR to have this fixed? https://github.com/home-assistant/core/pull/39839

I put the pull request and they were working on It. Not sure if it’s been applied to the HA yet. I’m getting null on precipitation which is correct for when there is no rain so maybe they did. I have to check.

No, not yet. You can see this by looking at the temperature low forecast, which also and still is “unknown” (same bug, same fix)

This looks rather promising… How can i import the .yaml filesin my home assistant? I tried importing the blue prints but it’s giving me errors.

I’ve got a setup like this where i want to automate the watering, between May and Oktober with a groundwater pump on a smart switch.

This sort of thing should be available to all users! This is where “Blueprints” come in handy. This should be made into a blueprint!

I was using ‘arvage’ logic since last year and worked like a charm until now, when sprinklers season starting, i see error message in HA log as below. Any clue how to fix it?

TemplateError('UndefinedError: None has no element 0') while processing template 'Template<template=({% set p0 = state_attr('weather.openweathermap', 'forecast')[0].condition == "rainy" %} {% set p1 = state_attr('weather.openweathermap', 'forecast')[1].condition == "rainy" %} {{ 'Tak' if p0 and p1 else 'Nie' }}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.czujnik_deszczu'

Hello bazuka,
I stopped using openweathermaps last year as they stopped providing required info. I have to look into their new formats and check if I can figure out what has changed.
Let me know if anyone already have a solution.

Thanks ‘arvage’. If there is any similar solution using other weather forecast app i’m happy to use it. I’m not tide only to openweather - just used it because it worked :slight_smile:

I found that Open-Meteo is a free integration that provides free daily forecast.
you can install it and then create below sensor templates. then you can adjust your automation to deal with the condition. my weather sensor name is home.

template:
#weather forecast daily sensor 
  - trigger:
    - platform: time_pattern
      minutes: /1
    - platform: homeassistant
      event: start
    action:
    - service: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.home
      response_variable: hourly
    sensor:
    - name: Rain Today
      unique_id: rain_today
      state: "{{ hourly['weather.home'].forecast[0].precipitation | int }}"
    - name: Rain Tomorrow
      unique_id: rain_tomorrow
      state: "{{ hourly['weather.home'].forecast[1].precipitation | int }}"

I used precipitation which is returning integer based on how much rain you will get. you can change it to condition to get a text string back and have your automation looks for “rainy”. if you decide to go with condition then use below

template:
#weather forecast daily sensor 
  - trigger:
    - platform: time_pattern
      minutes: /1
    - platform: homeassistant
      event: start
    action:
    - service: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.home
      response_variable: hourly
    sensor:
    - name: Rain Today
      unique_id: rain_today
      state: "{{ hourly['weather.home'].forecast[0].condition }}"
    - name: Rain Tomorrow
      unique_id: rain_tomorrow
      state: "{{ hourly['weather.home'].forecast[1].condition }}"

hope that helps

Many thanks! I will test your solution and observe does it work for me.