Irrigation Unlimited Integration

Add a schedule_id: to your schedule. It must be in snake_case like morning, night, before_sunrise, after_dark etc. It must be unique within all schedules (across controllers, zones, and sequences). Checks are done on startup and a warning message will be produced.

irrigation_unlimited:
  ...
    sequences:
      - name: "Est"
        delay: "00:00:05"
        schedules:
          - time: "14:45"
            schedule_id: "some_identifier"
  ...
    sequences:
      - schedules:
          - time: "15:00"
            schedule_id: "some_other_identifier"

Now you can use:

service: irrigation_unlimited.load_schedule
data:
  schedule_id: "some_identifier"
  time: "13:00:00"

I have a number of Zigbee devices some are power points which present as switch yet others present in the light domain. It think divirg is correct, it is just the way it has been implemented.

1 Like

I guess you mean schedule_id. I just checked it works. Thank you
Maybe I overlooked it, but I do not see any reference to schelude_id in the documentation.

1 Like

So I need to buy you a coffee at least :slight_smile: .

It works great beside the typo as suggested by @kolia

Can I have some hints also about the check_back object? Can I just put it under the “all_zones_config:”?
(Edit: tried and works great)

This is also a great feature, nice job!

Yes I did mean schedule_id, example fixed. Have updated the documentation.

2 Likes

Heads-up to all. Install Irrigation Unlimited version 2023.8.0 before updating Home Assistant to 2023.8.0 or above. A change was made to HA core that will prevent the integration from starting.

1 Like

Good evening @rgc99 and colleagues,

thank you, a lot, for this great work an this nice integration.
I’m trying to use it with my RC2 controller by Rain Bird and to set up home assistant to do the irrigation in a smart way.

This is my configuration:

irrigation_unlimited:
  controllers:
    - name: "Rain Bird RC2"
      enabled: true
      zones:
        - name: "Rasen Eingang"
          enabled: true
          entity_id: "switch.rain_bird_z1_rasen_eingang"
        - name: "Rasen Feige"
          enabled: true
          entity_id: "switch.rain_bird_z2_rasen_feige"
        - name: "Rasen Magnolie"
          enabled: true
          entity_id: "switch.rain_bird_z3_rasen_magnolie"
        - name: "Rasen vorne"
          enabled: true
          entity_id: "switch.rain_bird_z4_rasen_vorne"
        - name: "Rasen hinten"
          enabled: true
          entity_id: "switch.rain_bird_z5_rasen_hinten"
        - name: "Hecken Treppe"
          enabled: true
          entity_id: "switch.rain_bird_z6_hecken_treppe"
        - name: "Beet oben"
          enabled: true
          entity_id: "switch.rain_bird_z7_beet_oben"
        - name: "Beet unten"
          enabled: true
          entity_id: "switch.rain_bird_z8_beet_unten"
      sequences:
        - name: "Rasen"
          enabled: true
          schedules:
            - time: "06:00"
              duration: "00:50"
          zones:
            - zone_id: 1
              enabled: true
              duration: "00:10"
            - zone_id: 2
              enabled: true
              duration: "00:10"
            - zone_id: 3
              enabled: true
              duration: "00:10"
            - zone_id: 4
              enabled: true
              duration: "00:10"
            - zone_id: 5
              enabled: true
              duration: "00:10"
        - name: "Beete"
          enabled: true
          schedules:
            - time: "05:00"
              duration: "01:00"
          zones:
            - zone_id: 6
              enabled: true
              duration: "00:20"
            - zone_id: 7
              enabled: true
              duration: "00:20"
            - zone_id: 8
              enabled: true
              duration: "00:20"

Furthermore, I want to use/adopt the automation provided here: https://github.com/rgc99/irrigation_unlimited/blob/7b579a2e8c3807f9dd61702933b218ae1a2f8d79/packages/irrigation_unlimited_adjustment.yaml

Since I do not have a PWS, I replaced the corresponding sensors with sensors provided for my coordinates by OpenWeatherMap integration (OpenWeatherMap - Home Assistant).

  • sensor.wupws_preciptotalsensor.wetter_forecast_precipitation
    (forecast precipitation for the day)

  • sensor.wupws_tempsensor.wetter_temperature
    (forecast current temperature)

  • sensor.wupws_precipratesensor.wetter_hourly_forecast_precipitation
    (forecast precipitation for the present hour)

This results in:

sensor:
  - platform: average
    name: irrigation_unlimited_rain_0
    entities:
      - sensor.wetter_forecast_precipitation
    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.wetter_forecast_precipitation
    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.wetter_forecast_precipitation
    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.wetter_forecast_precipitation
    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.wetter_forecast_precipitation
    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.wetter_temperature
    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.wetter_temperature
    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.wetter_temperature
    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.wetter_temperature
    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.wetter_temperature
    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.wetter_temperature
    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:
  - id: 'IU1653340123453'
    alias: Irrigation Unlimited Adjustment
    trigger:
      # -------------------------------------------------------------------
      # Choose how you want to trigger this automation.
      # Comment out/delete/change as required.
      # -------------------------------------------------------------------
      # Run at a fixed time
      - platform: time
        at: "02:00"
      # Run when Home Assistant starts
      - platform: homeassistant
        event: start
      # Run when the sensors update. Don't use this option if any of your
      # schedules use the 'anchor: finish'. It will most likely cause the
      # system to skip. Use a fixed time.
      - platform: state
        entity_id:
          - sensor.irrigation_unlimited_rain_weighted_total
          - sensor.irrigation_unlimited_temperature_5_day_moving_average
          - sensor.wetter_hourly_forecast_precipitation
    condition:
      condition: and
      conditions:
        - "{{ states('sensor.irrigation_unlimited_rain_weighted_total') | float(-1) != -1 }}"
        - "{{ states('sensor.wetter_hourly_forecast_precipitation') | float(-1) != -1 }}"
        - "{{ states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float(-273) != -273 }}"
    action:
      service: irrigation_unlimited.adjust_time
      data:
        # -------------------------------------------------------------------
        # Please see documentation regarding the adjust_time service call.
        # Choose an option below. Comment out/delete/change as needed.
        # *** This will NOT work as is. ***
        # 1. Adjust a single zone. Change the zone as required
        # entity_id: binary_sensor.irrigation_unlimited_c1_z1
        # 2. Adjust a sequence. Change the sequence_id as required
        entity_id: binary_sensor.irrigation_unlimited_c1_m
        # sequence_id: 1
        # -------------------------------------------------------------------
        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.wetter_hourly_forecast_precipitation') | float(-1) %}
          {% set temperature_average = states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float(-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) }}

Now I’m experiencing issues and/or have questions:

  1. The automation above does not work. The template at the end results in percentage 0, which is fine since we had several very rainy days (and when manually setting the sensors, the outcome changes correctly to values >0). However, the service irrigation_unlimited.adjust_time does not work with 0 % in my case. Anything above 0 is fine (e.g. 1-200%). Same behavior when starting the service from the developer tooles my manually entering 0 %. With 0 as a value for percentage, simply nothing happens.

  2. In the documentation it says, for the adjust_time service sequence_id is not necessarily required. I thought, when not entering this ID, all sequences of the selected controller will be affected (in my case 2 sequences; see above the configuration). However, only sequence 1 is affected. How can I apply this to both of my 2 sequences with a single call of the adjust_time service?

  3. A local rain sensor (binary sensor: on=rain, off=no rain) is connected to my Rain Bird controller. It’s kind of a humidity sensor containing a sponge (therefore status on remains much longer than the rain itself). I would like to integrate this sensor in the automation above as an local addition to the forecast based algorithm. If the sensor is on, no irrigation should start. When it is off, irrigation and adjustment should work as scheduled.

This is my frontend after manually setting sequence 2 to 55% adjustment (by calling service using developer tools):

Manually setting sequence 2 back to 0% adjustment doesn’t change anything.

Interestingly, output of the controller binary_sensor.irrigation_unlimited_c1_m doens’t exactly match the frontend:

