Irrigation Custom Component with Custom Card

Peter

I am still not having any joy with the ignore rain sensor toggle, some times is works some time not.
sometimes it will activate the program toggle but not the relays

Hi Terence, I have updated the program, can you try the new version, Check the notes as you can now ignore rain sensor at the zone level with either a Boolean (true/false) or reference a sensor.

Peter

do ignore_rain_bool: and ignore_rain_sensor:

do the same thing, meaning one is for reference to a sensor and one to a boolean?

your right, I thought that for many occasions ignore is the default state while others you would want to reference a sensor. they are mutually exclusive in the config, only one can be configured at a time (for each switch)

Version 3 Released:

This is a breaking change from the previous version as the irrigationzone component has been deprecated and incorporated into the irrigationprogram component.

  • Rain sensor operation has been improved
  • A different sensor can be allocated against each zone
  • Water adjustment factor can be defined to vary the water time.
  • ASYNC coding has been improved
  • Improved error handling and configuration validation

The sample codes represents a working test harness that is self contained with dummy switches and rain sensor that can be used to become familiar with the capabilities of the component and a sample of LoveLace configuration that uses the Entities card with conditions and the Conditions Card to simplify the UI.

2 Likes

oh wow! That looks like everyones whishlist items all in one!

Thanx Peter

Questionā€¦ I havenā€™t looked that close yet, but, will the new single custom component work with the old yaml files, or should i set aside some time to redo everything at once?

Unfortunately its a breaking change so you will need to do some cutting and pasting of your two configurations.

I would recommend that you install the test harness to check out the functionality.

Hello Peter,
Iā€™ve just installed your integration, it seems to be good, but i need 4. zone.
Is there a way somehow to add a 4. zone ?

Thanx .

Hi, Easy!,
Copy one of the example zones that suits your scenario and change the name of the zone and any of the integrations used.
Define the new components.
Update the LoveLace UI. I find it easiest to cut and paste then edit a section used in the code editor.

There is no practical limit to the number of zones you can create

Cheers

Hi,

Here is a little more detail:

To add another zone to the configuration. Copy the section into your configuration yaml as another zone in the irrigationprogram.

          - zone: switch.dummy_1
          # no rain sensor will alway run
            name: Pot Plants
            water: input_number.irrigation_pot_plants_run
            wait: input_number.irrigation_pot_plants_wait
            repeat: input_number.irrigation_pot_plants_repeat
            icon: mdi:flower

To add a new zone to the Zone Attributes tile add this to the end just before the ā€˜title:ā€™ line.

    - type: section
      label: Pot Plants
    - entity: input_number.irrigation_pot_plants_run
    - entity: input_number.irrigation_pot_plants_wait
    - entity: input_number.irrigation_pot_plants_repeat

There are a number of ways to set up a zone so choose a sample that matches your requirement. You will need to modify the entity names to match your zone, create new inputā€¦ entities that support your new zone.

Hi,

Thank you, it works, iā€™m happy with it :slight_smile:

Hi Peterā€¦

nice update, way more to fiddle with than in v2

