Any good ideas are welcome. Nordpool Energy Price per hour

For those looking for a simple way to get entso-e spotprices, check out Electricity price right now - Home Assistant REST integration . Simple rest api endpoint (without need for a key), which provides min/max for today and tomorrow, currency conversion, support adding fees, and VAT-factor. The example gets all properties with a single sensor, which provide data (for presenning with apex charts) and additional values as attributes. But it’s of course possible to configure in any way you want :slight_smile:

That’s a nice little helper, but I honestly think we have enough data sources by now, what I would really like to see is an integration with UI configurable properties to extract the relevant info from all those sensor attributes.

There are various different requirements, individual cheap hours, absolute cheap prices, sequential cheap hours etc…and right now getting them all into some kind of useful shape is a bit of a pain for those of us not well versed in writing yaml code.

This works for me:

    additional_costs:  >-
        {% set s = {
            "hourly_fixed_cost": 0.0,
            "winter_low": 0.23,
            "winter_high": 0.689,
            "winter_peak":2.067,
            "summer_low": 0.23,
            "summer_high": 0.344,
            "summer_peak":0.896,
            "cert": 0.01
        }
        %}
        {% if now().month >= 4 and now().month < 10 %}
            {% if now().hour >= 16 and now().hour < 22 %}
                {{ s.summer_peak | float }}
            {% else %}
                {% if now().hour >= 6 %}
                    {{ s.summer_high | float }}
                {% else %}
                    {{ s.summer_low | float }}
                {% endif %}
            {% endif %}
        {% else %}
            {% if now().hour >= 16 and now().hour < 22 %}
                {{ s.winter_peak | float }}
            {% else %}
                {% if now().hour >= 6 %}
                    {{ s.winter_high | float }}
                {% else %}
                    {{ s.winter_low | float }}
                {% endif %}
            {% endif %}
        {% endif %}

I hope it helps you.

Is it possible to have the price-graph as a stacked graph?
Ie “Additional cost” as one color and “Nordpool price” as an other?
The intention is to have “what do I pay for imported electricity” vs “what do I get for exported electricity” in one graph.

Newbie here. Is it possible to combine the today and tomorrow time series into one? I would like both in one chart, but the bars are not wide enough. This is obviously because it has 2 time series, and the values of half of them are always 0.
I can’t figure out if I can do this with apex, or a template or in some other way: Anyone have a suggestion?

Hi all,

I am trying to fix a sensor to trigger scenes on the cheapest consecutive hours but something is fishy. I created a new post to avoid spamming (and change the sensor along the way): Binary sensor unavailable? (Nordpool)

2 Likes

Hi.
In addition to the prices, the Nordpool page also provides min, max, avg, peak every day. Is there an easy way in HA to call these values without unnecessary calculations directly in the apexchart card?

1 Like

Hi Bent,

I tried to add the “additional costs” - I am a total novice - like the following:

type: custom:apexcharts-card
graph_span: 48h
header:
title: Energy price till tomorrow (dkk/kWh)
show: true
span:
start: day
now:
show: true
label: Now
additional_costs: |-
{% set s = {
“hourly_fixed_cost”: 0.0,
“winter_low”: 0.23,
“winter_high”: 0.689,
“winter_peak”:2.067,
“summer_low”: 0.23,
“summer_high”: 0.344,
“summer_peak”:0.896,
“cert”: 0.01
} %} {% if now().month >= 4 and now().month < 10 %}
{% if now().hour >= 16 and now().hour < 22 %}
{{ s.summer_peak | float }}
{% else %}
{% if now().hour >= 6 %}
{{ s.summer_high | float }}
{% else %}
{{ s.summer_low | float }}
{% endif %}
{% endif %}
{% else %}
{% if now().hour >= 16 and now().hour < 22 %}
{{ s.winter_peak | float }}
{% else %}
{% if now().hour >= 6 %}
{{ s.winter_high | float }}
{% else %}
{{ s.winter_low | float }}
{% endif %}
{% endif %}
{% endif %}
series:

  • entity: sensor.nordpool_kwh_dk1_dkk_3_10_025
    type: column
    data_generator: |
    return entity.attributes.raw_today.map((start, index) => {
    return [new Date(start[“start”]).getTime(), entity.attributes.raw_today[index][“value”]];
    });

Unfortunately I get an error message: "value.additional_costs is extraneous". What am I doing wrong?

Hi!
I have a Horizontal Stack Card with entities that shows current price and average price, high, low today.
But how can i get 4 or more decimals?

type: horizontal-stack
cards:
  - type: entity
    entity: sensor.nordpool_kwh_fi_eur_3_10_01
    icon: mdi:currency-eur
    attribute: current_price
    name: Spotpris nu
    unit: €
  - type: entity
    entity: sensor.nordpool_kwh_fi_eur_3_10_01
    name: Snittpris idag
    icon: mdi:currency-eur
    attribute: average
    unit: €

When you create the sensor, you also specify the number of decimal

Is there a way to convert my previous data to cents? At the moment i have not “price in cents” ticked when i setup the integration.

I am pretty happy with my Nordpool data based solar battery charging automations at this point, but there are still a few issues.

My main problem is that I can’t seem to get all my fail-safes to work. If the charging process starts due to a bug (today the solcast data didn’t show up after a reboot thus leading to the charging starting although it was not necessary) then it should periodically check if the requirements are met and then stop.
I had hoped this would work since my automation is set to run every hour at 1 Minute past full, but for some Reason it did not adjust itself. I will have to figure out why and see if there is some way to make this more foolproof.

