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