Irrigation Unlimited Integration

I’ve had my system up and running well for a couple of days with this automation"

  alias: Rain Sensor
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.rain_2
  condition: []
  action:
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z1
      percentage: "{% if states('binary_sensor.rain_2') == 'on' %}\n    {{ 0 }}\n\
        \  {% else %}\n    {{ 100 }}\n  {% endif %}\n"
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z4
      percentage: "{% if states('binary_sensor.rain_2') == 'on' %}\n    {{ 0 }}\n\
        \  {% else %}\n    {{ 100 }}\n  {% endif %}\n"
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z5
      percentage: "{% if states('binary_sensor.rain_2') == 'on' %}\n    {{ 50 }}\n\
        \  {% else %}\n    {{ 100 }}\n  {% endif %}\n"

When I changed it to add the AND condition:

alias: Rain Sensor
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.rain
  condition: []
  action:
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z1
      percentage: "{% if states('binary_sensor.rain_2') == 'on' && states('input_boolean.rain_sensor_bypass') == 'off' %}\n    {{ 0 }}\n  {%\
        \ else %}\n    {{ 100 }}\n  {% endif %}\n"
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z3
      percentage: "{% if states('binary_sensor.rain_2') == 'on' %}\n    {{ 0 }}\n  {%\
        \ else %}\n    {{ 100 }}\n  {% endif %}\n"
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z4
      percentage: "{% if states('binary_sensor.rain_2') == 'on' %}\n    {{ 0 }}\n  {%\
        \ else %}\n    {{ 100 }}\n  {% endif %}\n"
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z5
      percentage: "{% if states('binary_sensor.rain_2') == 'on' %}\n    {{ 0 }}\n  {%\
        \ else %}\n    {{ 100 }}\n  {% endif %}\n"

I get a Notification

You should check your config in Developer Tools / Template. Just paste the data from the percentage template there and see what error do you get. Also, there should be something in the log about the error. Without that, here is how I would write the config for your first automation. I guess the problem has something to do with ‘&&’ or ‘/n’, but I still haven’t implemented this component to compare.

  alias: Rain Sensor
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.rain_2
  action:
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z1
      percentage: >
        {% if (is_state('binary_sensor.rain', 'on') and is_state('input_boolean.rain_sensor_bypass', 'off')) %}
        {{ 0 }}
        {% else %}
        {{ 100 }}
        {% endif %}

Thank you for your help.
I put your code:

{% if (is_state('binary_sensor.rain_2', 'on') and is_state('input_boolean.rain_sensor_bypass', 'off')) %}
{{ 0 }}
{% else %}
{{ 100 }}
{% endif %}

Into Developer Tools / Template and it worked OK. When I put it into the Automation I had to change it some to get it to work: ???

  alias: Rain Sensor
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.rain_2
  condition: []
  action:
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z1
      percentage: "{% if (is_state('binary_sensor.rain_2', 'on') and is_state('input_boolean.rain_sensor_bypass', 'off')) %}\n    {{ 0 }}\n\
        \  {% else %}\n    {{ 100 }}\n  {% endif %}\n"

I thought I was good to go so I added this to the other zones and the result was opposite of Zone 1. I reverse the minimum ad maximum values and it appears to work. No idea of why this happeened.

	alias: Rain Sensor
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.rain_2
  condition: []
  action:
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z1
      percentage: "{% if (is_state('binary_sensor.rain_2', 'on') and is_state('input_boolean.rain_sensor_bypass', 'off')) %}\n    {{ 0 }}\n\
        \  {% else %}\n    {{ 100 }}\n  {% endif %}\n"
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z4
      percentage: "{% if (is_state('binary_sensor.rain_2', 'on') and is_state('input_boolean.rain_sensor_bypass', 'off')) %}\n    {{ 100 }}\n\
        \  {% else %}\n    {{ 0 }}\n  {% endif %}\n"
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z5
      percentage: "{% if (is_state('binary_sensor.rain_2', 'on') and is_state('input_boolean.rain_sensor_bypass', 'off')) %}\n    {{ 100 }}\n\
        \  {% else %}\n    {{ 50 }}\n  {% endif %}\n"

I’ve installed the component, and I have put your config in my template, and here is the result:

alias: Rain Sensor
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.rain_2
  condition: []
  action:
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z1
      percentage: "\n    100\n  \n"
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z4
      percentage: "\n    0\n  \n"
  - service: irrigation_unlimited.adjust_time
    data:
      entity_id: binary_sensor.irrigation_unlimited_c1_z5
      percentage: "\n    50\n  \n"

Those “\n” at the end of the imaginary lines. I think those are used in C++, not in Jinja. Do you put them there on purpose, or some text editor inserts them there? So if you put only the template in the editor, eg:

{% if (is_state('binary_sensor.rain_2', 'on') and is_state('input_boolean.rain_sensor_bypass', 'off')) %}\n    {{ 0 }}\n\
        \  {% else %}\n    {{ 100 }}\n  {% endif %}\n

The result is:

\n    100\n  \n

It will never work if you get “Result type: string”. Just lose the ‘\n’ and you’re good.

I don’t want to confuse you, it will work without “\n”, but since I will also use the component, here is how that can be done much simpler in YAML:

alias: Rain Sensor
description: ''
trigger:
- platform: state
  entity_id: binary_sensor.rain_2
  to: "on"
action:
- choose:
    - conditions:
        - condition: state
          entity_id: input_boolean.rain_sensor_bypass
          state: 'off'  
      sequence: 
        - service: irrigation_unlimited.adjust_time
          data:
            enitity_id: binary_sensor.irrigation_unlimited_c1_z1
            percentage: 100
        - service: irrigation_unlimited.adjust_time
          data:
            enitity_id: binary_sensor.irrigation_unlimited_c1_z4
            percentage: 0
        - service: irrigation_unlimited.adjust_time
          data:
            enitity_id: binary_sensor.irrigation_unlimited_c1_z5
            percentage: 50

After that, I can continue with something like this:

    - conditions:
        - condition: state
          entity_id: input_boolean.rain_sensor_bypass
          state: 'on'  
      sequence: 
        - service: irrigation_unlimited.adjust_time
          data:
            enitity_id: binary_sensor.irrigation_unlimited_c1_z1
            percentage: 0
        - service: irrigation_unlimited.adjust_time
          data:
            enitity_id: binary_sensor.irrigation_unlimited_c1_z4
            percentage: 0
        - service: irrigation_unlimited.adjust_time
          data:
            enitity_id: by_sensor.irrigation_unlimited_c1_z5
            percentage: 0

Hi, does anyone know how to setup the irrigation unlimited card?

I’ve installed it via HACS.

Here’s my config, but it tells me the custom element doesn’t exist…

type: custom:irrigation-unlimited-card
name: Irrigation unlimited

This has just been added to HACS and finally worked through some deployment issues. Should be good to go now. Forget 2022.4.0, it doesn’t work, maybe even uninstall it. You should see 2022.4.1. The card will appear in the picker when adding. Nothing to configure, just make sure you are using the latest version of Irrigation Unlimited.

It’s early days with this card. Any pull requests are welcome.

Great, have it installed. Thanks. :+1:

And how does it look like. I searched a bit, but didn’t find any screenshots of the new card.

Haven’t had much of a play yet, but it looks like this…

Does anyone know why I’m getting this Warning. I think it might have popup after the this months update.
I’ve all so updated the Average Sensor in HACS just yesterday.

Logger: homeassistant.helpers.template
Source: helpers/template.py:1331
First occurred: May 12, 2022, 17:02:12 (2358 occurrences)
Last logged: 12:25:20

Template warning: 'float' got invalid input 'unknown' when rendering template '{# Threshold variables #} {% set rain_total_threshold = 3.5 %} {% set rain_rate_threshold = 1.0 %} {% set temperature_threshold = 20.0 %} {# Sensor data #} {% set rain_total = states('sensor.irrigation_unlimited_rain_weighted_total') | float %} {% set rain_rate = states('sensor.wupws_preciprate_2') | float %} {% set temperature_average = states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float %} {# Threshold variables #} {% set rain_multiplier = (1 - (rain_total / rain_total_threshold)) %} {% set temperature_multiplier = temperature_average / temperature_threshold %} {% set multiplier = 1.0 %} {% if rain_rate < rain_rate_threshold and rain_multiplier > 0 and rain_total < rain_total_threshold %} {% set multiplier = multiplier * temperature_multiplier %} {% set multiplier = multiplier * rain_multiplier %} {% else %} {% set multiplier = 0.0 %} {# It's raining or enough already #} {% endif %} {# Return multiplier as a percentage #} {{ (multiplier * 100) | round(0) }}' but no default was specified. Currently 'float' will return '0', however this template will fail to render in Home Assistant core 2022.6```

Yes, during HA startup the sensors come online at various stages. Your script is reading them before they are ready, this is common. The message is produced from the float statement below:

states('sensor.irrigation_unlimited_rain_weighted_total') | float

It was unable to convert NaN which is what you get when attempting to read something that is not there. Provide a default to the float expression to make this message go away.

states('sensor.irrigation_unlimited_rain_weighted_total') | float(-1)

Take a look at the updated version of this script here

Thank you for that info. Is that file not updated when I update Irrigation Unlimited in HACS?

No, HACS seem to be limited to the core files in config\custom_components\irrigation_unlimited\*. Installing and updating packages to my knowledge is outside of what it can do. I will look to add comments in the release notes.

1 Like