Is there a way to get tomorrows last price for finland (GMT+2). That would be the day after tomorrow 0:00-1:00? Now last value for raw_tomorrow is

- start: '2023-02-02T23:00:00+02:00'
  end: '2023-02-03T00:00:00+02:00'
  value: 13.746

Hi, smart people.

I want to find the cheapest hours in 2 separate time slots during the day to start my water boiler. For example between 00 and 07, and between 12 and 20.

Any tips?

There was a suggestion in Sep '22, but I found it to fail logically.

I also did a modification of this post but it was too cumbersome. (It had to be split into two sensors which the configuration didn’t like, and it uses up to 5-6 automations just to turn on and off the boiler a couple of times a day).

Why your configuration didn’t liked splitting in two sensors?

This line will return true if you are currently in one of those cheapest hours:


{{ states('sensor.nordpool_kwh_se3_sek_3_10_025') | float(0) in ((state_attr('sensor.nordpool_kwh_se3_sek_3_10_025', 'today') | default([]))[0:7] | sort)[0:1]  or states('sensor.nordpool_kwh_se3_sek_3_10_025') | float(0) in ((state_attr('sensor.nordpool_kwh_se3_sek_3_10_025', 'today') | default([]))[19:23] | sort)[0:1] }} 
  • please remember to replace to your sensor name
  • not tested in real conditions

I installed the Nordpool integration and used NL as the region when configuring, but the prices seem off compared to the EPEX prices I find online. It seems to be off “almost” by 21% which is our VAT rate, but it’s not exactly 21%. Anyone else experience this?

1 Like

This is what I use for my boiler, it is on during the two cheapest hours in three timeslots. Edit it to fit your use case.

template:
  - binary_sensor:
      - name: Electricity lowest prices segmented
        unique_id: electricity_lowest_prices_segmented
        state: >-
          {% set intervall_1=state_attr('sensor.nordpool_kwh_krsand_nok_3_10_025', 'raw_today')[0:8] | sort(attribute='value') %}
          {% set intervall_2=state_attr('sensor.nordpool_kwh_krsand_nok_3_10_025', 'raw_today')[8:16] | sort(attribute='value') %}
          {% set intervall_3=state_attr('sensor.nordpool_kwh_krsand_nok_3_10_025', 'raw_today')[16:24] | sort(attribute='value') %}
          {{ (now() >= intervall_1[0].start and now() <= intervall_1[0].end)
          or (now() >= intervall_1[1].start and now() <= intervall_1[1].end)
          or (now() >= intervall_2[0].start and now() <= intervall_2[0].end)
          or (now() >= intervall_2[1].start and now() <= intervall_2[1].end)
          or (now() >= intervall_3[0].start and now() <= intervall_3[0].end)
          or (now() >= intervall_3[1].start and now() <= intervall_3[1].end) }}

Hi! Figured I’d start sharing my stuff to help others. Been using HA since october but I’ve learned alot.

I’ve achieved this recently by using mushroom cards with their template card:

{% if state_attr('sensor.nordpool_kwh_se3_sek_0_10_025', 'current_price') > (state_attr('sensor.nordpool_kwh_se3_sek_0_10_025', 'max') - state_attr('sensor.nordpool_kwh_se3_sek_0_10_025', 'min')) * 0.6 + state_attr('sensor.nordpool_kwh_se3_sek_0_10_025', 'min') %}
  deep-orange
{% elif state_attr('sensor.nordpool_kwh_se3_sek_0_10_025', 'current_price') < (state_attr('sensor.nordpool_kwh_se3_sek_0_10_025', 'max') - state_attr('sensor.nordpool_kwh_se3_sek_0_10_025', 'min')) * 0.4 + state_attr('sensor.nordpool_kwh_se3_sek_0_10_025', 'min') %}
  light-green
{% else %}
  amber
{% endif %}

In words: it checks the current price from nordpool and compares it to 60% of the difference between highest and lower price. If it’s above 60%, the icon color is deep-orange (representing high price). If it’s below 40% it’s green (representing low price), and of course in between it’s amber (representing between middle-price)

Paste this in the ‘Icon color’ of the mushroom template card and change the sensor to match your own nordpool sensor, as well as the percentages to define what you think is low and high price.

I use the same formula in the ‘Secondary information’ as well to put the colors into words in the card, by replacing the deep-orange, green and amber with ‘high price’, ‘low price’ and ‘middle price’ respectively.

Good luck!

1 Like

Hi Foxxy!

First off, this is additional costs. Meaning that you don’t have to define the current_price as it already takes it into account. Basically the nordpool integration adds current_price and additional_costs together when it makes the sensor.

Secondly, I think you should just add " | float after the number like this:

{{ 0.013 | float }}

This is the one I use, built on the same example that bentcold references: nordpool/README.md at master · custom-components/nordpool · GitHub

Basically I have hightariff (höglast) during 06:00 - 22:00 between october and april, but not during the weekend.

{% set s = {
    "energiskatt": 49,
    "låglast": 12,
    "höglast": 70,
    "cert": 11.75
}
%}
{% if (now().month >= 4 and now().month <= 10) or (now().weekday() >= 5) %}
    {{ s.låglast + s.energiskatt + s.cert | float }}
{% else %}
    {% if now().hour >= 6 and now().hour < 22 %}
        {{ s.höglast + s.energiskatt + s.cert | float }}
    {% else %}
        {{ s.låglast + s.energiskatt + s.cert | float }}
    {% endif %}
{% endif %}

Snälla kan du posta yaml för allt? Vore super snällt :slight_smile: