Just a little update on my config because @Mikkaat was asking. There is some code commented out because I’m still not 100% happy that it’s complete, but it all works well. Here you go mate:-
ESPhome code on NodeMCU:
esphome:
name: ha_retic_controller_1
platform: ESP8266
board: nodemcuv2
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.0.61
gateway: 192.168.0.1
subnet: 255.255.255.0
api:
logger:
web_server:
port: 80
ota:
password: !secret ota_password
switch:
- platform: gpio
name: "Retic Station 1 Valve"
id: s1
icon: mdi:water-pump
pin:
number: D1
inverted: true
- platform: gpio
name: "Retic Station 2 Valve"
id: s2
icon: mdi:water-pump
pin:
number: D2
inverted: true
# - platform: gpio
# name: "Retic Station 3 Valve"
# id: s3
# icon: mdi:water-pump
# pin:
# number: D5
# inverted: true
# - platform: gpio
# name: "Retic Station 4 Valve"
# id: s4
# icon: mdi:water-pump
# pin:
# number: D6
# inverted: true
- platform: gpio
name: "Retic Bore Control"
id: p1
icon: mdi:water-pump
pin:
number: D7
inverted: true
restore_mode: RESTORE_DEFAULT_OFF
binary_sensor:
- platform: gpio
name: "Retic Bore Running"
pin:
number: D8
inverted: false
mode: INPUT_PULLUP
- platform: status
name: "Retic Controller Status"
reticulation.yaml (package)
########################################
#
# This is a full reticulation
# control package using ESPHOMEYAML
# as the soleniod control via a NodeMCU
#
########################################
homeassistant:
customize:
switch.retic_station_1_valve:
icon: mdi:water-pump
switch.retic_station_2_valve:
icon: mdi:water-pump
input_boolean.retic_program1_enable:
icon: mdi:traffic-light
input_boolean.retic_program2_enable:
icon: mdi:traffic-light
sensor:
- platform: template # determine if today is selected as a watering day for program 1
sensors:
retic_program1_watering_day:
entity_id: input_boolean.retic_program1_monday, input_boolean.retic_program1_tuesday, input_boolean.retic_program1_wednesday, input_boolean.retic_program1_thursday, input_boolean.retic_program1_friday, input_boolean.retic_program1_saturday, input_boolean.retic_program1_sunday, sensor.time
value_template: >
{% set sensor_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
{% set today_name = sensor_names[now().weekday()] %}
{% set entity_id = 'input_boolean.retic_program1_'+today_name %}
{{ is_state(entity_id, 'on') }}
retic_program2_watering_day:
entity_id: input_boolean.retic_program2_monday, input_boolean.retic_program2_tuesday, input_boolean.retic_program2_wednesday, input_boolean.retic_program2_thursday, input_boolean.retic_program2_friday, input_boolean.retic_program2_saturday, input_boolean.retic_program2_sunday, sensor.time
value_template: >
{% set sensor_names = [ 'monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'] %}
{% set today_name = sensor_names[now().weekday()] %}
{% set entity_id = 'input_boolean.retic_program2_'+today_name %}
{{ is_state(entity_id, 'on') }}
# Rain sensors from BOM forecast of today
# possible_rainfall_today:
# entity_id: sensor.bom_forecast_perth_weather_forecast_0
# friendly_name: "Possible Rainfall Today"
# value_template: >
# {{ state_attr('sensor.bom_forecast_perth_weather_forecast_0', 'Possible Rainfall') | replace("mm", "") | float }}
# chance_of_rain_today:
# entity_id: sensor.bom_forecast_perth_weather_forecast_0
# friendly_name: "Chance Of Rain Today"
# value_template: >
# {{ state_attr('sensor.bom_forecast_perth_weather_forecast_0', 'Chance of Rain') | replace("%", "") | float }}
input_datetime:
retic_program1_start_time_1: # program start time control
name: Program 1 Start Time 1
has_date: false
has_time: true
retic_program1_start_time_2:
name: Program 1 Start Time 2
has_date: false
has_time: true
retic_program2_start_time_1:
name: Program 2 Start Time 1
has_date: false
has_time: true
retic_program2_start_time_2:
name: Program 2 Start Time 2
has_date: false
has_time: true
input_number:
retic_program1_station1_run_time: # station run time control
name: Station 1 Run Time
min: 0
max: 30
step: 1
icon: mdi:camera-timer
retic_program1_station2_run_time:
name: Station 2 Run Time
min: 0
max: 30
step: 1
icon: mdi:camera-timer
retic_program2_station1_run_time:
name: Station 1 Run Time
min: 0
max: 30
step: 1
icon: mdi:camera-timer
retic_program2_station2_run_time:
name: Station 2 Run Time
min: 0
max: 30
step: 1
icon: mdi:camera-timer
allowable_rain_quantity:
name: 'Allowed Rain (mm)'
min: 0
max: 5
step: 0.1
icon: mdi:cup-water
allowable_rain_percentage:
name: 'Allowed Rain (%)'
min: 0
max: 100
step: 1
icon: mdi:water-percent
input_boolean:
retic_program1_monday: # watering day selections for program 1
name: Monday
retic_program1_tuesday:
name: Tuesday
retic_program1_wednesday:
name: Wednesday
retic_program1_thursday:
name: Thursday
retic_program1_friday:
name: Friday
retic_program1_saturday:
name: Saturday
retic_program1_sunday:
name: Sunday
retic_program2_monday: # watering day selections for program 2
name: Monday
retic_program2_tuesday:
name: Tuesday
retic_program2_wednesday:
name: Wednesday
retic_program2_thursday:
name: Thursday
retic_program2_friday:
name: Friday
retic_program2_saturday:
name: Saturday
retic_program2_sunday:
name: Sunday
retic_program1_enable: # enable program to run
name: Enable
retic_program1_start_time1_enable:
name: Prog 1 Start 1 Enable
retic_program1_start_time2_enable:
name: Prog 1 Start 2 Enable
retic_program2_enable:
name: Enable
retic_program2_start_time1_enable:
name: Prog 2 Start 1 Enable
retic_program2_start_time2_enable:
name: Prog 2 Start 2 Enable
retic_station_1_run:
name: Station 1 Run
retic_station_2_run:
name: Station 2 Run
retic_rain_parameters_met: # set to ON if rain today values are below levels set in input_numbers
name: Rain Parameters Met
icon: mdi:water
retic_rain_override: # set to ON to run retic even if rain parameters are not met
name: Rain Override
icon: mdi:water
group: # frontend interface setup
retic_manual:
control: hidden
name: 'Manual Control'
entities:
- switch.retic_station_1_valve
- switch.retic_station_2_valve
retic_program1:
control: hidden
name: 'Program 1'
entities:
- input_boolean.retic_program1_enable
- script.retic_program1_run
- input_datetime.retic_program1_start_time_1
- group.retic_program1_watering_days
- group.retic_program1_run_times
retic_program2:
control: hidden
name: 'Program 2'
entities:
- input_boolean.retic_program2_enable
- script.retic_program2_run
- input_datetime.retic_program2_start_time_1
- group.retic_program2_watering_days
- group.retic_program2_run_times
retic_program1_watering_days:
control: hidden
name: 'Watering days'
icon: mdi:calendar-multiple-check
entities:
- input_boolean.retic_program1_monday
- input_boolean.retic_program1_tuesday
- input_boolean.retic_program1_wednesday
- input_boolean.retic_program1_thursday
- input_boolean.retic_program1_friday
- input_boolean.retic_program1_saturday
- input_boolean.retic_program1_sunday
retic_program2_watering_days:
control: hidden
name: 'Watering days'
icon: mdi:calendar-multiple-check
entities:
- input_boolean.retic_program2_monday
- input_boolean.retic_program2_tuesday
- input_boolean.retic_program2_wednesday
- input_boolean.retic_program2_thursday
- input_boolean.retic_program2_friday
- input_boolean.retic_program2_saturday
- input_boolean.retic_program2_sunday
retic_program1_run_times:
control: hidden
name: 'Run times'
icon: mdi:camera-timer
entities:
- input_number.retic_program1_station1_run_time
- input_number.retic_program1_station2_run_time
retic_program2_run_times:
control: hidden
name: 'Run times'
icon: mdi:camera-timer
entities:
- input_number.retic_program2_station1_run_time
- input_number.retic_program2_station2_run_time
automation:
- alias: Check rain parameters # check that todays rain doesnt need to disable the retic from running ### LOOK AT CHANGING THIS TO A BINARY_SENSOR TEMPLATE
initial_state: 'on'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == ((states.input_datetime.retic_program1_start_time_1.attributes.timestamp - 600) | int | timestamp_custom('%H:%M', False)) }}"
- platform: template
value_template: "{{ states('sensor.time') == ((states.input_datetime.retic_program1_start_time_2.attributes.timestamp - 600) | int | timestamp_custom('%H:%M', False)) }}"
- platform: template
value_template: "{{ states('sensor.time') == ((states.input_datetime.retic_program2_start_time_1.attributes.timestamp - 600) | int | timestamp_custom('%H:%M', False)) }}"
- platform: template
value_template: "{{ states('sensor.time') == ((states.input_datetime.retic_program2_start_time_2.attributes.timestamp - 600) | int | timestamp_custom('%H:%M', False)) }}"
- platform: state
entity_id: input_number.allowable_rain_quantity
- platform: state
entity_id: input_number.allowable_rain_percentage
action:
# - service_template: >
# {% if states('sensor.bom_perth_rain_today') <= states('input_number.allowable_rain_quantity') and states('sensor.possible_rainfall_today') <= states('input_number.allowable_rain_percentage') %}
# input_boolean.turn_on
# {% else %}
# input_boolean.turn_off
# {% endif %}
# entity_id: input_boolean.retic_rain_parameters_met
- service_template: >
input_boolean.turn_{{'on' if states('sensor.bom_perth_rain_today') <= states('input_number.allowable_rain_quantity') and
states('sensor.bom_perth_forecast_chance_of_rain_0') <= states('input_number.allowable_rain_percentage') else 'off'}}
entity_id: input_boolean.retic_rain_parameters_met
# - service_template: >
# input_boolean.turn_{{'on' if states('sensor.bom_perth_rain_today') <= states('input_number.allowable_rain_quantity') or
# states('sensor.possible_rainfall_today') <= states('input_number.allowable_rain_percentage') else 'off'}}
# entity_id: input_boolean.retic_rain_parameters_met
- alias: Reticulation Run Program 1 # start program 1 at designated time if it is enabled and today is selected as a watering day
initial_state: 'on'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program1_start_time_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
- platform: template
value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program1_start_time_2.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.retic_program1_enable
state: 'on'
- condition: state
entity_id: sensor.retic_program1_watering_day
state: 'True'
- condition: or
conditions:
- condition: state
entity_id: input_boolean.retic_rain_parameters_met
state: 'on'
- condition: state
entity_id: input_boolean.retic_rain_override
state: 'on'
action:
- service: script.turn_on
entity_id: script.retic_program1_run
- alias: Reticulation Run Program 2 # start program 2 at designated time if it is enabled and today is selected as a watering day
initial_state: 'on'
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program2_start_time_1.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
- platform: template
value_template: "{{ states('sensor.time') == (states.input_datetime.retic_program2_start_time_2.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.retic_program2_enable
state: 'on'
- condition: state
entity_id: sensor.retic_program2_watering_day
state: 'True'
- condition: or
conditions:
- condition: state
entity_id: input_boolean.retic_rain_parameters_met
state: 'on'
- condition: state
entity_id: input_boolean.retic_rain_override
state: 'on'
action:
- service: script.turn_on
entity_id: script.retic_program2_run
- alias: Reticulation Station 1 Run
initial_state: 'on'
trigger:
platform: state
entity_id: input_boolean.retic_station_1_run
action:
- service_template: >
{% if is_state('input_boolean.retic_station_1_run', 'on') %}
script.retic_station_1_run
{% else %}
script.retic_station_1_stop
{% endif %}
- alias: Reticulation Station 2 Run
initial_state: 'on'
trigger:
platform: state
entity_id: input_boolean.retic_station_2_run
action:
- service_template: >
{% if is_state('input_boolean.retic_station_2_run', 'on') %}
script.retic_station_2_run
{% else %}
script.retic_station_2_stop
{% endif %}
- alias: Reticulation Controller Offline Alert
initial_state: 'on'
trigger:
platform: state
entity_id: binary_sensor.retic_controller_status
to: 'off'
for:
minutes: 5
action:
- service: notify.pushbullet
data:
message: 'Retic Controller Offline!'
script:
retic_program1_run: #run retic program 1 through each station for selected time
alias: Program 1 Run
sequence:
- service: switch.turn_on
data:
entity_id: switch.retic_station_1_valve
- delay: "00:00:01"
- service: switch.turn_on
data:
entity_id: switch.retic_bore_control
- delay: "00:{{ states('input_number.retic_program1_station1_run_time')|int }}:00"
- service: switch.turn_off
data:
entity_id: switch.retic_station_1_valve
- service: switch.turn_on
data:
entity_id: switch.retic_station_2_valve
- delay: "00:{{ states('input_number.retic_program1_station2_run_time')|int }}:00"
- service: switch.turn_off
data:
entity_id: switch.retic_bore_control
- delay: "00:00:01"
- service: switch.turn_off
data:
entity_id: switch.retic_station_2_valve
retic_program2_run: #run retic program 2 through each station for selected time
alias: Program 2 Run
sequence:
- service: switch.turn_on
data:
entity_id: switch.retic_station_1_valve
- delay: "00:00:01"
- service: switch.turn_on
data:
entity_id: switch.retic_bore_control
- delay: "00:{{ states('input_number.retic_program2_station1_run_time')|int }}:00"
- service: switch.turn_off
data:
entity_id: switch.retic_station_1_valve
- service: switch.turn_on
data:
entity_id: switch.retic_station_2_valve
- delay: "00:{{ states('input_number.retic_program2_station2_run_time')|int }}:00"
- service: switch.turn_off
data:
entity_id: switch.retic_bore_control
- delay: "00:00:01"
- service: switch.turn_off
data:
entity_id: switch.retic_station_2_valve
retic_station_1_run:
alias: Station 1 Run
sequence:
- service: switch.turn_on
data:
entity_id: switch.retic_station_1_valve
- delay: "00:00:01"
- condition: state
entity_id: switch.retic_station_1_valve
state: 'on'
- service: switch.turn_on
data:
entity_id: switch.retic_bore_control
retic_station_1_stop:
alias: Station 1 Stop
sequence:
- service: switch.turn_off
data:
entity_id: switch.retic_bore_control
- delay: "00:00:01"
- condition: state
entity_id: switch.retic_bore_control
state: 'off'
- service: switch.turn_off
data:
entity_id: switch.retic_station_1_valve
retic_station_2_run:
alias: Station 2 Run
sequence:
- service: switch.turn_on
data:
entity_id: switch.retic_station_2_valve
- delay: "00:00:01"
- condition: state
entity_id: switch.retic_station_2_valve
state: 'on'
- service: switch.turn_on
data:
entity_id: switch.retic_bore_control
retic_station_2_stop:
alias: Station 2 Stop
sequence:
- service: switch.turn_off
data:
entity_id: switch.retic_bore_control
- delay: "00:00:01"
- condition: state
entity_id: switch.retic_bore_control
state: 'off'
- service: switch.turn_off
data:
entity_id: switch.retic_station_2_valve
##################
# use a timer instead of the delay for the station runtime
# - service: timer.start
# data_template:
# entity_id: timer.cooking_timer
# duration: '00:{{ states.input_number.timer_minutes.state | int }}:{{ states.input_number.timer_seconds.state | int }}'
lovelace:
- title: Retic
icon: 'mdi:fountain'
background: center / cover no-repeat url("/local/images/back_garden_1.jpg") fixed
cards:
- type: entities
show_header_toggle: false
title: Program 1
entities:
- input_boolean.retic_program1_enable
- script.retic_program1_run
- input_datetime.retic_program1_start_time_1
- input_datetime.retic_program1_start_time_2
- group.retic_program1_watering_days
- group.retic_program1_run_times
- type: entities
show_header_toggle: false
title: Program 2
entities:
- input_boolean.retic_program2_enable
- script.retic_program2_run
- input_datetime.retic_program2_start_time_1
- input_datetime.retic_program2_start_time_2
- group.retic_program2_watering_days
- group.retic_program2_run_times
- type: entities
show_header_toggle: false
title: Manual Control
entities:
- input_boolean.retic_station_1_run
- input_boolean.retic_station_2_run
- type: entities
title: Rain Settings
entities:
- input_number.allowable_rain_percentage
- input_number.allowable_rain_quantity
- input_boolean.retic_rain_parameters_met
- input_boolean.retic_rain_override
show_header_toggle: false
- type: entities
show_header_toggle: false
title: Status
entities:
- entity: binary_sensor.retic_controller_status
secondary_info: last-changed
- entity: switch.retic_station_1_valve
secondary_info: last-changed
- entity: switch.retic_station_2_valve
secondary_info: last-changed
- entity: switch.retic_bore_control
secondary_info: last-changed
- binary_sensor.retic_bore_running
EDIT: I only have 2 stations because it’s running on a bore which has enough pressure and flow to do all the front of the house on one station and all the back on another.