index: 0
enabled: true
status: 'off'
zone_count: 8
zones: ''
sequence_status:
  - index: 0
    name: Rasen
    enabled: true
    status: 'off'
    icon: mdi:stop-circle-outline
    start: null
    duration: 0
    adjustment: '%0.0'
    schedule:
      index: null
      name: null
    zones:
      - index: 0
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '1'
      - index: 1
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '2'
      - index: 2
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '3'
      - index: 3
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '4'
      - index: 4
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '5'
  - index: 1
    name: Beete
    enabled: true
    status: 'off'
    icon: mdi:stop-circle-outline
    start: '2023-08-08T05:00:00+02:00'
    duration: 1980
    adjustment: '%55.0'
    schedule:
      index: 0
      name: Schedule 1
    zones:
      - index: 0
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 660
        adjustment: ''
        zone_ids:
          - '6'
      - index: 1
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 660
        adjustment: ''
        zone_ids:
          - '7'
      - index: 2
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 660
        adjustment: ''
        zone_ids:
          - '8'
current_schedule: deprecated (use current_zone)
current_zone: not running
percent_complete: 0
next_zone: 6
next_name: Hecken Treppe
next_start: '2023-08-08T05:00:00+02:00'
next_duration: '0:11:00'
icon: mdi:water-off
friendly_name: Rain Bird RC2

E.g. adjustment of zones 1-5 is 55% when looking at their single sensors, but the controller status (see above) says 0%.

Hope I made it to communicate my ideas in a comprehensible way :slight_smile:

All the best and kind regards
Benedikt

  1. Zero percent of anything is 0. Setting the duration to zero I would expect nothing to turn on. This is another way of disabling irrigation.
  2. Please be aware there are three adjustment points in the system.
    a. The first is on a zone entity which is better used when sequences are not required. Here you do not specify a sequence_id. If the entity_id is the controller then it loops through all the zones and applies the same adjustment.
    b. The second is on an entire sequence. Now you specify a sequence_id and the entity_id must be the controller. The sequence_id can be 0 which is a wild card. Each sequence zone within the sequence will be proportioned accordingly.
    c. The third is on a zone within a sequence. Once again specify the sequence_id as above but also a list of zones you would like to adjust. Zones from one sequence do not effect zones from another. This adjustment will combine with (b) above so if the sequence is 200% and the sequence zone is 50% you will in effect get 100%.
  3. See item 1. Change the script to set the adjustment to 0% if the rain sensor is on.

I would reset the various adjustments and start with a clean slate.

Hi @rgc99 , thank you for the fast answers!

This is what I expected (and would like) to happen. But, however, running the service adjust_time with the value 0 results in no change. When setting precentage to any other value, it works fine. When trying to reset to 0, like the current wheather-based automation does, nothing changes and (in both the custom frintend card and the status of the controller) the former value (e.g. 55% adjustment) remains active.

→ This is currently my major issue

After restarting HA, this is how the frontend looks like:

Shouldn’t the frontend show “0%” (due to adjustment automation running at startup with weather-based outcome 0%)?

This is the status of the controller binary_sensor.irrigation_unlimited_c1_m:

index: 0
enabled: true
status: 'off'
zone_count: 8
zones: ''
sequence_status:
  - index: 0
    name: Rasen
    enabled: true
    status: 'off'
    icon: mdi:stop-circle-outline
    start: null
    duration: 0
    adjustment: '%0.0'
    schedule:
      index: null
      name: null
    zones:
      - index: 0
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '1'
      - index: 1
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '2'
      - index: 2
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '3'
      - index: 3
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '4'
      - index: 4
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '5'
  - index: 1
    name: Beete
    enabled: true
    status: 'off'
    icon: mdi:stop-circle-outline
    start: null
    duration: 0
    adjustment: '%0.0'
    schedule:
      index: null
      name: null
    zones:
      - index: 0
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '6'
      - index: 1
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '7'
      - index: 2
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 0
        adjustment: ''
        zone_ids:
          - '8'
current_schedule: deprecated (use current_zone)
current_zone: not running
percent_complete: 0
next_schedule: deprecated (use next_zone)
next_zone: none
icon: mdi:water-off
friendly_name: Rain Bird RC2

When running

service: irrigation_unlimited.adjust_time
data:
  entity_id: binary_sensor.irrigation_unlimited_c1_m
  sequence_id: 0
  percentage: 15

it looks like:

and

