I’m trying to set a value via a template based on the time of day, I’ve swapped to Octopus Flex and there are only 3 prices through-out the day.
I’d like to build new tiles for my dashboard but with the following template code I only get one value, no matter what the time.
#Octopus Flex Export prices
- platform: template
sensors:
flex_export_price:
friendly_name: “Flex Export Price”
unit_of_measurement: “p”
value_template: >
{% if states(‘sensor.time’) > ‘02:01’ and states.sensor.time.state < ‘05:00’ %}
8.44
{% elif states(states.sensor.time.state) > ‘16:01’ and states.sensor.time.state < ‘19:00’%}
32.36
{% else %} 21.40
{% endif %}
It displays perfectly in the developer tools/template section.
Thanks in advance.