Any good ideas are welcome. Nordpool Energy Price per hour

Are there any way to easily display average monthly prices on Nordpool?

2 Likes

So it seems that Nordpool changed something.

The webpage i have as a bookmark now says

Oops!

That page doesn’t seem to exist! Try to use the search bar at the top bar to find content you are looking for.

Also the integration says “Import error”

Maybe the nordpool integration needs a bit of love :slight_smile:

I’ve got an interesting situation.

I have 2 separate systems under same local network. Raspberry Pi 4 4GBs with HAOS + all the latest updates. Both have Norpool component installed from HACS and corresponding definitions in configuration.yaml. I believe there is also a graphical way of setting up them, but since I needed to do some testing with variables (mainky additional costs, precision etc.), I took the yaml route.

The 2 systems are coonnected with remote home asistant -integration.

Now, it seems that when both systems initialize during restart, they of course run the settings from the yaml. It looks like that running the yaml from either machine has an effect on the other one as well, that is, when restarting the other, the other one also initializes. I can see this from the fact that the entity (nordpool_kwh_fi_eur_4_095_024) set by Nordpool goes for brief to undefined or null etc. ( I do not recall what exatcly)

Also, the system does not seem to alwyas know, how it should apply the additional costs -setting.

When looking at core.config_entries at /config/.storage folder of Pi, I can see that it differs to config I have in yaml, most dominantly the additional cocts, which in configuration.yaml is

additional_costs: 0.0756372

but in core.config_entries it has the default setting:

            {
                "entry_id": "xxxxxxxxxxxxxxxxxxxxxxxxx",
                "version": 1,
                "domain": "nordpool",
                "title": "Nordpool",
                "data": {
                    "region": "FI",
                    "currency": "EUR",
                    "VAT": true,
                    "precision": 4,
                    "low_price_cutoff": 0.95,
                    "price_in_cents": true,
                    "price_type": "kWh",
                    "additional_costs": "{{0.0|float}}"
                },
                "options": {},
                "pref_disable_new_entities": false,
                "pref_disable_polling": false,
                "source": "user",
                "unique_id": null,
                "disabled_by": null
            },

I have in general not been messing around manually with core.config_entries due to it’s nature as a system -type of file

Q1: Is there a problem, when 2 separate systems from the same ip connects with the Nordpool component to their system? Can it cause some kind of confusion?

Q2: Should I do something (what?) with the obvious conflict between configyration.yaml and core.config_entries described above?

I am using this but today I updated apexcharts to version 2.0.1 and there is an error:

/// apexcharts-card version 2.0.1 
/// value.series[0] is not a ChartCardSeriesExternalConfig value.series[0].extend_to_end is extraneous value.series[0].extend_to_end is extraneous

any one an idea how to fix this?

Apexcharts changes: extend_to_end replaced by extend_to: , possible values are now and end.
Best, JR

Thanks Foxy. I change it to code below and I can see the graph again:

type: custom:apexcharts-card
hours_12: false
header:
  show: true
  title: Nordpool Prize -> 48 hours
  show_states: true
now:
  show: true
  color: '#ff0000'
  label: Now
graph_span: 2d
span:
  start: day
series:
  - entity: sensor.nordpool_kwh_oslo_nok_2_10_025
    name: Today
    unit: øre/kWh
    data_generator: |
      return entity.attributes.raw_today.map((entry) => {
        return [new Date(entry.start), entry.value * 100];
      });
    type: column
    show:
      legend_value: false
      in_header: false
    extend_to: end
  - entity: sensor.nordpool_kwh_oslo_nok_2_10_025
    name: Tomorrow
    unit: øre/kWh
    data_generator: |
      return entity.attributes.raw_tomorrow.map((entry) => {
        return [new Date(entry.start), entry.value * 100];
      });
    type: column
    show:
      legend_value: false
      in_header: false
3 Likes

Why did you update apexcards ?

Asking because in the last days my apexcharts with Nordpool prices for today and tomorrow has been very spotty.

Today i only have the price from 00-01 and on the card for tomorrow i have no prices at all.

If you experienced something similar and upgraded because of this i am very interested in knowing.

There are some issues with Nordpool, causing the next day not to be visible once in a while (restarting HA will get the correct prices but that is only a work around). This has nothing to do the the apexcards. I updated the apexcards because there was a new release, no other reason.