index: 0
enabled: true
status: 'off'
zone_count: 8
zones: ''
sequence_status:
  - index: 0
    name: Rasen
    enabled: true
    status: 'off'
    icon: mdi:stop-circle-outline
    start: '2023-08-09T06:00:00+02:00'
    duration: 450
    adjustment: '%15.0'
    schedule:
      index: 0
      name: Schedule 1
    zones:
      - index: 0
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 90
        adjustment: ''
        zone_ids:
          - '1'
      - index: 1
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 90
        adjustment: ''
        zone_ids:
          - '2'
      - index: 2
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 90
        adjustment: ''
        zone_ids:
          - '3'
      - index: 3
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 90
        adjustment: ''
        zone_ids:
          - '4'
      - index: 4
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 90
        adjustment: ''
        zone_ids:
          - '5'
  - index: 1
    name: Beete
    enabled: true
    status: 'off'
    icon: mdi:stop-circle-outline
    start: '2023-08-09T05:00:00+02:00'
    duration: 540
    adjustment: '%15.0'
    schedule:
      index: 0
      name: Schedule 1
    zones:
      - index: 0
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 180
        adjustment: ''
        zone_ids:
          - '6'
      - index: 1
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 180
        adjustment: ''
        zone_ids:
          - '7'
      - index: 2
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 180
        adjustment: ''
        zone_ids:
          - '8'
current_schedule: deprecated (use current_zone)
current_zone: not running
percent_complete: 0
next_zone: 6
icon: mdi:water-off
friendly_name: Rain Bird RC2
next_name: Hecken Treppe
next_start: '2023-08-09T05:00:00+02:00'
next_duration: '0:03:00'

Which seems to be perfectly fine.

When running back to zero percent

service: irrigation_unlimited.adjust_time
data:
  entity_id: binary_sensor.irrigation_unlimited_c1_m
  sequence_id: 0
  percentage: 0

this results in no changes at all:

index: 0
enabled: true
status: 'off'
zone_count: 8
zones: ''
sequence_status:
  - index: 0
    name: Rasen
    enabled: true
    status: 'off'
    icon: mdi:stop-circle-outline
    start: '2023-08-09T06:00:00+02:00'
    duration: 450
    adjustment: '%15.0'
    schedule:
      index: 0
      name: Schedule 1
    zones:
      - index: 0
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 90
        adjustment: ''
        zone_ids:
          - '1'
      - index: 1
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 90
        adjustment: ''
        zone_ids:
          - '2'
      - index: 2
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 90
        adjustment: ''
        zone_ids:
          - '3'
      - index: 3
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 90
        adjustment: ''
        zone_ids:
          - '4'
      - index: 4
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 90
        adjustment: ''
        zone_ids:
          - '5'
  - index: 1
    name: Beete
    enabled: true
    status: 'off'
    icon: mdi:stop-circle-outline
    start: '2023-08-09T05:00:00+02:00'
    duration: 540
    adjustment: '%15.0'
    schedule:
      index: 0
      name: Schedule 1
    zones:
      - index: 0
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 180
        adjustment: ''
        zone_ids:
          - '6'
      - index: 1
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 180
        adjustment: ''
        zone_ids:
          - '7'
      - index: 2
        enabled: true
        status: 'off'
        icon: mdi:stop-circle-outline
        duration: 180
        adjustment: ''
        zone_ids:
          - '8'
current_schedule: deprecated (use current_zone)
current_zone: not running
percent_complete: 0
next_zone: 6
icon: mdi:water-off
friendly_name: Rain Bird RC2
next_name: Hecken Treppe
next_start: '2023-08-09T05:00:00+02:00'
next_duration: '0:03:00'

Why does this happen and how can I visually differenciate between adjustment to 0% (if it would work) and no schedule at all (like it looks like after startup as shown above)?

When I do not specify a sequence_id and I’m using my controller as entity_id, changes apply to sequence 1, not to sequence 2 or the zones included in sequence 2 (at least in the frontend). However, setting sequence_id to 0 solved the problem for me.

Could you please help me including this in the automation?

Thank you, a lot, for helping me!

Kind regards
Benedikt

Hi Benedikt,

I think we should move items 1 & 2 back to issue 132 for deeper analysis.

Here is an idea for adding in the rain sensor. This is untested and the assumption is binary_sesnor.rain_bird_my_rain_sensor. Tweak as required.

