Hi!
I have a markdown card that updates every day with nordpool prices.
I can’t figure out how to send this text as a notification to my phone.
I have many notifications that are fairly easy to set up, but I can’t figure this out.
Below is the code inside the markdown card
This translates to :
De billigaste 2-timmarna startar imorgon kl 03:00, då
snittpriset är 0.05 cent/kWh
De dyraste 2-timmarna startar imorgon kl 18:00, då
snittpriset är 0.39 cent/kWh
{% set iterativesum = namespace(iter=[]) %}
{% set lowestiter = namespace(kr=2) %}
{% set timelowest = namespace(hr=2) %}
{% set highestiter = namespace(kr=0) %}
{% set timehighest = namespace(hr=0) %}
{% set num_hours = 2 | int %}
{% set nordpoolentity = 'sensor.nordpool_kwh_fi_eur_3_10_024' %}
{% set timemapper = {
0: '00:00',
1 : '01:00',
2 : '02:00',
3 : '03:00',
4 : '04:00',
5 : '05:00',
6 : '06:00',
7 : '07:00',
8 : '08:00',
9 : '09:00',
10 : '10:00',
11 : '11:00',
12 : '12:00',
13 : '13:00',
14 : '14:00',
15 : '15:00',
16 : '16:00',
17 : '17:00',
18 : '18:00',
19 : '19:00',
20 : '20:00',
21 : '21:00',
22 : '22:00',
23 : '23:00',
24: '00:00',
25 : '01:00',
26 : '02:00',
27 : '03:00',
28 : '04:00',
29 : '05:00',
30 : '06:00',
31 : '07:00',
32 : '08:00',
33 : '09:00',
34 : '10:00',
35 : '11:00',
36 : '12:00',
37 : '13:00',
38 : '14:00',
39 : '15:00',
40 : '16:00',
41 : '17:00',
42 : '18:00',
43 : '19:00',
44 : '20:00',
45 : '21:00',
46 : '22:00',
47 : '23:00',
48 : '0:00',
} %}
{% set prices = namespace(price=[]) %}
{% set prices.price = prices.price + state_attr(nordpoolentity, 'today')
%}
{%- if state_attr(nordpoolentity,'tomorrow') | length == 1 -%}
Morgondagens priser ej släppta
{% else %}
{% set prices.price = prices.price + state_attr(nordpoolentity,
'tomorrow') %}
{% endif %}
{%- for n in range(prices.price|length -num_hours +1) -%}
{%- set tempsum= namespace(temp=0) -%}
{%- for i in range(num_hours) -%}
{%- set tempsum.temp = tempsum.temp + prices.price[n+i] -%}
{% endfor -%}
{% set iterativesum.iter = iterativesum.iter + [tempsum.temp] -%}
{% endfor -%}
{% for iter in iterativesum.iter -%}
{%- if loop.index > now().hour -%}
{%- if iter < lowestiter.kr | float -%}
{%- set lowestiter.kr = iter | float -%}
{%- set timelowest.hr = loop.index -1 -%}
{%- endif -%}
{%- if iter > highestiter.kr | float -%}
{%- set highestiter.kr = iter | float -%}
{%- set timehighest.hr = loop.index -1 -%}
{%- endif -%}
{%- endif -%}
{% endfor -%}
De billigaste {{num_hours}}-timmarna startar {% if (timelowest.hr < 24)
%}idag{% else %}imorgon{% endif %} kl {{timemapper[timelowest.hr]}}, då
snittpriset är {{"%.2f"|format(lowestiter.kr/num_hours)}} cent/kWh
De dyraste {{num_hours}}-timmarna startar {% if (timehighest.hr < 24)
%}idag{% else %}imorgon{% endif %} kl {{timemapper[timehighest.hr]}}, då
snittpriset är {{"%.2f"|format(highestiter.kr/num_hours)}} cent/kWh