Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template:
- - sensor:
- - name: El billigste 3 timer
- unit_of_measurement: DKK/kWh
- device_class: timestamp
- state: >
- {%- set x = namespace(x = now().hour) %}
- {%- set x.low_price = 99999 %}
- {%- set x.prices = state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'raw_today') + state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'raw_tomorrow') %}
- {%- for n in range(now().hour, (state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'today') | length) + (state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'tomorrow') | length)-2) %}
- {%- set price = (x.prices[n].value + x.prices[n+1].value + x.prices[n+2].value) / 3 %}
- {%- if price < x.low_price %}
- {%- set x.low_price = price %}
- {%- set x.x = n %}
- {%- endif %}
- {%- endfor %}
- {{ x.prices[x.x].start.isoformat() }}
- attributes:
- price: >
- {%- set x = namespace(x = now().hour) %}
- {%- set x.low_price = 99999 %}
- {%- set x.prices = state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'raw_today') + state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'raw_tomorrow') %}
- {%- for n in range(now().hour, (state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'today') | length) + (state_attr('sensor.nordpool_kwh_dk1_dkk_3_10_025', 'tomorrow') | length)-2) %}
- {%- set price = (x.prices[n].value + x.prices[n+1].value + x.prices[n+2].value) / 3 %}
- {%- if price < x.low_price %}
- {%- set x.low_price = price %}
- {%- set x.x = n %}
- {%- endif %}
- {%- endfor %}
- {{ x.low_price | round(3) }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement