I have an automation, which I would like to run on a specific day.
The automation runs at Midnight (00:00), and uses a condition to check if it’s the correct day…
I have an input select, input_select.day_picker, with the days of the week in its list.
I’d like my automation to check if TODAY is the day picked in my input select, but I can’t quite work out how to do it.
I know I will probably need a Template based condition, and somehow use now().time().strftime("%A") to find out if today matches the input select… but not sure exactly what code to use.
Hey guys, I just came across this and realised that what you are looking for is very similar to how I have my irrigation system setup. I use input_booleans to select if a day is a watering day or not, then templates to check if today is a watering day. There is a lot more to the code but I have pasted the bits that I think will help with what you need.
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
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
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') }}
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
Hi @sparkydave and thank you for the code! How do you ensure the entity will change the state after it turn to another day. I noticed that it keeps unchanged. Any help on this please?
Not sure if I fully understand what you are asking. Which entity are you referring to? the sensors? All that my code does is give you input_selects for each day of the week, then sensors to see if ‘today’ is selected to ‘on’ or not. When the day changes (ie: midnight) the sensor will automatically change to on/off depending on what the input_select status is for the new day of the week