I have that problem also, did it resolve the issue with not showing the next day prices. ?

Nevermind, it seems there was probably some error in 2022.5, that they fixed in 2202.5.1, all is working again.

After updating to the latest May release Nordpool integration fails here.

Setup failed for custom integration nordpool: Unable to import component: cannot import name ‘EVENT_TIME_CHANGED’ from ‘homeassistant.const’ (/usr/src/homeassistant/homeassistant/const.py)

If anybody interested, I used some code from here and adjusted a bit for a better Apex Chart: [Question] Is it possible to get all 48 price values into one graph? · Issue #19 · custom-components/nordpool · GitHub

type: custom:apexcharts-card
graph_span: 48h
span:
  start: day
  offset: +0H
header:
  title: Electricity Price
  show: true
  show_states: false
  colorize_states: true
hours_12: false
stacked: false
experimental:
  color_threshold: true
all_series_config:
  show:
    legend_value: false
    datalabels: false
    extremas: true
    in_brush: true
  float_precision: 3
  type: area
  invert: false
  fill_raw: last
  color_threshold:
    - value: -1
      color: 1E90FF
    - value: 0.06
      color: '008000'
    - value: 0.19
      color: DAA520
    - value: 0.25
      color: FF0000
now:
  show: true
  label: Now
  color: red
series:
  - entity: sensor.nordpool_kwh_ee_eur_3_05_02
    name: Current day
    opacity: 0.7
    extend_to: false
    data_generator: |
      return entity.attributes.raw_today.map((start, index) => {
        return [new Date(start["start"]).getTime(), entity.attributes.raw_today[index]["value"]];
      });
  - entity: sensor.nordpool_kwh_ee_eur_3_05_02
    name: Tomorrow
    opacity: 0.5
    data_generator: |
      return entity.attributes.raw_tomorrow.map((start, index) => {

        return [new Date(start["start"]).getTime(), entity.attributes.raw_tomorrow[index]["value"]];

      });
apex_config:
  chart:
    height: 400px
    animations:
      enabled: true
      easing: easeinout
      speed: 800
      animateGradually:
        enabled: true
        delay: 150
  zoom:
    enabled: true
    type: x
    autoScaleYaxis: true
    zoomedArea:
      fill:
        color: '#90CAF9'
        opacity: 0.4
      stroke:
        color: '#0D47A1'
        opacity: 0.4
        width: 1
  legend:
    show: false
    floating: true
    offsetY: 25
  yaxis:
    opposite: false
    reversed: false
    logarithmic: false
    decimalsInFloat: 2
    labels:
      show: true
    tooltip:
      enabled: true
    crosshairs:
      show: true
  xaxis:
    labels:
      show: true
      rotate: -45
      rotateAlways: true
    logarithmic: true
  stroke:
    show: true
    curve: stepline
    lineCap: butt
    colors: undefined
  plotOptions:
    candlestick:
      colors:
        upward: '#00B746'
        downward: '#EF403C'
      wick:
        useFillColor: true
  markers:
    size: 1
  grid:
    show: true
    strokeDashArray: 1
    position: front
    xaxis:
      lines:
        show: true

Change the entity and play with color threshhold values to suit you.

20 Likes

thanks for this!

1 Like

Taking now a closer look on costs side of things.

From the component description:

   # The price result of the additional_costs template expects this additional cost to be in kWh and not cents as a float

Can someone please clarify, what this sentence means?

“…additional costs to be in kWh” means in other words that the units of currency and energy are the same (“currency = kWh”), which of course cannot be.

“…and not cents as a float” ???

Basically I need to to know, whether additionals costs are per kWhs or are they per hour type of things? The senttence above probably takes some position in that, but I don’t undestand the sentence at all.

I also need to insert both kWh -based and hour -based fixed costs, so how is this done?

nordpool integration has some nasty bug - it cannot do properly dynamic delivery cost calculation for future use. It will add only currently active price.

Thus I made external proper calculation:

input_number:
  sadales_tikls_day:
    name: "Sadales tīkls dienas tarifs (Eur/kWh)"
    initial: 0.051
    min: 0
    max: 10.00
    step: 0.001
    mode: box
  sadales_tikls_night:
    name: "Sadales tīkls brivdienu un nakts tarifs (Eur/kWh)"
    initial: 0.027
    min: 0
    max: 10.00
    step: 0.001
    mode: box

  - platform: template
    sensors:
      electricity_price:
        friendly_name: "Nordpool + Sadales Tīkls"
        icon_template: mdi:currency-eur
        unit_of_measurement: "EUR/kWh"
        value_template: '{% if now().weekday() < 5 and ("07" | int <=  now().hour | int < "23" | int) %}{{state_attr("sensor.nordpool_kwh_lv_eur_4_08_0", "current_price") + states("input_number.sadales_tikls_day")|float }}{% else %}{{state_attr("sensor.nordpool_kwh_lv_eur_4_08_0", "current_price") + states("input_number.sadales_tikls_night")|float }}{% endif %}'
        attribute_templates:
          today: >
            {%- set y = states.sensor.nordpool_kwh_lv_eur_4_08_0.attributes.today -%}
            {%- set ns = namespace (z=[]) -%}
            {%- for i in states.sensor.nordpool_kwh_lv_eur_4_08_0.attributes.today -%}
              {%- if loop.index0 >= 7 and loop.index0 < 23 and now().weekday() < 5 -%}
                {%- set ns.z = ns.z + [(y[loop.index0]|float+ states('input_number.sadales_tikls_day')|float)|round(4)] -%}
              {%- else -%}
                {%- set ns.z = ns.z + [(y[loop.index0]|float+ states('input_number.sadales_tikls_night')|float)|round(4)] -%}
              {%- endif -%}
            {%- endfor -%}
            {{ ns.z }}
            
      electricity_price_today_low_1h:
        friendly_name: "Lowest 1h price today"
        value_template: >
          {%- set sorted_prices = state_attr('sensor.electricity_price','today')|sort %}
          {{ states('sensor.electricity_price')|float <= sorted_prices[0]|float }}

      electricity_price_today_low_2h:
        friendly_name: "Lowest 2h price today"
        value_template: >
          {%- set sorted_prices = state_attr('sensor.electricity_price','today')|sort %}
          {{ states('sensor.electricity_price')|float <= sorted_prices[1]|float }}

      electricity_price_today_low_3h:
        friendly_name: "Lowest 3h price today"
        value_template: >
          {%- set sorted_prices = state_attr('sensor.electricity_price','today')|sort %}
          {{ states('sensor.electricity_price')|float <= sorted_prices[2]|float }}
.......

Then it is a matter to craft and automation based on those lowest x hour True or False status.

1 Like

Ok… Brand new home assistant user here. With the current energy prices I realized I had to do something about the energy consumption scheduling in my house (I have some humidity control equpiment in the basement which use a LOT of power…), and found home assistant. Im not yet very familiar with stuff you veterans think is obvious, so hope I don’t ask too silly questions :wink:
I’ve setup a home assistant and installed HACS, then I installed the nordpool integration. Then I installed a sensor (nordpool_kwh_se4_sek_3_10_025) and now I think I’m good to go to actually start to use it (?).
My goal is to know the X number of cheapest hours today/tomorrow, and only allow the equpiment to run those cheap hours. I don’t yet know X, since that depends on the humidity in the basement (which I also already monitor via home assistant actually).
My next step is to create a… what? (Where I can do some calculation and output if the current hour is among the cheapest known)
I haven’t yet understood the work flow for these things, so if someone is kind enough to just describe the overall concept what the steps are it would help a lot :slight_smile:
In the end I conceptually think I want multiple inputs for the basement equipment, like “current price is ok” (it’s amont the lowest X), “humidity is not ok” (overrides price check so it runs anyway) and so on.

Thanks is advance!

Hi Daffy951
Controling based on Nordpool price can be hard based on the need.
Say example that you are expecting to have car fully charged in the morning and that takes say 3 houres. Then you know that you need to find the 3 lowest houres.

If doing the same for say a heating system or in youre case humidity there will be more varibels. Maby some critical upper limmit that the equipment should run no mater the cost. Say that its raining outside you might need to run the controller 8h that day, and some othere days just 1 houre.

If you like to start with somthing less complicated you should be able to use the attribute “average” to compare the current price with the average. Supplie energy if current is lower then average.
This would give that the controller atlest have power during several of houres a day and avoiding the most expensive houres.

