I am trying to create a sensor that will return a color based on how much time is left before I have to leave to get to work by a certain time according to the google map sensor.
The sensor shows as unavailable and I am getting the following error? Could someone help me figure out where I went astray. Many thanks
Not sure where the float is coming from:
TemplateError(‘TypeError: unsupported operand type(s) for +: ‘datetime.datetime’ and ‘float’’) while processing
work_drive_time_color:
value_template: >
{% set arrival = '10:45' %}
{% set travel_time = states('sensor.google_travel_time') | float / 60 %}
{% set arrival = strptime(arrival, '%H:%M') %}
{% set t = strptime(states.sensor.time.state,'%H:%M') %}
{% set delta = arrival.hour + arrival.minute/60 - (t + travel_time) %}
{% if delta*60 <= 15 and delta*60>=0 %}
green
{% elif delta*60 <0 and delta*60 >= -10%}
yellow
{% elif delta*60 <= -10 %}
red
{% else %}
off
{% endif %}