i hope you are all fine.
Today i am seeking help for an automation i have in mind for very long time but was not able to build.
I would like to show the point with a led stripe and color, when i have to have to start drive to work in the morning.
So if there is more traffic, i have to drive a bit more earlier.
Wih the new here sensor, this seems to be realizable.
So here is what i have so far (pretty the same from the example).
i think and im not sure about this, i need then a template sensor, which checks the work_tro sensor.
I need to be at work at 8 AM, so check the current time plus the travel time, if it is then 7.45 AM make the string green, will it be 7.55 AM orange and everything after 8 AM make it red
The rest i could with normal automations, like turn off the string if it is after 8 AM etc etc.
But i have an issue on how to realise the calculöation.
Thanks for sharing. This is exactly what I wanted to accomplish but I came across an issue
I tried to use the above code for an automation I had in mind but the sensor always shows as unavailable and there is an error.
I do have a time sensor set up and I am using a google_travel time sensor as well. I am not sure why I am getting this .
I get this error message: TemplateError(‘OverflowError: timestamp out of range for platform time_t’) while processing template 'Template("{% set arrival = ‘09:55’ %}
work_drive_time_color:
value_template: >-
{% set arrival = '07:40' %}
{% set travel_time = states('sensor.google_travel_time') | float %}
{% set arrival = as_timestamp(strptime(arrival, '%H:%M')) %}
{% set t = as_timestamp(strptime(states('sensor.time'), '%H:%M')) %}
{% set delta = arrival - (t + travel_time * 60) %}
{% if 60*60 <= delta < 15*60 %}
green
{% elif 15*60 <= delta < 5*60 %}
yellow
{% elif 5*60 <= delta <= 0 %}
red
{% else %}
off
{% endif %}
friendly_name: 'Time to Leave for work