irrigation_unlimited icon indicating copy to clipboard operation
irrigation_unlimited copied to clipboard

Weather adjust time

Open stefanoferrario opened this issue 2 years ago • 8 comments

I'm trying to setup weather adjust time using my Netatmo station and some open weather map API. I use this file with some changes and this was the result:

sensor:
  - platform: average
    name: irrigation_unlimited_rain_0
    entities:
      - sensor.netatmo_ferrario_stazione_meteo_studio_pluviometro_rain_today
    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.netatmo_ferrario_stazione_meteo_studio_pluviometro_rain_today
    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.netatmo_ferrario_stazione_meteo_studio_pluviometro_rain_today
    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.netatmo_ferrario_stazione_meteo_studio_pluviometro_rain_today
    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.netatmo_ferrario_stazione_meteo_studio_pluviometro_rain_today
    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.netatmo_ferrario_stazione_meteo_studio_sensore_esterno_portico_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.netatmo_ferrario_stazione_meteo_studio_sensore_esterno_portico_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.netatmo_ferrario_stazione_meteo_studio_sensore_esterno_portico_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.netatmo_ferrario_stazione_meteo_studio_sensore_esterno_portico_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.netatmo_ferrario_stazione_meteo_studio_sensore_esterno_portico_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.netatmo_ferrario_stazione_meteo_studio_sensore_esterno_portico_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:
      - platform: time
        at: "00:05"
    condition:
      condition: and
      conditions:
        - "{{ states('sensor.irrigation_unlimited_rain_weighted_total') | float(-1) != -1 }}"
        - "{{ states('sensor.openweathermap_forecast_precipitation') | float(-1) != -1 }}"
        - "{{ states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float(-273) != -273 }}"
    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.openweathermap_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) }}

When I execute the automation all scheduled time expire and I can't find a solution to this problem

stefanoferrario avatar May 27 '22 06:05 stefanoferrario

It sounds like the sensor information is not correct. The run time will be set to 0 if it is currently raining sensor.openweathermap_forecast_precipitation > 0 or there has been enough rain sensor.irrigation_unlimited_rain_weighted_total > rain_rate_threshold (1.0). Check these sensors in Developer Tools -> States to see if the values appear correct. Also check the automation is running and there are no errors in Settings -> Automations & Scenes -> Irrigation Unlimited Adjustment -> Debug Automation. There is a lot of information in this section to help you work through the problem.

rgc99 avatar May 31 '22 06:05 rgc99

Have you figured this out? I am having same problem it will not do an adjustment. Last year on older version I had no problems but this year it will not calculate an adjustment. I know it should have an adjustment because it has rained for last 3 days. It is showing 0.0% adjustment. My irrigation_unimited_adjustment.yaml is setup with lastest in packages yaml.

Here is a result of the trace debug in HA