Hi rgc99
Does the automation in the irrigation_unlimited_adjustment.yaml adjust the irr_unli.time_adjust service in real time or does it wait until the day of watering.
I recently updated (Copied from your repo) the irrigation_unlimited_adjustment.yaml file, My sensor.irrigation_unlimited_rain_weighted_total is changing which is good.
I can adjust the time with the service time adjust.
But has stayed on 100% for the last two cycles since updating.

I might change back to the old copy and see how that goes.
Thanks

# Filename: irrigation_unlimited_adjustment.yaml
#
# This file is a package and should be located in the config/packages
# folder. If you do not have a packages folder then create it and add
# the following to configuration.yaml
#
# homeassistant:
#  packages: !include_dir_named packages
#
# More information on packages can be found at https://www.home-assistant.io/docs/configuration/packages
#
# Set up some observation sensors.
# This uses the Weather Underground (WUnderground) https://www.home-assistant.io/integrations/wunderground/ integration.
# Rain information (wupws_preciptotal) is a daily accumulation total. So we want to grab the
# data just before midnight to get the daily total. We shouldn't be too eager to look after midnight
# because the reset from WU may take a few minutes to come through, currently 10 min. Increase this
# if data is unreliable.
# Note: Requires the ha-average integration to be installed https://github.com/Limych/ha-average

sensor:
  - platform: average
    name: irrigation_unlimited_rain_0
    entities:
      - sensor.wupws_preciptotal
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) }}"
    end: "{{ now() }}"
    scan_interval: 600

  - platform: average
    name: irrigation_unlimited_rain_1
    entities:
      - sensor.wupws_preciptotal
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=1) }}"
    end: "{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=1) }}"
    scan_interval: 600

  - platform: average
    name: irrigation_unlimited_rain_2
    entities:
      - sensor.wupws_preciptotal
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=2) }}"
    end: "{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=2) }}"
    scan_interval: 600

  - platform: average
    name: irrigation_unlimited_rain_3
    entities:
      - sensor.wupws_preciptotal
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=3) }}"
    end: "{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=3) }}"
    scan_interval: 600

  - platform: average
    name: irrigation_unlimited_rain_4
    entities:
      - sensor.wupws_preciptotal
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=4) }}"
    end: "{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=4) }}"
    scan_interval: 600

  - platform: average
    name: irrigation_unlimited_temperature_0
    entities:
      - sensor.wupws_temp
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) }}"
    end: "{{ now() }}"
    scan_interval: 600

  - platform: average
    name: irrigation_unlimited_temperature_1
    entities:
      - sensor.wupws_temp
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=1) }}"
    end: "{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=1) }}"
    scan_interval: 600

  - platform: average
    name: irrigation_unlimited_temperature_2
    entities:
      - sensor.wupws_temp
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=2) }}"
    end: "{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=2) }}"
    scan_interval: 600

  - platform: average
    name: irrigation_unlimited_temperature_3
    entities:
      - sensor.wupws_temp
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=3) }}"
    end: "{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=3) }}"
    scan_interval: 600

  - platform: average
    name: irrigation_unlimited_temperature_4
    entities:
      - sensor.wupws_temp
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=4) }}"
    end: "{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=4) }}"
    scan_interval: 600

  - platform: average
    name: irrigation_unlimited_temperature_5_day_moving_average
    entities:
      - sensor.wupws_temp
    precision: 1
    start: "{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=4) }}"
    end: "{{ now() }}"
    scan_interval: 600

  # Five day weighted rain total sensor.
  # Adjust the weight values (0.7, 0.3, 0.15, 0.05) to suit your needs (0.0 = ignore that day).
  - platform: template
    sensors:
      irrigation_unlimited_rain_weighted_total:
        friendly_name: "Irrigation Unlimited Rain Weighted Total"
        unit_of_measurement: "mm"
        icon_template: "mdi:umbrella"
        value_template: >
          {% set r0 = state_attr('sensor.irrigation_unlimited_rain_0','max_value') | float(-1) %}
          {% set r1 = state_attr('sensor.irrigation_unlimited_rain_1','max_value') | float(-1) %}
          {% set r2 = state_attr('sensor.irrigation_unlimited_rain_2','max_value') | float(-1) %}
          {% set r3 = state_attr('sensor.irrigation_unlimited_rain_3','max_value') | float(-1) %}
          {% set r4 = state_attr('sensor.irrigation_unlimited_rain_4','max_value') | float(-1) %}
          {% if r0 != -1 and r1 != -1 and r2 != -1 and r3 != - 1 and r4 != -1 %}
            {% set rain_total = r0 %}
            {% set rain_total = rain_total + r1 * 0.7 %}
            {% set rain_total = rain_total + r2 * 0.3 %}
            {% set rain_total = rain_total + r3 * 0.15 %}
            {% set rain_total = rain_total + r4 * 0.05 %}
            {{ rain_total | round(1) }}
          {% else %}
            {{ -1 }}
          {% endif %}
    scan_interval: 600