# 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:
  - id: 'IU1653340123453'
    alias: Irrigation Unlimited Adjustment
    trigger:
      # -------------------------------------------------------------------
      # Choose how you want to trigger this automation.
      # Comment out/delete/change as required.
      # -------------------------------------------------------------------
      # Run at a fixed time
      - platform: time
        at: "02:00"
      # Run when Home Assistant starts
      - platform: homeassistant
        event: start
      # Run when the sensors update. Don't use this option if any of your
      # schedules use the 'anchor: finish'. It will most likely cause the
      # system to skip. Use a fixed time.
      - platform: state
        entity_id:
          - sensor.irrigation_unlimited_rain_weighted_total
          - sensor.irrigation_unlimited_temperature_5_day_moving_average
          - sensor.wetter_hourly_forecast_precipitation
          - binary_sensor.rain_bird_my_rain_sensor
    condition:
      condition: and
      conditions:
        - "{{ states('sensor.irrigation_unlimited_rain_weighted_total') | float(-1) != -1 }}"
        - "{{ states('sensor.wetter_hourly_forecast_precipitation') | float(-1) != -1 }}"
        - "{{ states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float(-273) != -273 }}"
        - "{{ states('binary_sensor.rain_bird_my_rain_sensor') | float(-1) != -1 }}"
    action:
      service: irrigation_unlimited.adjust_time
      data:
        # -------------------------------------------------------------------
        # Please see documentation regarding the adjust_time service call.
        # Choose an option below. Comment out/delete/change as needed.
        # *** This will NOT work as is. ***
        # 1. Adjust a single zone. Change the zone as required
        # entity_id: binary_sensor.irrigation_unlimited_c1_z1
        # 2. Adjust a sequence. Change the sequence_id as required
        entity_id: binary_sensor.irrigation_unlimited_c1_m
        # sequence_id: 1
        # -------------------------------------------------------------------
        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.wetter_hourly_forecast_precipitation') | float(-1) %}
          {% set temperature_average = states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float(-273) %}
          {% set rain_sensor = is_state('binary_sensor.rain_bird_my_rain_sensor', 'off')}

          {# Threshold variables #}
          {% set rain_multiplier = (1 - (rain_total / rain_total_threshold)) %}
          {% set temperature_multiplier = temperature_average / temperature_threshold %}

          {% set multiplier = 1.0 %}
          {% if rain_sensor and 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) }}

Thank you, seems to work perfect!

There was just one little typo:
{% set rain_sensor = is_state('binary_sensor.rain_bird_my_rain_sensor', 'off') %}

Now, when it’s possible to fix the issue with adjusting time to 0%, I’m perfectly fine :slight_smile:

I’ve a question regarding this line?
What is it for?

It is to make sure the sensor is available. The float(-1) casts the value but has a default value in case the sensor is not available for whatever reason; off-line, still starting up etc. The -1 value is not a valid sensor value so it must be the default value and therefore the sensor is not available.
Automations will throw an error if you attempt to use sensors that are not available so you need to always check.

Since 2023.04, template features a new function: has_value. Does it serves the same purpose?

I unterstand. But in that case, the outcome is always “false” (regardless the value of the binary sensor on or off) and the automation will never run…

As noted this is untested, however the assumption is false will cast to 0 and true to 1 and -1 will come into play if the sensor is unavailable. So if the value is not -1 then the sensor is working.

I think you are correct. A better way to test for sensor availability.

Hi @rgc99, thank you for the help. It’s running great an the meantime!

I noticed something weird, when setting up notifications.

This is my automation to be fired at start and finish of a sequence:

alias: Irrigation Unlimited Benachrichtigung
description: ""
trigger:
  - platform: event
    event_type: irrigation_unlimited_start
    id: start
  - platform: event
    event_type: irrigation_unlimited_finish
    id: finish
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: irrigation_stop
    id: stop
condition: []
action:
  - if:
      - condition: trigger
        id:
          - start
          - finish
    then:
      - service: notify.mobile_app_sm_g990b
        data:
          title: >-
            Die Bewässerung wurde {{ 'gestartet' if trigger.id =='start' else
            'beendet' }}
          message: >
            Zeit: {{ as_local(trigger.event.time_fired).strftime('%A, %d.%m.%y
            %H:%M') | replace("Monday", "Montag") | replace("Wednesday",
            "Mittwoch") }}

            Programm: {{ trigger.event.data.sequence.name }}

            Auslöser: {% if trigger.event.data.schedule.index is integer %}{{
            trigger.event.data.schedule.name }}{% else %}Manuell{% endif %}

            Dauer: {{ timedelta(seconds=trigger.event.data.run.duration) }}

            Adjustierung: {{ states('sensor.irrigation_adjustment') }}%
          data:
            clickAction: /dashboard-garten/garten
            tag: irrigation
            actions:
              - action: irrigation_stop
                title: Bewässerung abbrechen
  - if:
      - condition: trigger
        id:
          - stop
    then:
      - service: irrigation_unlimited.cancel
        data:
          entity_id: binary_sensor.irrigation_unlimited_c1_m
mode: single

This works great when starting a sequence:

However, when finishing a sequence, my smartphone doesn’t receive any notification. Interestedly, in the logs everything looks fine and the notification was successfully fired by the automation. In the notification list of my smartphone, nothing is visible except for notifications when starting a sequence and other notifications not related to irrigation. I’m wondering, since starting notifications are received 100%, and finishing notifications 0%.

Has anyone experienced this?
In my case it’s even the same automation and notification…


Logs: Seems to be successful





Everything seems to work like it should…


…but no finishing notifications received.

Any idea?

All the best and thank you for the kind help
Benedikt

I am wondering if part of the trigger.event.data is missing on a finish. Perhaps just hard code a simple “hello world” message to see it works.

But doesn’t it look like everything should have worked properly in my logs? This is what makes me wonder…

In the meantime, without any changes, notification at finish event worked the last 2-3 times.

Another observation is, that start and finish events are fired in situations that are not scheduled and I cannot find the reason.

This is my current configuration:

irrigation_unlimited:
  controllers:
    - name: "Rain Bird RC2"
      enabled: true
      zones:
        - name: "Rasen Eingang"
          enabled: true
          entity_id: "switch.rain_bird_z1_rasen_eingang"
          zone_id: "1"
        - name: "Rasen Feige"
          enabled: true
          entity_id: "switch.rain_bird_z2_rasen_feige"
          zone_id: "2"
        - name: "Rasen Magnolie"
          enabled: true
          entity_id: "switch.rain_bird_z3_rasen_magnolie"
          zone_id: "3"
        - name: "Rasen vorne"
          enabled: true
          entity_id: "switch.rain_bird_z4_rasen_vorne"
          zone_id: "4"
        - name: "Rasen hinten"
          enabled: true
          entity_id: "switch.rain_bird_z5_rasen_hinten"
          zone_id: "5"
        - name: "Hecken Treppe"
          enabled: true
          entity_id: "switch.rain_bird_z6_hecken_treppe"
          zone_id: "6"
        - name: "Beet oben"
          enabled: true
          entity_id: "switch.rain_bird_z7_beet_oben"
          zone_id: "7"
        - name: "Beet unten"
          enabled: true
          entity_id: "switch.rain_bird_z8_beet_unten"
          zone_id: "8"
      sequences:
        - name: "Rasen"
          enabled: true
          schedules:
            - time: "06:00"
              weekday: [mon, wed, fri]
              duration: "01:50"
          zones:
            - zone_id: 5
              enabled: true
              duration: "00:25"
            - zone_id: 4
              enabled: true
              duration: "00:25"
            - zone_id: 3
              enabled: true
              duration: "00:20"
            - zone_id: 2
              enabled: true
              duration: "00:20"
            - zone_id: 1
              enabled: true
              duration: "00:20"
        - name: "Beete"
          enabled: true
          schedules:
            - time: "05:00"
              weekday: [tue, thu, sat]
              duration: "02:15"
          zones:
            - zone_id: 6
              enabled: true
              duration: "00:45"
            - zone_id: 7
              enabled: true
              duration: "00:45"
            - zone_id: 8
              enabled: true
              duration: "00:45"

This is my adjustment automation:

template:
  - trigger:
      - platform: time
        at: input_datetime.irrigation_adjustment_1
      - platform: time
        at: input_datetime.irrigation_adjustment_2
      - platform: homeassistant
        event: start
      - platform: state
        entity_id:
          - input_number.pop
          - input_number.prec
          - input_boolean.bypass_rainsensor
          - input_boolean.bypass_suspension
          - input_boolean.bypass_adjustment
    sensor:
      - name: irrigation_adjustment
        state: >
          {% set rain_multiplier = states('sensor.rain_multiplier') | float(-1) %}
          {% set temperature_multiplier = states('sensor.temperature_multiplier') | float(-1) %}
          {% set multiplier = rain_multiplier * temperature_multiplier %}
          {{ (multiplier * 100) | round(0) }}
        unit_of_measurement: "%"
    binary_sensor:
      - name: irrigation_suspend
        state: >
          {% set forecast_pop = states('sensor.wetter_forecast_precipitation_probability') | float(-1) %}
          {% set threshold_pop = states('input_number.pop') | float(-1) %}
          {% set forecast_prec = states('sensor.wetter_forecast_precipitation') | float(-1) %}
          {% set threshold_prec = states('input_number.prec') | float(-1) %}
          {% if forecast_pop < threshold_pop or forecast_prec < threshold_prec %}
            {{ 'off' }}
          {% else %}
            {{ 'on' }}
          {% endif %}

automation:
  - id: 'IU1653340123453'
    alias: Irrigation Unlimited Adjustment
    trigger:
      - platform: homeassistant
        event: start
      - platform: state
        entity_id:
          - sensor.irrigation_adjustment
          - binary_sensor.irrigation_suspend
          - binary_sensor.rainsensor
          - input_boolean.bypass_rainsensor
          - input_boolean.bypass_suspension
          - input_boolean.bypass_adjustment
    condition:
      condition: and
      conditions:
        - "{{ has_value('sensor.irrigation_adjustment') }}"
        - "{{ has_value('binary_sensor.rainsensor') }}"
        - "{{ has_value('binary_sensor.irrigation_suspend') }}"
        - "{{ has_value('input_boolean.bypass_rainsensor') }}"
        - "{{ has_value('input_boolean.bypass_suspension') }}"
        - "{{ has_value('input_boolean.bypass_adjustment') }}"
    action:
      service: irrigation_unlimited.adjust_time
      data:
        entity_id: binary_sensor.irrigation_unlimited_c1_m
        sequence_id: 0
        percentage: >
          {% set adjustment = states('sensor.irrigation_adjustment') | int %}
          {% set suspension = is_state('binary_sensor.irrigation_suspend', 'off') %}
          {% set rain_sensor = is_state('binary_sensor.rainsensor', 'off') %}
          {% set rain_sensor_bypass = is_state('input_boolean.bypass_rainsensor', 'on') %}
          {% set rain_adjustment_bypass = is_state('input_boolean.bypass_adjustment', 'off') %}
          {% set rain_suspension_bypass = is_state('input_boolean.bypass_suspension', 'on') %}

          {% if (rain_sensor or rain_sensor_bypass) and rain_adjustment_bypass and (rain_suspension_bypass or suspension) %}
            {% set percentage = adjustment %}
          {% elif rain_adjustment_bypass is false and (rain_sensor or rain_sensor_bypass) and (rain_suspension_bypass or suspension) %}
            {% set percentage = 100 %}
          {% else %}
            {% set percentage = 0 %}
          {% endif %}

          {{ percentage }}

with input_datetime.irrigation_adjustment_1 set to 02:00 and input_datetime.irrigation_adjustment_2 set to 16:00

The dashboard looks like this:

This is my notification automation:

alias: Irrigation Unlimited Benachrichtigung
description: ""
trigger:
  - platform: event
    event_type: irrigation_unlimited_start
    id: start
  - platform: event
    event_type: irrigation_unlimited_finish
    id: finish
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: irrigation_stop
    id: stop