{
  "trace": {
    "last_step": "action/0",
    "run_id": "10964b86c0f187fa25cd3dbf9eb43852",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2022-06-28T12:16:08.387199+00:00",
      "finish": "2022-06-28T12:16:08.492683+00:00"
    },
    "domain": "automation",
    "item_id": "IU1653340123453",
    "trigger": "state of sensor.sensor_rain_in_mm",
    "trace": {
      "trigger/2": [
        {
          "path": "trigger/2",
          "timestamp": "2022-06-28T12:16:08.387332+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.irrigation_unlimited_adjustment",
              "state": "on",
              "attributes": {
                "last_triggered": "2022-06-28T12:14:11.337902+00:00",
                "mode": "single",
                "current": 0,
                "id": "IU1653340123453",
                "friendly_name": "Irrigation Unlimited Adjustment"
              },
              "last_changed": "2022-06-28T12:15:10.911471+00:00",
              "last_updated": "2022-06-28T12:15:10.911471+00:00",
              "context": {
                "id": "01G6N3SA1ZM7ZDJ91RX07D479F",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "2",
              "idx": "2",
              "platform": "state",
              "entity_id": "sensor.sensor_rain_in_mm",
              "from_state": {
                "entity_id": "sensor.sensor_rain_in_mm",
                "state": "unavailable",
                "attributes": {
                  "unit_of_measurement": "mm",
                  "friendly_name": "Todays Rain in mm"
                },
                "last_changed": "2022-06-28T12:15:48.775468+00:00",
                "last_updated": "2022-06-28T12:15:48.775468+00:00",
                "context": {
                  "id": "01G6N3TF17D9Z6MF2KRGB5AZQ1",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sensor.sensor_rain_in_mm",
                "state": "0.0",
                "attributes": {
                  "unit_of_measurement": "mm",
                  "friendly_name": "Todays Rain in mm"
                },
                "last_changed": "2022-06-28T12:16:08.369966+00:00",
                "last_updated": "2022-06-28T12:16:08.369966+00:00",
                "context": {
                  "id": "01G6N3V21DST2BD8T9HQ0Z8Q7B",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of sensor.sensor_rain_in_mm"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2022-06-28T12:16:08.387435+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/conditions/0": [
        {
          "path": "condition/0/conditions/0",
          "timestamp": "2022-06-28T12:16:08.387501+00:00",
          "result": {
            "result": true,
            "entities": [
              "sensor.irrigation_unlimited_rain_weighted_total"
            ]
          }
        }
      ],
      "condition/0/conditions/1": [
        {
          "path": "condition/0/conditions/1",
          "timestamp": "2022-06-28T12:16:08.388075+00:00",
          "result": {
            "result": true,
            "entities": [
              "sensor.sensor_rain_rate_mm"
            ]
          }
        }
      ],
      "condition/0/conditions/2": [
        {
          "path": "condition/0/conditions/2",
          "timestamp": "2022-06-28T12:16:08.388546+00:00",
          "result": {
            "result": true,
            "entities": [
              "sensor.irrigation_unlimited_temperature_5_day_moving_average"
            ]
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2022-06-28T12:16:08.396920+00:00",
          "changed_variables": {
            "context": {
              "id": "01G6N3V263K58D7DHZEY2FP7FG",
              "parent_id": "01G6N3V21DST2BD8T9HQ0Z8Q7B",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "irrigation_unlimited",
              "service": "adjust_time",
              "service_data": {
                "entity_id": "binary_sensor.irrigation_unlimited_c1_m",
                "percentage": 0
              },
              "target": {}
            },
            "running_script": false,
            "limit": 10
          }
        }
      ]
    },
    "config": {
      "id": "IU1653340123453",
      "alias": "Irrigation Unlimited Adjustment",
      "trigger": [
        {
          "platform": "time",
          "at": "02:00"
        },
        {
          "platform": "homeassistant",
          "event": "start"
        },
        {
          "platform": "state",
          "entity_id": [
            "sensor.irrigation_unlimited_rain_weighted_total",
            "sensor.irrigation_unlimited_temperature_5_day_moving_average",
            "sensor.sensor_rain_in_mm"
          ]
        }
      ],
      "condition": {
        "condition": "and",
        "conditions": [
          "{{ states('sensor.irrigation_unlimited_rain_weighted_total') | float(-1) != -1 }}",
          "{{ states('sensor.sensor_rain_rate_mm') | float(-1) != -1 }}",
          "{{ states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float(-273) != -273 }}"
        ]
      },
      "action": {
        "service": "irrigation_unlimited.adjust_time",
        "data": {
          "entity_id": "binary_sensor.irrigation_unlimited_c1_m",
          "percentage": "{

bsmith76s avatar Jun 28 '22 12:06 bsmith76s

Please post the configuration and relevant log entries so I can dig further into this. You are attempting to adjust the controller/master and not specify a sequence_id which will set each zone individually. Are you attempting to adjust a sequence or all zones?

rgc99 avatar Jun 28 '22 21:06 rgc99

I'm trying to adjust all sequences and zones. How do I get it to adjust all my sequences and zones? I dont have any logs at the moment I am in the process of deleting the integration and yaml files and starting fresh. I was having problems since trying to get the adjustment to calculate and some how it stop calculating the next cycle time.

here is my configuration.yaml

irrigation_unlimited:
  controllers:
    entity_id: "input_boolean.garden_irrigation"
    zones:
      - name: "Tomato Garden"
        entity_id: "switch.tasmota_garden_1"
      - name: "Bean Patch"
        entity_id: "switch.tasmota_garden_2"
      - name: "Lettuce Patch"
        entity_id: "switch.tasmota_garden_3"
      - name: "Zucchini Patch"
        entity_id: "switch.tasmota_garden_4" 
    sequences:
      - name: "Morning Spring and Autumn"
        duration: "00:10"
        delay: "00:00"
        repeat: 3
        schedules:
          - name: "Sunrise"
            time:
              sun: "sunrise"
              before: "01:30"
            month: [jun, jul, aug, sep, oct]
        zones:
          - zone_id: 1
          - zone_id: 2
            duration: "00:06"
          - zone_id: 3
            duration: "00:07"
          - zone_id: 4
            duration: "00:07"
#      - name: "Mid Day Summer"
#        duration: "00:10"
#        delay: "00:05"
#        repeat: 3
#        schedules:
#          - name: "Mid-day"
#            time: "12:15"
#            month: [jun, jul, aug]
#        zones:
#          - zone_id: 1
#          - zone_id: 3
      - name: "Evening Spring and Autumn"
        duration: "00:10"
        delay: "00:00"
        repeat: 3
        schedules:
          - name: "Before sunset"
            time:
              sun: "sunset"
              before: "03:15"
            month: [jun, jul, aug, sep, oct]
        zones:
          - zone_id: 1
            #duration: "00:08"
          - zone_id: 2
            duration: "00:06"
          - zone_id: 3
            duration: "00:07"
          - zone_id: 4
            duration: "00:07"

here is my irrigation_unlimited_adjustment.yaml

# 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 Home-Assistant-wundergroundpws https://github.com/cytech/Home-Assistant-wundergroundpws 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.sensor_rain_in_mm
    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.sensor_rain_in_mm
    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.sensor_rain_in_mm
    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.sensor_rain_in_mm
    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.sensor_rain_in_mm
    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.sensor_atlas_temperature_in_c
    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.sensor_atlas_temperature_in_c
    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.sensor_atlas_temperature_in_c
    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.sensor_atlas_temperature_in_c
    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.sensor_atlas_temperature_in_c
    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.sensor_atlas_temperature_in_c
    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.sensor_rain_in_mm
    condition:
      condition: and
      conditions:
        - "{{ states('sensor.irrigation_unlimited_rain_weighted_total') | float(-1) != -1 }}"
        - "{{ states('sensor.sensor_rain_rate_mm') | 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
        #zones: 0
        # -------------------------------------------------------------------
        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) %}
          {# 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) }}

bsmith76s avatar Jun 29 '22 00:06 bsmith76s

deleting integration and reloading fixed the next cycle schedule I am not going to try adjustment before I know how to adjust all zones and sequences. I will wait for a response.

bsmith76s avatar Jun 29 '22 01:06 bsmith76s

In Developer Tools -> STATES what is the state for the following sensors:

  1. 'sensor.irrigation_unlimited_rain_weighted_total'
  2. 'sensor.wupws_preciprate'
  3. 'sensor.irrigation_unlimited_temperature_5_day_moving_average'

These sensors are used in the action part of the automation to set the percentage. They should exist and have sensible values. Sensor 1 is the rain over the last few days. Sensor 2 is used to see if it is currently raining (This comes from weatherundergroundpws integration, is it installed). Sensor 3 is the average temperature of the last few days.

rgc99 avatar Jul 03 '22 20:07 rgc99

In Developer Tools -> STATES what is the state for the following sensors:

  1. 'sensor.irrigation_unlimited_rain_weighted_total'
  2. 'sensor.wupws_preciprate'
  3. 'sensor.irrigation_unlimited_temperature_5_day_moving_average'

Thanks for for the response

  1. I get a valid rain weight total.
  2. I use a weather station I pull this value from and is a valid value.
  3. this is also a valid value. The observation card is showing the values of 1 and 3 that are calculating.

I have not setup the adjustment.yaml since rebuilding the integration a few days ago. I was waiting to see how I set it up to do adjustment for all zones and sequences. Do I use this in the adjustment.yaml file?

        # 2. Adjust a sequence. Change the sequence_id as required
        entity_id: binary_sensor.irrigation_unlimited_c1_m
        zones: 0

bsmith76s avatar Jul 03 '22 21:07 bsmith76s

I opened a new issue didn't want to hijack this one any longer. here is link

https://github.com/rgc99/irrigation_unlimited/issues/84

bsmith76s avatar Jul 07 '22 02:07 bsmith76s