Irrigation Custom Component with Custom Card

there we go!

I started at type:
I omitted the second - entity: line

Thanx Pete!!

Hi Peter!

Finally had some time to upgrade from v2 to v3. Seems to work great! I haven’t dug into all the new features such as the reduction of irrigation time, etc. But I did notice one thing I wanted to double check – With the new setup, you have the solenoids broken out directly, not the zones like it used to be. That allows you to enable more than one zone at a time (manually), and when you enable a zone, it doesn’t act like it used to in v2 (it would just run that zone for the configured time and it would shut off automatically). It’s not a problem for me, but I wanted to double check that that was by design and not a result of something I messed up in the shift from v2 to v3 …

Thanks again for your awesome work!

Hi Robbert,

You are right, now the zones are integrated into each program, the only way to run an individual zone is to start the switch that is linked to your solenoid. I personally only have the solenoids visible as part of the test harness to make sure that they have actually started.

I’m much happier with this version, I can’t think of any other features to add, so now I am looking for my next project.

I have created a companion component to collect 5 days of history using the openweathermap API and calculate an adjustment factor that can be used in the Irrigation component.

openweathremaphistory

A home assistant sensor that uses the OpenWeatherMap API to get the last 5 days rainfall. A call is made for each day so the scan_interval is set at 3600 seconds (1 hour) as the free tier allows only 1000 calls per day.

This information is used to calculate a factor that can be used to reduce the watering time of the Irrigation Program custom component.

A OpenWeatherMap API Key is required see the OpenWeatherMap custom component for more information.

You need an API key, which is free, but requires a registration.

Calculation

The adjustment factor is calculated based on the the cumulative rainfall for each day. For yesterday the cumulative value is today’s (day 0) rainfall + yesterday’s (day 1) rainfall.

The lowest factor of the up to five days of rainfall is return as the state of the sensor.

factor = 1 - ((cumulative rainfall - daymin)/(daymax - daymin))

If the factor is less than 0 the factor is set to 0.

Attributes

Attributes are returned for:

  • daily rainfall
  • daily cumulative rainfall

This is the first iteration of this and any feedback is appreciated.

1 Like

oops wrong component

oops, wrong component

New Version 3.0.3 release with minor bug fix enhancements.

Version 4 of the custom component is now available. This release comes with some new options and support for a new custom card.

Custom Card
I am not the best UI developer so this utilises the entities card model to present the objects defined for the custom component. This is my first custom card so feedback and assistance will be welcomed.

Breaking Change
There is a minor breaking change for anyone using the run_days option in version 3. Please rename run_days to run_freq to maintain the existing capability. As the capabilities have been merged into a single option.

Please review the documentation in the GITHUB repository for all changes.
Summary of Changes

  • New repository with improvements and support for the new custom card
  • Allow definition for run frequency at the zone level - feature request
  • DEPRECATE the run_days attribute. Simply rename this attribute to run_freq to maintain the functionality
  • Optionally allow multiple programs to run simultaneously, use the allow_multiple config option
  • Allow monitoring of the irrigation controller hardware if supported, will not run schedule if controller is offline

This is a new release, despite my best efforts there is going to be an issue or two, if you find issues please log them in the GITHUB issues for the respective archives or let me know in this forum.

If you use the component let me know, I would love to know if and where it is being used.

V1.0.1 of the Custom Card for Irrigation component released with improved error handling.
image

hi petergridge
thanks a lot for your component, i’m probably not the only one to migrate the old rainbird controller to ha. , i’m suprised that this component is not more popular.

i have installed all your component ( irrigation V4, custom card , and openweathremaphistory ) i have a nice dashboard, but i’m struggling to understand how to set up the automation to fit my need. and to have it active

i would like to run on sprinkler every 2 days for a duration X , which will be adjusted by sensor.rainfactor (set by openweathremaphistory ).

i’m probably missing the last configuration step , could you point me the direction ?

Hi Froggy,

Can you send me a copy of your config, I will look at it and get back to you.

Cheers
Pete

thanks petergridge
i’m not sure to understand which config file i need to send to you
at this stage, i have only installed all the custom component and the irrigationtest.yaml package.
i’m trying to understand what config i need to modify in order to make the automation run

Hi

Thank you for your great work.
In v4 when I set water time more then 6 min its display 1:06.59, if more then 12 min its 2:12:59 and etc.
Also when you run program and stop it adjust any parameter or not and run again, the timer not correctly countdown.
And water adjustment must be more then 0 to be run program?

Thank you.

Hi,

I have corrected the calculation for the remaining time.

The watering adjustment is designed to be a factor 0 if you detect that it is raining and no watering is required to 1 if it has been dry and you need a full watering cycle. As a result it is zero the zone/s it is associated with will not run.

Cheers
Pete

Hi Froggy,
Try this:
Use the yaml below to replace irrigationtest.yaml and change line 24 zone: switch.dummy_1 to switch.yourswitch, the switch exposed to HA by your irrigation controller.

    input_datetime:
      irrigation_afternoon_start_time:
        name: Afternoon Start Time
        has_date: false
        has_time: true

    sensor:
      - platform: time_date
        display_options:
          - 'time'
          - 'date'
      - platform: openweathermaphistory
        name: 'rainfactor'
        api_key: !secret openweatherapi
       
    switch:

      - platform: irrigationprogram
        switches: 
          afternoon:
            start_time: input_datetime.irrigation_afternoon_start_time
            run_freq: input_select.irrigation_freq
            zones:
              - zone: switch.dummy_1
                name: Lawn
                water: input_number.irrigation_lawn_run
                icon: mdi:grass

      - platform: template
        switches:
          dummy_1:
            value_template: "{{ is_state('input_boolean.dummy_switch_1', 'on') }}"
            turn_on:
              - service: input_boolean.turn_on
                entity_id: input_boolean.dummy_switch_1
            turn_off:
              - service: input_boolean.turn_off
                entity_id: input_boolean.dummy_switch_1

    input_number:

      irrigation_lawn_run:
        name: water
        min: 1
        max: 30
        step: 1
        icon: mdi:water

    input_select:
    # Use either run days of Frequency they are mutually exclusive
      irrigation_freq:
        name: Frequency
        options:
          - "1"
          - "2"
          - "3"
          - "4"
          - "5"
          - "6"
          - "7"

    input_boolean:
      irrigation_on:
        name: Enable Irrigation
      dummy_switch_1:

I have also identified an issue with the implementation of the watering adjustment that I will work and and release a new version shortly. Currently it does not support the provision of a sensor just input_number.

I hope this helps, let me know how you go.

Cheers

Thanks for the feedback:

Updated versions now available of both the custom component and custom card.

thanks a lot peterridge.
it works perfectly :smile:

in your yaml , i don’t see how the duration is adjusted by the rain factor from openweather.
how can i check this ?

Hi,

I did not have the water adjustment configured in the sample above was just keeping it simple. See the update below. If it has not been raining where you are you can change the location on the sensor to somewhere you know it is (it’s pouring in Sydney Aus today) and test against other locations. See the rain history page for the latitude and longitude settings.

You can also write your own template sensor to use the attributes of the openweatherhist to do your own calculation or use any other inputs.

Cheers
Pete

Hi Pete

input_datetime:
  irrigation_morning_start_time:
    name: Morning Start Time
    has_date: false
    has_time: true
  irrigation_afternoon_start_time:
    name: Afternoon Start Time
    has_date: false
    has_time: true
  irrigation_night_start_time:
    name: Night Start Time
    has_date: false
    has_time: true
    
sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
#    - platform: openweathermaphistory
#      name: 'rainfactor'
#      api_key: !secret openweatherapi
   
