This automation is generally ok, but I’m confident that sometimes the “delays” dont work. Like, it will make it all the way through the automation in just a few minutes. I cannot see how or why the delays would be ignored, skipped, is there any bug with delays at the moment?? Also, is there a better way to do this? Maybe something more accurate?
- alias: "Notify Paul when its time to leave for work"
trigger:
- platform: template
value_template: >
{{ is_state('sensor.time_to_leave_for_work1', 'True') and
is_state('input_select.work_location', 'work1') or
is_state('sensor.time_to_leave_for_work2', 'True') and
is_state('input_select.work_location', 'work2') }}
condition:
- condition: numeric_state
entity_id: sensor.ha_runtime_in_minutes
above: 1
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
- condition: time
after: '06:00:00'
before: '10:00:00'
action:
- service: notify.main_echos
data_template:
message: >-
{% if states('input_select.work_location') == 'work1' %}
work1d on current traffic, you have 15 minutes to leave if you want to get to work1 by {{ states.input_datetime.work_time_paul.attributes.hour }} {{ states.input_datetime.work_time_paul.attributes.minute }}. Traffic is {{ states('sensor.pauls_traffic_density_to_work1') }} today.
{% elif states('input_select.work_location') == 'work2' %}
work1d on current traffic, you have 15 minutes to leave if you want to get to work 2 by {{ states.input_datetime.work_time_paul.attributes.hour }} {{ states.input_datetime.work_time_paul.attributes.minute }}. Traffic is {{ states('sensor.pauls_traffic_density_to_work2') }} today.
{% else %}
I'm not sure where you're going today
{% endif %}
- delay:
minutes: 5
- condition: state
entity_id: input_select.house_mode
state: 'Home'
- service: notify.main_echos
data_template:
message: "You have about 10 minutes to leave if you want to get to work on time"
- delay:
minutes: 10
- condition: state
entity_id: input_select.house_mode
state: 'Home'
- service: notify.main_echos
data_template:
message: "You are now going to be late. Get moving"
Basically I have this sensor which uses a waze sensor for timing
time_to_leave_for_work1:
value_template: >
{% set t = strptime(states.sensor.time.state,'%H:%M') %}
{{ ( t.hour + t.minute / 60 ) > ( state_attr('input_datetime.work_time_paul', 'timestamp')/3600 - 0.25 - states.sensor.time_to_work1.state | int / 60) }}
friendly_name: 'Time to leave for work1'
I guess I could have several of these sensors (this one is for 15 minutes before work). Just looking for some ideas, if anyone else does anything similiar