I know that this is not really what you asked about. You might be able to build what you are asking about, however I think you need to do logic to first find out how many houres a day that the equipent needs to run and what varibles is effect that amount of houres from day to day.

To do above you need to look into allot of template and logic (Templating - Home Assistant), you can test this out in under “development tools” → “template”

//Nicklas

Hi @Daffy951,

I have a similar need for which I created a template sensor for. I want to run my pool pump on the cheap hours, and I want it to run for 12 hrs a day with no longer pauses that 10 hrs.

For this I created a template sensor which state contains the median, and have a few attributes that can be used for automations: tomorrow, tomorrow_valid, below_median_now, unit_of_measurement: friendly_name

This sensor I use in my automations to turn on/off the pool pump. I use a “protection” automation that ensures that the pump are not off for too long, simply by checking “for 10 hours”

You can likely build upon this sensor for your needs:

sensor:
  - platform: template
    sensors:
      nordpool_eo4_median:
        friendly_name: "Nordpool EO4 Median"
        unit_of_measurement: 'SEK/kWh'
        value_template: >
          {{average((state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'today') | sort())[11],
                    (state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'today') | sort())[12]) | 
            round(3) }}
        attribute_templates:
          tomorrow: >
            {% if state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'tomorrow_valid') %}
            {{average((state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'tomorrow') | sort())[11],
                      (state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'tomorrow') | sort())[12]) | 
              round(3) }}
            {% endif %}
          tomorrow_valid: >
            {% if state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'tomorrow_valid') %}
            True
            {% endif %}
          below_median_now: >
            {% if state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'current_price') <= 
                  average((state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'today') | sort())[11],
                          (state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'today') | sort())[12]) | 
                  round(3) %}
            True
            {% else %}
            False
            {% endif %}

Come to think of if, this template will likely fulfill your needs. Change HRS_ON to how may hours you need your system to run.

{% set HRS_ON = 11 %}
{% set M1 = HRS_ON - 1 %}
{% set M2 = M1+1 %}
{{average((state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'today') | sort())[M1],
          (state_attr('sensor.nordpool_kwh_se4_sek_3_095_025', 'today') | sort())[M2]) | 
   round(3) }}

/Marcus

4 Likes

I have made an attempt to control my pool heating to use the cheapest hours. Based on the weather forecast and old heating data, i made a forecast how much heating needed to keep the pool temperature on the desired level. Then I used the Nordpol price info for the next day to figure out exactly which hours to heat my pool.

This system worked quite well. However, I couldn’t see any real advantage compared to a much simpler algorithm where I just avoid to heat during expensive hours. This control system is a implemented as a Phyton script. I plan to implement this in Home Assistant as well and I will definitely go for the simple solution. I have already implemented this algorithm to control floor heating in my house, so I will just extend this to include the pool heating as well.

So keep it simple. This is.my best advice!

I started to very complicated algorithms but eventually i ended up using 36h price if tomorrows prices are released.
Because nordpool sensor sometimes gives tomorrow valid due timezone differnece im checking if tomorrow 5th price is valid…

36h
if todays prices are cheaper then tomorrows, il using more today, and when tomorrow is cheaper, then stop using today

{% if state_attr('sensor.nordpool_mwh_ee_eur_3_099_0','tomorrow')[5] %}
{{(state_attr('sensor.nordpool_mwh_ee_eur_3_099_0','tomorrow') | sort)[6]>= state_attr('sensor.nordpool_mwh_ee_eur_3_099_0','current_price') }}
{%- else -%}
{{ (state_attr('sensor.nordpool_mwh_ee_eur_3_099_0','today') | sort)[6] >= state_attr('sensor.nordpool_mwh_ee_eur_3_099_0','current_price') }}
{%- endif %}

24h

{{ (state_attr('sensor.nordpool_mwh_ee_eur_3_099_0','today') | sort)[6] >= state_attr('sensor.nordpool_mwh_ee_eur_3_099_0','curr
ent_price') }}
1 Like

It would be nice to have an average, min and max for today, tomorrow and total (today and tomorrow if it is available).
I would think it is not too difficult to implement in the integration.
Or are there good reasons why not to do this?

2 Likes