condition: []
action:
  - if:
      - condition: trigger
        id:
          - start
          - finish
    then:
      - service: notify.mobile_app_sm_g990b
        data:
          title: >-
            Die Bewässerung wurde {{ 'gestartet' if trigger.id =='start' else
            'beendet' }}
          message: >
            Zeit: {{ as_local(trigger.event.time_fired).strftime('%A, %d.%m.%y
            %H:%M') | replace("Monday", "Montag") | replace("Wednesday",
            "Mittwoch") | replace("Tuesday", "Dienstag") | replace("Thursday",
            "Donnerstag") | replace("Friday", "Freitag") | replace("Saturday",
            "Samstag") | replace("Sunday", "Sonntag") }}

            Programm: {{ trigger.event.data.sequence.name }}

            Auslöser: {% if trigger.event.data.schedule.index is integer %}{{
            trigger.event.data.schedule.name }}{% else %}Manuell{% endif %}

            Dauer: {{ timedelta(seconds=trigger.event.data.run.duration) }} ({{
            states('sensor.irrigation_adjustment') }}%)
          data:
            clickAction: /dashboard-garten/garten
            tag: irrigation
            actions:
              - action: irrigation_stop
                title: Bewässerung abbrechen
  - if:
      - condition: trigger
        id:
          - stop
    then:
      - service: irrigation_unlimited.cancel
        data:
          entity_id: binary_sensor.irrigation_unlimited_c1_m
mode: single

Today, something weird happened again with a faulty notification, fired at 16:00 according to input_datetime.irrigation_adjustment_2

However, there was no irrigation started finished and nothing scheduled…

2023-08-18 16:00:00.496 INFO (MainThread) [homeassistant.components.automation.irrigation_unlimited_adjustment] Irrigation Unlimited Adjustment: Running automation actions
2023-08-18 16:00:00.497 INFO (MainThread) [homeassistant.components.automation.irrigation_unlimited_adjustment] Irrigation Unlimited Adjustment: Executing step call service
2023-08-18 16:00:00.500 INFO (MainThread) [custom_components.irrigation_unlimited] CALL [2023-08-18 16:00:00] service: adjust_time, controller: 1, zone: 0, data: {"entity_id": ["binary_sensor.irrigation_unlimited_c1_m"], "sequence_id": 0, "percentage": 162.0}
2023-08-18 16:00:00.505 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2023-08-18 08:54:18] controller: 1, zone: 0, state: 1
2023-08-18 16:00:00.506 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2023-08-18 08:54:18] controller: 1, zone: 1, state: 1, data: 1.1.1.5.1
2023-08-18 16:00:00.568 INFO (MainThread) [homeassistant.components.automation.irrigation_unlimited_benachrichtigung_start] Irrigation Unlimited Benachrichtigung: Running automation actions
2023-08-18 16:00:00.593 INFO (MainThread) [homeassistant.components.automation.irrigation_unlimited_benachrichtigung_start] Irrigation Unlimited Benachrichtigung: If at step 1: Running automation actions
2023-08-18 16:00:00.594 INFO (MainThread) [homeassistant.components.automation.irrigation_unlimited_benachrichtigung_start] Irrigation Unlimited Benachrichtigung: If at step 1: Executing step call service
2023-08-18 16:00:01.505 WARNING (MainThread) [custom_components.irrigation_unlimited] SYNCHRONISATION [2023-08-18 16:00:01] Switch does not match current state: expected: on, switch: switch.rain_bird_z1_rasen_eingang
2023-08-18 16:00:01.521 WARNING (MainThread) [custom_components.irrigation_unlimited] SYNCHRONISATION [2023-08-18 16:00:01] Switch does not match current state: expected: on, switch: switch.rain_bird_z1_rasen_eingang
2023-08-18 16:00:01.527 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2023-08-18 16:00:01] controller: 1, zone: 1, state: 0
2023-08-18 16:00:01.528 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2023-08-18 16:00:01] controller: 1, zone: 0, state: 0
2023-08-18 16:00:01.552 WARNING (MainThread) [homeassistant.components.automation.irrigation_unlimited_benachrichtigung_start] Irrigation Unlimited Benachrichtigung: Already running
2023-08-18 16:00:06.206 INFO (MainThread) [homeassistant.components.mobile_app.notify] mobile_app push notification rate limits for SM-G990B: 8 sent, 500 allowed, 0 errors, resets in 9:59:53

Any idea why this was triggered or why finish and start events were fired at 16:00 without any schedule? It seems like adjustment automation resultet in a very short activation of the controller and zone 1 for a second (which shouldn’t happen) resulting in the fired start and finish events triggering my notification automation…