switch:
  - platform: irrigationprogram
    switches: 
      morning:
        irrigation_on: input_boolean.irrigation_on
        start_time: input_datetime.irrigation_morning_start_time
        #will run only on selected run days
        run_freq: input_select.irrigation_run_days
        icon: mdi:fountain
        zones:
          - zone: switch.relay1
            # no rain sensor will alway run
            name: Zone 1
            water: input_number.irrigation_zone_1_run
            rain_sensor: binary_sensor.raining
            ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
            water_adjustment: input_number.irrigation_adjust_run
            icon: mdi:grass
          - zone: switch.relay2
            # rain sensor with ignore option
            name: Zone 2
            #irrigation_on: input_boolean.irrigation_on
            water: input_number.irrigation_zone_2_run
            rain_sensor: binary_sensor.raining
            #wait: input_number.irrigation_pot_plants_wait
            #repeat: input_number.irrigation_pot_plants_repeat
            ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
            water_adjustment: input_number.irrigation_adjust_run                
            icon: mdi:grass
          - zone: switch.relay3
            # rain sensor with ignore option
            name: Zone 3
            #irrigation_on: input_boolean.irrigation_on
            water: input_number.irrigation_zone_3_run
            rain_sensor: binary_sensor.raining
            #wait: input_number.irrigation_pot_plants_wait
            #repeat: input_number.irrigation_pot_plants_repeat
            ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
            water_adjustment: input_number.irrigation_adjust_run                
            icon: mdi:grass
            
      afternoon:
        #irrigation_on: input_boolean.irrigation_on
        start_time: input_datetime.irrigation_afternoon_start_time
        #will run only on selected run days
        run_freq: input_select.irrigation_run_days
        icon: mdi:fountain            
        zones:
          - zone: switch.relay1
            # no rain sensor will alway run
            name: Zone 1
            #irrigation_on: input_boolean.irrigation_on
            water: input_number.irrigation_zone_1_run
            #rain_sensor: binary_sensor.raining
            #wait: input_number.irrigation_pot_plants_wait
            #repeat: input_number.irrigation_pot_plants_repeat
            #ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
            #water_adjustment: input_number.irrigation_adjust_run                
            icon: mdi:grass
          - zone: switch.relay2
            # rain sensor with ignore option
            name: Zone 2
            #irrigation_on: input_boolean.irrigation_on
            water: input_number.irrigation_zone_2_run
            #rain_sensor: binary_sensor.raining
            #wait: input_number.irrigation_pot_plants_wait
            #repeat: input_number.irrigation_pot_plants_repeat
            #ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
            #water_adjustment: input_number.irrigation_adjust_run                
            icon: mdi:grass
          - zone: switch.relay3
            # rain sensor with ignore option
            name: Zone 3
            #irrigation_on: input_boolean.irrigation_on
            water: input_number.irrigation_zone_3_run
            #rain_sensor: binary_sensor.raining
            #wait: input_number.irrigation_pot_plants_wait
            #repeat: input_number.irrigation_pot_plants_repeat
            #ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
            #water_adjustment: input_number.irrigation_adjust_run                
            icon: mdi:grass
          - zone: switch.relay4
            # no rain sensor will alway run
            name: Zone 4
            #irrigation_on: input_boolean.irrigation_on
            water: input_number.irrigation_zone_4_run
            #rain_sensor: binary_sensor.raining
            #wait: input_number.irrigation_pot_plants_wait
            #repeat: input_number.irrigation_pot_plants_repeat
            #ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
            #water_adjustment: input_number.irrigation_adjust_run
            #run_freq: input_select.irrigation_run_days
            icon: mdi:flowe  
  
  - platform: template
    switches:
      dummy_1:
        value_template: "{{ is_state('input_boolean.dummy_switch_1', 'on') }}"
        turn_on:
          - service: input_boolean.turn_on
            entity_id: input_boolean.dummy_switch_1
        turn_off:
          - service: input_boolean.turn_off
            entity_id: input_boolean.dummy_switch_1
      dummy_2:
        value_template: "{{ is_state('input_boolean.dummy_switch_2', 'on') }}"
        turn_on:
          - service: input_boolean.turn_on
            entity_id: input_boolean.dummy_switch_2
        turn_off:
          - service: input_boolean.turn_off
            entity_id: input_boolean.dummy_switch_2
      dummy_3:
        value_template: "{{ is_state('input_boolean.dummy_switch_3', 'on') }}"
        turn_on:
          - service: input_boolean.turn_on
            entity_id: input_boolean.dummy_switch_3
        turn_off:
          - service: input_boolean.turn_off
            entity_id: input_boolean.dummy_switch_3
      dummy_4:
        value_template: "{{ is_state('input_boolean.dummy_switch_4', 'on') }}"
        turn_on:
          - service: input_boolean.turn_on
            entity_id: input_boolean.dummy_switch_4
        turn_off:
          - service: input_boolean.turn_off
            entity_id: input_boolean.dummy_switch
                  
            
input_number:
  irrigation_adjust_run:
    name: water adjustment
    min: 0
    max: 1
    step: 0.2
    icon: mdi:water-pump-off
  irrigation_pot_plants_run:
    name: water
    min: 1
    max: 30
    step: 1
    icon: mdi:water
  irrigation_pot_plants_wait:
    name: wait
    min: 0
    max: 10
    step: 1
    icon: mdi:timer-sand
  irrigation_pot_plants_repeat:
    name: repeat
    min: 1
    max: 10
    step: 1
    icon: mdi:repeat
  irrigation_zone_1_run:
    name: water
    min: 1
    max: 30
    step: 1
    icon: mdi:water
  irrigation_zone_2_run:
    name: water
    min: 1
    max: 30
    step: 1
    icon: mdi:water 
  irrigation_zone_3_run:
    name: water
    min: 1
    max: 30
    step: 1
    icon: mdi:water 
  irrigation_zone_4_run:
    name: water
    min: 1
    max: 30
    step: 1
    icon: mdi:water     
input_select:
# Use either run days of Frequency they are mutually exclusive
  irrigation_run_days:
    name: Run Days
    options:
      - "['Wed','Sat']"
      - "['Sun','Thu']"
      - "['Mon','Fri']"
      - "['Tue','Sat']"
      - "['Sun','Wed']"
      - "['Mon','Thu']"
      - "['Tue','Fri']"
      - "['Mon','Wed','Fri']"
      - "['Mon','Tue','Wed','Thu','Fri','Sat','Sun']"
  irrigation_freq:
    name: Frequency
    options:
      - "1"
      - "2"
      - "3"
      - "4"
      - "5"
      - "6"
      - "7"
input_boolean:
  irrigation_on:
    name: Enable Irrigation
  irrigation_config:
    name: Show Configuration
  irrigation_ignore_rain_sensor:
    name: Ignore Rain Sensor
  
  dummy_switch_1:
  dummy_switch_2:
  dummy_switch_3:
  dummy_switch_4:
  dummy_rain_sensor:
binary_sensor:
  - platform: template
    sensors:
      raining:
            device_class: moisture
            value_template: "{{ is_state('input_boolean.dummy_rain_sensor', 'on') }}"
            icon_template: >-
              {% if is_state("binary_sensor.raining", "on") %}
                mdi:weather-pouring
              {% else %}
                mdi:weather-sunny
              {% endif %}

this is my config , when I try to add morning and afternoon programs I have this error.

Hi,

A silly error on my part, I have added this scenario to my testing as well. I have uploaded a new version 4.0.3.

I am currently working on some cleaning up of v4 to reduce the amount of redundant code that has crept in so keep an eye out for version 4.1.0 in the next week or two.

If you have any feature requests I am feeling motivated at the moment.

Cheers