Unfortunately, I need your help. V2 was pretty easy to set up, unfortunately, I messed v3 up somewhere:(

1st issueā€¦ itā€™s not adjusting time based on ā€œadjust_run_timeā€ input number

for testing I have zones set to 1 minute, and adjust_run_time set to 0.5, so I would expect 30 seconds per zone, however, Iā€™m getting 1 min.

another weird thingā€¦ I have repeat, set to 0, but when the zone runā€™s it has a repeat of 1 set

irrigation:
    switch:
      - platform: irrigationprogram
        switches: 
          program_1:
            irrigation_on: input_boolean.irrigation_on
            start_time: input_datetime.irrigation_program_1_start_time
            run_days: input_select.irrigation_run_days
            icon: mdi:fountain
            zones:
              - zone: switch.dummy_1
                name:  Front Lawn
                water: input_number.irrigation_front_lawn_run
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_front_lawn_wait
                repeat: input_number.irrigation_front_lawn_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
              - zone: switch.dummy_2
                name:  Front Door Shrubs
                water: input_number.irrigation_front_door_shrubs
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_front_door_shrubs_wait
                repeat: input_number.irrigation_front_door_shrubs_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
              - zone: switch.dummy_3
                name:  Front Street
                water: input_number.irrigation_front_street_run
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_front_street_wait
                repeat: input_number.irrigation_front_street_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
              - zone: switch.dummy_5
                name:  Back Dripline
                water: input_number.irrigation_back_dripline_run
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_back_dripline_wait
                repeat: input_number.irrigation_back_dripline_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
          program_2:
            irrigation_on: input_boolean.irrigation_on
            start_time: input_datetime.irrigation_program_2_start_time
            run_days: input_select.irrigation_run_days
            icon: mdi:fountain
            zones:
              - zone: switch.dummy_1
                name:  Front Lawn
                water: input_number.irrigation_front_lawn_run
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_front_lawn_wait
                repeat: input_number.irrigation_front_lawn_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
              - zone: switch.dummy_2
                name:  Front Door Shrubs
                water: input_number.irrigation_front_door_shrubs
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_front_door_shrubs_wait
                repeat: input_number.irrigation_front_door_shrubs_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
              - zone: switch.dummy_3
                name:  Front Street
                water: input_number.irrigation_front_street_run
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_front_street_wait
                repeat: input_number.irrigation_front_street_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
              - zone: switch.dummy_5
                name:  Back Dripline
                water: input_number.irrigation_back_dripline_run
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_back_dripline_wait
                repeat: input_number.irrigation_back_dripline_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
                
          program_3:
            irrigation_on: input_boolean.irrigation_on
            start_time: input_datetime.irrigation_program_3_start_time
            run_days: input_select.irrigation_run_days
            icon: mdi:fountain
            zones:
              - zone: switch.dummy_1
                name:  Front Lawn
                water: input_number.irrigation_front_lawn_run
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_front_lawn_wait
                repeat: input_number.irrigation_front_lawn_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
              - zone: switch.dummy_2
                name:  Front Door Shrubs
                water: input_number.irrigation_front_door_shrubs
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_front_door_shrubs_wait
                repeat: input_number.irrigation_front_door_shrubs_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
              - zone: switch.dummy_3
                name:  Front Street
                water: input_number.irrigation_front_street_run
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_front_street_wait
                repeat: input_number.irrigation_front_street_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
              - zone: switch.dummy_5
                name:  Back Dripline
                water: input_number.irrigation_back_dripline_run
                water_adjustment: input_number.adjust_run_time
                wait: input_number.irrigation_back_dripline_wait
                repeat: input_number.irrigation_back_dripline_repeat
                rain_sensor: binary_sensor.meteobridge_is_raining
                ignore_rain_sensor: input_boolean.irrigation_ignore_rain_sensor
                icon: mdi:grass
      - platform: template
        switches:
          dummy_1:
            value_template: "{{ is_state('switch.front_lawn_zone', 'on') }}"
            turn_on:
              service: bhyve.start_watering
              data:
                entity_id: switch.front_lawn_zone
                #max minutes to run
                minutes: 60
            turn_off:
              service: bhyve.stop_watering
              data:
                entity_id: switch.front_lawn_zone

          dummy_2:
            value_template: "{{ is_state('switch.front_door_shrubs_zone', 'on') }}"
            turn_on:
              service: bhyve.start_watering
              data:
                entity_id: switch.front_door_shrubs_zone
                #max minutes to run
                minutes: 60
            turn_off:
              service: bhyve.stop_watering
              data:
                entity_id: switch.front_door_shrubs_zone

          dummy_3:
            value_template: "{{ is_state('switch.front_street_zone', 'on') }}"
            turn_on:
              service: bhyve.start_watering
              data:
                entity_id: switch.front_street_zone
                #max minutes to run
                minutes: 60
            turn_off:
              service: bhyve.stop_watering
              data:
                entity_id: switch.front_street_zone
                
          dummy_5:
            value_template: "{{ is_state('switch.back_dripline_zone', 'on') }}"
            turn_on:
              service: bhyve.start_watering
              data:
                entity_id: switch.back_dripline_zone
                #max minutes to run
                minutes: 60
            turn_off:
              service: bhyve.stop_watering
              data:
                entity_id: switch.back_dripline_zone


    input_number:
# seasonal adjustment
      adjust_run_time:
        name: water adjustment
        min: 0
        max: 1
        step: 0.1
        icon: mdi:water-pump-off
#front lawn
      irrigation_front_lawn_run:
        name: water
        min: 1
        max: 60
        step: 1
        icon: mdi:water
      irrigation_front_lawn_wait:
        name: wait
        min: 0
        max: 10
        step: 1
        icon: mdi:timer-sand
      irrigation_front_lawn_repeat:
        name: repeat
        min: 0
        max: 10
        step: 1
        icon: mdi:repeat
#front door shrubs
      irrigation_front_door_shrubs_run:
        name: water
        min: 1
        max: 60
        step: 1
        icon: mdi:water
      irrigation_front_door_shrubs_wait:
        name: wait
        min: 0
        max: 10
        step: 1
        icon: mdi:timer-sand
      irrigation_front_door_shrubs_repeat:
        name: repeat
        min: 0
        max: 10
        step: 1
        icon: mdi:repeat
#front street
      irrigation_front_street_run:
        name: water
        min: 1
        max: 60
        step: 1
        icon: mdi:water
      irrigation_front_street_wait:
        name: wait
        min: 0
        max: 10
        step: 1
        icon: mdi:timer-sand
      irrigation_front_street_repeat:
        name: repeat
        min: 0
        max: 10
        step: 1
        icon: mdi:repeat
#back dripline
      irrigation_back_dripline_run:
        name: water
        min: 1
        max: 60
        step: 1
        icon: mdi:water
      irrigation_back_dripline_wait:
        name: wait
        min: 0
        max: 10
        step: 1
        icon: mdi:timer-sand
      irrigation_back_dripline_repeat:
        name: repeat
        min: 0
        max: 10
        step: 1
        icon: mdi:repeat

    input_datetime:
      irrigation_program_1_start_time:
        name: Start Time 1
        has_date: false
        has_time: true
      irrigation_program_2_start_time:
        name: Start Time 2
        has_date: false
        has_time: true
      irrigation_program_3_start_time:
        name: Start Time 3
        has_date: false
        has_time: true


    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']"
          - "['Sun','Wed','Fri']"

      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_5:
      dummy_rain_sensor:

    binary_sensor:
      - platform: template
        sensors:
          raining:
            device_class: moisture
            value_template: "{{ is_state('binary_sensor.meteobridge_is_raining', 'on') }}"
            icon_template: >-
              {% if is_state("binary_sensor.meteobridge_is_raining", "on") %}
                mdi:weather-pouring
              {% else %}
                mdi:weather-sunny
              {% endif %}```







2021-04-08 16:29:41 DEBUG (MainThread) [custom_components.irrigationprogram.switch] Zone switch switch.dummy_1: <state switch.dummy_1=off; friendly_name=dummy_1 @ 2021-04-08T16:29:35.074439-07:00>
2021-04-08 16:29:41 DEBUG (MainThread) [custom_components.irrigationprogram.switch] Zone switch switch.dummy_2: <state switch.dummy_2=off; friendly_name=dummy_2 @ 2021-04-08T16:20:18.039406-07:00>
2021-04-08 16:29:41 DEBUG (MainThread) [custom_components.irrigationprogram.switch] Zone switch switch.dummy_3: <state switch.dummy_3=off; friendly_name=dummy_3 @ 2021-04-08T16:20:18.039661-07:00>
2021-04-08 16:29:41 DEBUG (MainThread) [custom_components.irrigationprogram.switch] Zone switch switch.dummy_5: <state switch.dummy_5=off; friendly_name=dummy_5 @ 2021-04-08T16:20:18.039933-07:00>
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] -------------------- on execution: Program_1 ----------------------------
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] Template: Template("{{ states('sensor.time') + ':00' == states('input_datetime.irrigation_program_1_start_time')  and is_state('input_boolean.irrigation_on', 'on')  and now().strftime('%a') in states('input_select.irrigation_run_days') }}")
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] Start Time input_datetime.irrigation_program_1_start_time: <state input_datetime.irrigation_program_1_start_time=12:50:00; editable=False, has_date=False, has_time=True, hour=12, minute=50, second=0, timestamp=46200, friendly_name=Start Time 1 @ 2021-04-08T16:20:17.774578-07:00>
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] Irrigation on input_boolean.irrigation_on: <state input_boolean.irrigation_on=off; editable=False, friendly_name=Enable Irrigation @ 2021-04-08T16:20:17.834255-07:00>
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] Run Days input_select.irrigation_run_days: <state input_select.irrigation_run_days=['Mon','Tue','Wed','Thu','Fri','Sat','Sun']; 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']", "['Sun','Wed','Fri']"], editable=False, friendly_name=Run Days @ 2021-04-08T16:20:17.884102-07:00>
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] ------------ on execution zone: switch.dummy_1--------
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] ------------Irrigation Manually triggered, rain sensor not evaluated--------
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] watering adjustment factor is 0.5
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] Start water:1, water_adj:0.5 wait:0, repeat:1
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] switch data:{'entity_id': 'switch.dummy_1'}
2021-04-08 16:29:42 DEBUG (MainThread) [custom_components.irrigationprogram.switch] run switch repeat:1

Hi,

Both of these issues are expected behaviours:

The component is designed to work in minute intervals so if your run time is 1 minute it will always run for 1 minute, I round up the result of applying the factor to the run time, if the adjuster is 0 and zone will not run. Try it with 2 minutes and it will reduce to 1 minute if set at 0.5. I really didnā€™t think anyone would require less than 1 minute watering intervals.

Repeat always defaults to 1 internally, a repeat of 0 will end the zone immediately as the expectation is the zone will run at least once. I could remove this if you have a particular use case for it.

ah ha!

k, makes sense, no use case, just testing and noticed. reset zones to 2 min runtime with 0.5 adjust and zone runs for 1 minute as expected:)

2 other questionsā€¦

what is the dummy rain sensor (switch) in the Lovelace config used for? is it needed?

same question with the input booleans in the yaml. is it needed?

    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_5:
      dummy_rain_sensor:

This is just part of my test harness to emulate a real rain sensor. It is a template boolean sensor that just mirrors the state of an input_boolean. I wanted to provide a fully working config that users can swap out with their own sensors and switches.

The other input booleans support options in the config:

  • irrigation_on - this is an input can be used in the irrigation_on zone attribute to turn zones off.
  • Irrigation_config - this is used in the UI to show and hide configuration items
  • irrigation_ignore_rain_sensor - is used in the zone config to allow a zone to temporarily ignored the state of the rain sensor ignore_rain_sensor, again a optional setting

Thank Peterā€¦ thatā€™s kinda what I figured.

I will remove it from the Lovelace and keep it in the yaml for testing if needed.

Took a bit, but itā€™s all up, running and tested, and working as expected!

GREAT WORK! MUCH APPRECIATED!

Dave

Thanks Dave,

I feel like this is a better solution than requiring two components, it is more stable and a little less complex to maintain.

While a little more complicated to configure it is more flexible.

New minor version:

Fixing a bug where the last run date was not populated correctly after a HASS restart. This impacts programs running based on the Frequency option.

Hi Peterā€¦

lovelace configuration questionā€¦

I have 3 programs setup
program_1
program_2
program_3

what bits do I need to add to lovelace to have the last_ran attribute displayed under them at all times?
I see how you did it with the conditional remaining attribute, but I canā€™t seem to get last_ran to display in my default view attached.

Thanx in advance

dave

Hi Dave,

Here is some sample yaml to add an attribute to the dashboard. The last four lines is the new bit to add, the first section is showing where I added it to the test harness.

type: entities
entities:
  - type: section
    label: Morning - run days example
  - entity: switch.morning
  - entity: switch.morning
    type: attribute
    attribute: last_ran
    name: Last Ran

Cheers, Pete