Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {# Fra late_hour og frem tages næste dag med i beregningen af billigste priser #}
- {% set late_hour = 20 %}
- {% set hour = now().hour %}
- {% set day = now().day %}
- {% set data = namespace(prices=[]) %}
- {% set l=(state_attr('sensor.elpriser_raw', 'records') ) %}
- {% set antal = min(l | count, 22 if hour < late_hour and day|int==l[0].HourDK[8:10]|int else 46) %}
- {% for i in range(antal) %}
- {% if day | float + (hour>=late_hour) >= l[i].HourDK[8:10] | float %}
- {% if hour>= min(late_hour,22) or hour | float < l[i].HourDK[11:13] | float %}
- {% set avg = ((l[i].TotalPriceDKK | float + l[i+1].TotalPriceDKK | float + l[i+2].TotalPriceDKK | float) / 3) | round(2) %}
- {% set data.prices = data.prices + [{"hour": i, "avgprice":avg}] %}
- {% endif %}
- {% endif %}
- {% endfor %}
- {% set prices = data.prices | sort(attribute='avgprice') %}
- Aktuelt er elprisen {{state_attr('sensor.elpriser', 'current_price') | round(2) }} kr pr kWh.
- Billigste tretimersperiode er mellem kl. {{ l[prices[0].hour].HourDK[11:13] }} og {{ l[prices[0].hour+2].HourDK[11:13]|int+1 }} med en gns.pris på {{ prices[0].avgprice}} kr/kWh
- Tid {{ l[prices[0].hour].HourDK[11:16] }} / Pris {{ l[prices[0].hour].TotalPriceDKK }}
- Tid {{ l[prices[0].hour+1].HourDK[11:16] }} / Pris {{ l[prices[0].hour+1].TotalPriceDKK }}
- Tid {{ l[prices[0].hour+2].HourDK[11:16] }} / Pris {{ l[prices[0].hour+2].TotalPriceDKK }}
- Næstbilligste periode er mellem kl. {{ l[prices[1].hour].HourDK[11:13] }} og {{ l[prices[1].hour+2].HourDK[11:13]|int+1 }} med en gns.pris på {{ prices[1].avgprice }} kr/kWh
- Tid {{ l[prices[1].hour].HourDK[11:16] }} / Pris {{ l[prices[1].hour].TotalPriceDKK }}
- Tid {{ l[prices[1].hour+1].HourDK[11:16] }} / Pris {{ l[prices[1].hour+1].TotalPriceDKK }}
- Tid {{ l[prices[1].hour+2].HourDK[11:16] }} / Pris {{ l[prices[1].hour+2].TotalPriceDKK }}
Add Comment
Please, Sign In to add comment