nordpool
nordpool copied to clipboard
Presenting the hour with lowest energy cost.
Is your feature request related to a problem? Please describe. Its not a problem of existing system . But it would help me to get a hour I.E 17.00 when the energy cost is as lowest for the day. I will use this information to start heating my water tank.
Describe the solution you'd like If there could be a parameter with the time coming from the server with the lowest energy cost for the day (date)
Describe alternatives you've considered
Additional context
You need N lowest price hours for that.
You need N lowest price hours for that.
Hi can you describe little more in detail about "N lowest price hour". Is there already a function working and is there any sample/documentation of this ?
You need to use a template sensors. Check the docs for them.
I've following template to get the three cheapest hours during the night (10pm-6am)
- platform: template
sensors:
cheap_night_hour:
friendly_name: "Cheap night hour"
value_template: >-
{%- set ns = namespace(hour_price=[], cheapest_hour=False) %}
{%- set cheap_hours = namespace(number=3) %}
{% if state_attr("sensor.nordpool_kwh_fi_eur_3_095_024", "tomorrow_valid")==true %}
{% for i in range(22, 24) %}
{% set ns.hour_price = ns.hour_price + [(i, states.sensor.nordpool_kwh_fi_eur_3_095_024.attributes.raw_today[i].value)] %}
{%- endfor -%}
{% for i in range(0, 7) %}
{% set ns.hour_price = ns.hour_price + [(i, states.sensor.nordpool_kwh_fi_eur_3_095_024.attributes.raw_tomorrow[i].value)] %}
{%- endfor -%}
{% else %}
{% for i in range(0, 7) %}
{% set ns.hour_price = ns.hour_price + [(i, states.sensor.nordpool_kwh_fi_eur_3_095_024.attributes.raw_today[i].value)] %}
{%- endfor -%}
{% endif %}
{% set hour_price_dict = dict.from_keys(ns.hour_price) %}
{% set sorted_hour_price_dict = hour_price_dict.items()|sort(attribute='1') %}
{% for i in range(0, cheap_hours.number) %}
{% if sorted_hour_price_dict[i].0 == now().hour %}
{% set ns.cheapest_hour = true %}
{% endif %}
{%- endfor -%}
{{ ns.cheapest_hour }}
sensor.cheap_electricity is a boolean and indicates value=true, if current hour is one of three cheapest hours during the night.
This is brilliant :) How could this be edited to work for the entire day?
Hi modified the above code like this.
cheapest_hour_24h:
friendly_name: "Cheapest hour 24h"
entity_id: sensor.cheapest_hour_24h
value_template: >-
{%- set ns = namespace(hour_price=[], cheapest_hour=False) %}
{%- set cheap_hours = namespace(number=3) %}
{% for i in range(0, 23) %}
{% set ns.hour_price = ns.hour_price + [(i, states.sensor.nordpool_kwh_dk2_eur_3_095_025.attributes.raw_today[i].value)] %}
{%- endfor -%}
{% set hour_price_dict = dict.from_keys(ns.hour_price) %}
{% set sorted_hour_price_dict = hour_price_dict.items()|sort(attribute='1') %}
{% for i in range(0, cheap_hours.number) %}
{% if sorted_hour_price_dict[i].0 == now().hour %}
{% set ns.cheapest_hour = true %}
{% else %}
{% set ns.cheapest_hour = false %}
{% endif %}
{%- endfor -%}
{{ ns.cheapest_hour }}
I've following template to get the three cheapest hours during the night (10pm-6am)
- platform: template sensors: cheap_night_hour: friendly_name: "Cheap night hour" value_template: >- {%- set ns = namespace(hour_price=[], cheapest_hour=False) %} {%- set cheap_hours = namespace(number=3) %} {% if state_attr("sensor.nordpool_kwh_fi_eur_3_095_024", "tomorrow_valid")==true %} {% for i in range(22, 24) %} {% set ns.hour_price = ns.hour_price + [(i, states.sensor.nordpool_kwh_fi_eur_3_095_024.attributes.raw_today[i].value)] %} {%- endfor -%} {% for i in range(0, 7) %} {% set ns.hour_price = ns.hour_price + [(i, states.sensor.nordpool_kwh_fi_eur_3_095_024.attributes.raw_tomorrow[i].value)] %} {%- endfor -%} {% else %} {% for i in range(0, 7) %} {% set ns.hour_price = ns.hour_price + [(i, states.sensor.nordpool_kwh_fi_eur_3_095_024.attributes.raw_today[i].value)] %} {%- endfor -%} {% endif %} {% set hour_price_dict = dict.from_keys(ns.hour_price) %} {% set sorted_hour_price_dict = hour_price_dict.items()|sort(attribute='1') %} {% for i in range(0, cheap_hours.number) %} {% if sorted_hour_price_dict[i].0 == now().hour %} {% set ns.cheapest_hour = true %} {% endif %} {%- endfor -%} {{ ns.cheapest_hour }}
sensor.cheap_electricity is a boolean and indicates value=true, if current hour is one of three cheapest hours during the night.
When I was testing your code it started at the lowest hour and run for thee hours in a row , not running at the three cheapest hours.
You can also consider https://github.com/jpulakka/nordpool_diff
Hi modified the above code like this.
cheapest_hour_24h: friendly_name: "Cheapest hour 24h" entity_id: sensor.cheapest_hour_24h value_template: >- {%- set ns = namespace(hour_price=[], cheapest_hour=False) %} {%- set cheap_hours = namespace(number=3) %} {% for i in range(0, 23) %} {% set ns.hour_price = ns.hour_price + [(i, states.sensor.nordpool_kwh_dk2_eur_3_095_025.attributes.raw_today[i].value)] %} {%- endfor -%} {% set hour_price_dict = dict.from_keys(ns.hour_price) %} {% set sorted_hour_price_dict = hour_price_dict.items()|sort(attribute='1') %} {% for i in range(0, cheap_hours.number) %} {% if sorted_hour_price_dict[i].0 == now().hour %} {% set ns.cheapest_hour = true %} {% else %} {% set ns.cheapest_hour = false %} {% endif %} {%- endfor -%} {{ ns.cheapest_hour }}
Very nice. Thank you. Is this just for 1 hour a day or 3 hours a day?
You can also consider https://github.com/jpulakka/nordpool_diff
That was to complicated for me..did not understand a thing :)
It’s indicating only one hour as bellow history
From: flippz @.*** @.>
Sent: den 29 augusti 2022 18:33
To: custom-components/nordpool @.>
Cc: Bach-Danielsson @.>; Author @.>
Subject: Re: [custom-components/nordpool] Presenting the hour with lowest energy cost. (Issue #181)
Hi modified the above code like this.
cheapest_hour_24h: friendly_name: "Cheapest hour 24h" entity_id: sensor.cheapest_hour_24h value_template: >-
{%- set ns = namespace(hour_price=[], cheapest_hour=False) %}
{%- set cheap_hours = namespace(number=3) %}
{% for i in range(0, 23) %}
{% set ns.hour_price = ns.hour_price + [(i, states.sensor.nordpool_kwh_dk2_eur_3_095_025.attributes.raw_today[i].value)] %}
{%- endfor -%}
{% set hour_price_dict = dict.from_keys(ns.hour_price) %}
{% set sorted_hour_price_dict = hour_price_dict.items()|sort(attribute='1') %}
{% for i in range(0, cheap_hours.number) %}
{% if sorted_hour_price_dict[i].0 == now().hour %}
{% set ns.cheapest_hour = true %}
{% else %}
{% set ns.cheapest_hour = false %}
{% endif %}
{%- endfor -%}
{{ ns.cheapest_hour }}
Very nice. Thank you. Is this just for 1 hour a day or 3 hours a day?
— Reply to this email directly, view it on GitHub https://github.com/custom-components/nordpool/issues/181#issuecomment-1230551551 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AJKEKKZERTWKMU5SL2ZGS6DV3TQ33ANCNFSM56TMXYKQ . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AJKEKKYTX25ZMY5R3YCO2ZDV3TQ33A5CNFSM56TMXYK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOJFMLT7Y.gif Message ID: @.*** @.***> >
It would be great if every hour of the day was ranked, from cheapest to most expensive and vise versa. Hours having the same price should have the same rank. Then it would be easy to write automations using the GUI. You can have expressions like this:
"Turn water heater on if cheap_price_rank <= 12" to have the water heater on only on the 12 cheapest hours "Turn off floor heater if expensive_price_rank >=3" to turn the floor heater off the most expensive 3 hours
Try what jpulakka sayd
Try what jpulakka sayd
That package need a better name! It works splendid and need more attention!
Yes it does 👍
So how to modify this if I want the cheapest 3 hours between 06:00 and 22:00?