replace the 8.33 with 9.
1 Like
The other sensor called time is:
# Example configuration.yaml entry
sensor:
- platform: time_date
display_options:
- 'time'
1 Like
Good call, forgot to include that in the sensor list. I’ve updated my post.
This is what I have - however the time_to_leave_for_work sensor is always true
Sorry im missing something and really appreciate your help
#Binary
- platform: workday
country: 'UnitedKingdom'
workdays: [mon, tue, wed, thu, fri]
# Time-Date Sensor
- platform: time_date
display_options:
- 'time'
- platform: uptime
name: "HA runtime in minutes"
unit_of_measurement: minutes
# Commute to Work
- platform: waze_travel_time
name: Time to Work
origin: zone.home
destination: zone.rob_work
region: 'EU'
- platform: template
sensors:
time_to_leave_for_work:
value_template: >
{% set t = strptime(states.sensor.time.state,'%H:%M') %}
{{ ( t.hour + t.minute / 60 ) > ( 9 - states.sensor.time_to_work.state | int / 60) }}
friendly_name: 'Time to Leave for Work'
entity_id: sensor.time
- platform: template
sensors:
my_traffic_density_to_work:
friendly_name: Traffic to Work
value_template: >
{% if states("sensor.time_to_work") | int >= 30 %}
Heavy
{% elif states("sensor.time_to_work") | int < 30 and states("sensor.time_to_work") | int >= 25 %}
Moderate
{% elif states("sensor.time_to_work") | int < 25 and states("sensor.time_to_work") | int >= 10 %}
Normal
{% else %}
unknown
{% endif %}
entity_id: sensor.time
Mine is true from the moment it becomes true until midnight. Then it becomes false until… the
{{ ( t.hour + t.minute / 60 ) > ( 9 - states.sensor.time_to_work.state | int / 60) }}
is true again. Basically once a day it becomes true that the it’s time to leave for work. If that makes sense.
1 Like
Thank you so much. That explains it!