koburg
(Koburg)
April 25, 2022, 8:10pm
1
I have been playing with some templating for making a sensor who tells me what time the electricity cost is lowest of the day.
in the developer I can get this code to work but not sure about the syntax for putting this in a sensor.
{% set l=state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'raw_today')|sort(attribute='value') %}
cheapest kl. {{l[0].start.hour}}-{{l[0].end.hour}}
I get this result
cheapest
kl. 1-2
this is working but can not get it working in a template sensor can someone point me the right syntax for this to work ?
koburg
(Koburg)
April 26, 2022, 8:19am
2
i solved it my self but it is the lack of documentation.
- platform: template
sensors:
billigsteelpris:
friendly_name: Billigste El Pris idag
unit_of_measurement: "KL."
value_template: >
{% set l=state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'raw_today')|sort(attribute='value') %}
{{l[0].start.hour}}-{{l[0].end.hour}}
This is interesting since I am trying to do something similar, but I am trying to get the cheapest price, not the time windows.
How would I need to write this in order to get the Template to supply the “lowest today” price as Output?