# Automation to adjust the run times for Irrigation Unlimited.
# It uses the 5 day weighted rain total and the moving 5 day average temperature sensors
# created above to generate a variation.
# Adjust rain_total_threshold, rain_rate_threshold and temperature_threshold variables to suit you needs.
automation:
  - alias: Irrigation Unlimited Adjustment
    trigger:
      platform: state
      entity_id:
        - sensor.irrigation_unlimited_rain_weighted_total
        - sensor.irrigation_unlimited_temperature_5_day_moving_average
        - sensor.wupws_preciprate
    action:
      service: irrigation_unlimited.adjust_time
      data:
        entity_id: binary_sensor.irrigation_unlimited_c1_m
        percentage: >
          {# Threshold variables #}
          {% set rain_total_threshold = 3.5 %}
          {% set rain_rate_threshold = 1.0 %}
          {% set temperature_threshold = 20.0 %}
          {# Sensor data #}
          {% set rain_total = states('sensor.irrigation_unlimited_rain_weighted_total') | float(-1) %}
          {% set rain_rate = states('sensor.wupws_preciprate') | float(-1) %}
          {% set temperature_average = states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float(-273) %}
          {# Check if sensor data is valid #}
          {% if rain_total != -1 and rain_rate != -1 and temperature_average and temperature_average != -273 %}
            {# Threshold variables #}
            {% set rain_multiplier = (1 - (rain_total / rain_total_threshold)) %}
            {% set temperature_multiplier = temperature_average / temperature_threshold %}
            {% set multiplier = 1.0 %}
            {% if rain_rate < rain_rate_threshold and rain_multiplier > 0 and rain_total < rain_total_threshold %}
              {% set multiplier = multiplier * temperature_multiplier %}
              {% set multiplier = multiplier * rain_multiplier %}
            {% else %}
              {% set multiplier = 0.0 %} {# It's raining or enough already #}
            {% endif %}
            {# Return multiplier as a percentage #}
            {{ (multiplier * 100) | round(0) }}
          {% else %}
            {{ 100 }}
          {% endif %}

Ok I replace the file with the old on and and its adjusted the time_adjust to 0% which looks to be good with the amount of rain ive had this week.
Maybe I’m missing one of the entities not sure.
anyway i can live with the old copy if i have to.
Thanks

This was changed about 6 months ago. Below is the relevant section that is most likely to cause a problem. Check the three sensors that it is reading (Developer Tools → States). If they cannot be read then the outcome will 100% which is what you are getting. The old code did not have defaults on the float statements and is likely to stop working in the future according to the HA developers.

          {# Sensor data #}
          # *********** Check the values of these three sensors ********************
          {% set rain_total = states('sensor.irrigation_unlimited_rain_weighted_total') | float(-1) %}
          {% set rain_rate = states('sensor.wupws_preciprate') | float(-1) %}
          {% set temperature_average = states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float(-273) %}
          # ******************************************************************************

          {# Check if sensor data is valid #}
          {% if rain_total != -1 and rain_rate != -1 and temperature_average and temperature_average != -273 %}
            {# Threshold variables #}
            {% set rain_multiplier = (1 - (rain_total / rain_total_threshold)) %}
            {% set temperature_multiplier = temperature_average / temperature_threshold %}

            {% set multiplier = 1.0 %}
            {% if rain_rate < rain_rate_threshold and rain_multiplier > 0 and rain_total < rain_total_threshold %}
              {% set multiplier = multiplier * temperature_multiplier %}
              {% set multiplier = multiplier * rain_multiplier %}
            {% else %}
              {% set multiplier = 0.0 %} {# It's raining or enough already #}
            {% endif %}

            {# Return multiplier as a percentage #}
            {{ (multiplier * 100) | round(0) }}
          {% else %}
            {{ 100 }}
          {% endif %}

Thank you
I found out what I had done wrong. I’ve never actually had the precipRate entity in my config.
So all this time the old automation was calculating on just the rain_total and the temperature_average and was still adjusting the time.
Another noob mistake of mine.
Thanks again for your help

It was probably implicitly setting a value of 0. This is why you must have explicit defaults now as it was a big source of bugs. There is a new version of this automation available which has some enhancements. The first is an id: so you can use all the new automation trace tools on it. A selection of triggers to choose from. Checks the sensors have been setup correctly and some comments about what you want to adjust. You will need to change the action part to suit you needs and it no longer assumes any configuration, which in itself was causing problems.

My Irrigation Unlimited was working great until I updated to Home Assistant 2022.6. The schedules didn’t show up on the UI and no irrigation was preformed. When I restored the backup to Home Assistant 2022.5 Irrigation Unlimited was working fine. Is anyone else having this problem?