Setting up a plant watering automation with input variables for irrigation duration, frequency and number of repititions

Hi everyone, I’ve just begun using Home Assistant to monitor and automate some tasks in my indoor garden. So far it’s been working great and has been really fun to learn, but I have to go out of town for a couple of weeks and so want to make sure I’ve gotten everything set up correctly before I leave.

The main thing I’m still wondering about is automatic watering / irrigation. What I am aiming for is: input selectors on my dashboard to be able to select how long the irrigation pumps should run (duration), how often (frequency), and how many times (repeats) – for example, the pumps should run for two minutes, every two days, and this should happen seven times. I’d also like to be able to cancel and reset this automation if necessary.

These are the automations I’ve written so far, but if anyone has any suggestions for improving them, or sees any issues please let me know! Thanks!

- id: '9346510911918'
  alias: First Irrigation
  description: Runs irrigation pump for X amount of time. Triggered at time set in first
    irrigation input date time helper. Also turns on first irrigation boolean to let main irrigation
    automation run after this.
  trigger:
  - platform: time
    at: input_datetime.first_irrigation
  condition:
  - condition: time
    after: input_datetime.day_start
    before: input_datetime.night_start
  action:
  - service: switch.turn_on
    target:
      entity_id: switch.pump
  - delay: "{{ states('input_number.irrigation_duration') | multiply(60) | int }}"
  - service: switch.turn_off
    target:
      entity_id: switch.pump
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.first_irrigation_completed
  mode: single
- id: '8893281833876'
  alias: Irrigation
  description: Irrigating for x minutes, every x days. Only if first
    irrigation has run (input_boolean.first_irrigation_completed is on) and
    is after first irrigation input time date and before night start.
  trigger:
  - platform: state
    entity_id: input_boolean.first_irrigation_completed
    from: 'off'
    to: 'on'
  condition:
  - condition: time
    after: input_datetime.first_irrigation
    before: input_datetime.night_start
  - condition: state
    entity_id: input_boolean.first_irrigation_completed
    state: 'on'
  action:
    repeat:
      count: "{{ states('input_number.irrigation_repeat') | int }}"
      sequence:
        - delay: "{{ states('input_number.irrigation_frequency') | int }}"
        - service: switch.turn_on
          target:
            entity_id: switch.pump
        - delay: "{{ states('input_number.irrigation_duration') | multiply(60) | int }}"
        - service: switch.turn_off
          target:
            entity_id: switch.pump
        - service: counter.increment
          target:
            entity_id:
            - counter.irrigation_counter
    service: counter.reset
    target:
    entity_id: counter.irrigation_counter
  mode: single

Started down this path a couple of years ago and ended up here writing an integration. Might save you some time. Good luck.

2 Likes

There are a few irrigation components/AddOns out there. The one that @rgc99 listed, or this one:

Note: not in any kind a judgement about the named integrations! :slight_smile: Just to note another alternative! :wink:

Very true. I use both as they work together very well. One to accurately calculate the required amount of water and other to manage the system.

1 Like

This one looks like it might be a good fit, thanks @rgc99 !

The HAsmartirrigation integration won’t work because it is designed for outdoor sprinklers and accounts requires a precipitation calculation which won’t be relevant in an indoor garden.