ok all, I have now got a much nicer interface and working watering day setup. In terms of what I want the end solution to be, its only missing the rain / weather conditions which I will sort out in the near future. I have to say a big thanks to @petro and @anon43302295 for their work helping me get the watering day side of things working.
again, this is in a package called reticulation.yaml
########################################
#
# This is a full reticulation
# control package using DarkSky
# weather prediction to
# prevent watering if rain
# is expected, or occured recently
# with local moisture sensor data
# as well
#
########################################
# Weather prediction setup
sensor:
- platform: darksky
api_key: !secret darksky_api_key
name: Reticulation Weather
forecast:
- 1
update_interval: '00:30:00'
monitored_conditions:
- precip_intensity
- precip_probability
- precip_intensity_max
# - summary
# - icon
# - temperature
# - apparent_temperature
# - wind_speed
# - wind_bearing
# - cloud_cover
# - humidity
# - hourly_summary
# - daily_summary
# - temperature_max
# - temperature_min
# - apparent_temperature_max
- platform: template # determine if today is selected as a watering day for program 1
sensors:
retic_program1_watering_day:
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:
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') }}
# Calculations for rain to stop reticulation
# to be completed later
# Reticulation control panel setup
input_datetime:
retic_program1_start_time: # program start time control
name: Program 1 Start Time
has_date: false
has_time: true
initial: '04:00'
retic_program2_start_time:
name: Program 2 Start Time
has_date: false
has_time: true
initial: '18:00'
input_number:
retic_program1_station1_run_time: # station run time control
name: Station 1 Run Time
initial: 10
min: 0
max: 30
step: 1
icon: mdi:camera-timer
retic_program1_station2_run_time:
name: Station 2 Run Time
initial: 10
min: 0
max: 30
step: 1
icon: mdi:camera-timer
retic_program2_station1_run_time:
name: Station 1 Run Time
initial: 10
min: 0
max: 30
step: 1
icon: mdi:camera-timer
retic_program2_station2_run_time:
name: Station 2 Run Time
initial: 10
min: 0
max: 30
step: 1
icon: mdi:camera-timer
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_station1_manual_run:
name: Station 1 ON Manual
icon: mdi:arrow-right-drop-circle
retic_station2_manual_run:
name: Station 2 ON Manual
icon: mdi:arrow-right-drop-circle
retic_program1_enable:
name: Enable
retic_program2_enable:
name: Enable
group: # frontend interface setup
retic_manual:
control: hidden
name: 'Manual Control'
entities:
- input_boolean.retic_station1_manual_run
- input_boolean.retic_station2_manual_run
retic_program1:
control: hidden
name: 'Program 1'
entities:
- input_boolean.retic_program1_enable
- script.retic_program1_run
- input_datetime.retic_program1_start_time
- 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
- 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
switch: # Solenoid control (will be signals to NodeMCU)
- platform: mqtt
name: "Retic Station 1 Valve"
state_topic: "retic/station1/state"
command_topic: "retic/station1/cmd"
payload_on: "1"
payload_off: "0"
optimistic: false
qos: 0
retain: true
- platform: mqtt
name: "Retic Station 2 Valve"
state_topic: "retic/station2/state"
command_topic: "retic/station2/cmd"
payload_on: "1"
payload_off: "0"
optimistic: false
qos: 0
retain: true
automation:
- 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.state == (states.input_datetime.retic_program1_start_time.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'
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.state == (states.input_datetime.retic_program2_start_time.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'
action:
- service: script.turn_on
entity_id: script.retic_program2_run
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:{{ 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_station_1_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:{{ 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_station_1_valve
and this in in groups.yaml for the frontend tab
retic:
name: Retic
view: yes
icon: mdi:barley
entities:
- group.retic_program1
- group.retic_program2
- group.retic_manual
which should all then give you this interface:
and if you click the watering days section:
and clicking the run times section gives:
You can disable a program if you want (without having to turn off all the watering days). The program run will allow you to force the program to run now, or shows when it is currently running plus allows you to stop it. Manual station control is pretty obvious on the right hand side if you want to force a station for sprinkler tester etc.
It is currently set up for 2 programs and 2 stations but the code can be replicated to as many as you want very easily.
I hope you like it!