Any good ideas are welcome. Nordpool Energy Price per hour

Hello!
I got the sensor working, i added ocnf in configuratin.yaml and then also made changes to lovlace and sensor files, and at least i see now something…
Now to define everythin… If you can direct me foward, i would be most thankful

Wjaceh! You were correct. It is now possible over UI. Got the sensor to work. Thanks

Now it is possible to get the graph for daily electric prices.

  1. Install Apex chart card (https://github.com/RomRider/apexcharts-card)
  2. Add the following configuration to lovelace card.
type: 'custom:apexcharts-card'
graph_span: 1d
span:
  start: day
series:
  - entity: sensor.nordpool_kwh_fi_eur_3_10_024
    data_generator: |
      return entity.attributes.raw_today.map((entry) => {
        return [new Date(entry.start), entry.value];
      });
    type: column

And this will give you this kind of graph of daily prices.

image

8 Likes

How you have changed the EUR to cents?

      return entity.attributes.raw_today.map((entry) => {
        return [new Date(entry.start), entry.value * 100];

or You can of course use series: transform: function :slight_smile:
Best, JR

1 Like

And here it is presented with today and tomorrow in a nice Apex Chart Card (awesome card - must have for everyone)

NOTE: Right now there is something f–ked up, the sensor is presenting prizes in eur or something instead of NOK, this will probably get fixed pretty soon :slight_smile:

          - type: 'custom:apexcharts-card'
            header:
              show: true
              title: Nordpool Prize -> 48 hours
              show_states: false
            graph_span: 2d
            span:
              start: day
            series:
              - entity: sensor.nordpool_kwh_krsand_nok_3_10_025
                name: Today
                data_generator: |
                  return entity.attributes.raw_today.map((entry) => {
                    return [new Date(entry.start), entry.value];
                  });
                type: column
                show:
                  legend_value: false
                  in_header: false
                extend_to_end: false
              - entity: sensor.nordpool_kwh_krsand_nok_3_10_025
                name: Tomorrow
                data_generator: |
                  return entity.attributes.raw_tomorrow.map((entry) => {
                    return [new Date(entry.start), entry.value];
                  });
                type: column
                show:
                  legend_value: false
                  in_header: false

image

7 Likes

You can change the price to to be displayed on the Nordpool component settings.

What could be wrong that I have only today’s values?

Configuration YAML:

  - platform: nordpool
    VAT: True
    currency: "EUR"
    low_price_cutoff: 0.5
    region: "EE"
    precision: 3
    price_type: kWh
    friendly_name: "Power"

Lovelace code:

type: custom:apexcharts-card
header:
  show: true
  title: Nordpool Prize -> 48 hours
  show_states: false
graph_span: 2d
span:
  start: day
series:
  - entity: sensor.nordpool_kwh_ee_eur_3_05_02
    name: Today
    unit: Cent
    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: false
  - entity: sensor.nordpool_kwh_ee_eur_3_05_02
    name: Tomorrow
    unit: Cent
    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

and result:

1 Like

The Nordpool energy price reporting is sometimes very up and down and quite a few times I have seen that the tomorrow values are being reported late. So give it some time and it will probably pop-up.

I compare your code with mine and could see anything different, so your code is valid.

Thanks. Tomorrows prices are available now.

Is it possible to get this info into the energy section thingy?

I mean here:

Tia

I want to find the min and max values of “tomorrow” to use in some automations. Is this possible?
Min and Max for today have their own attributes, so thats easy, but I’m not good enough to find the same for the “tomorrow price” :thinking: :exploding_head:

1 Like

Hi – I got a Swedish energy spot price sensor built in the following manner:

  1. I used a command_line sensor to get the current hour’s spot price from elen.nu:
- platform: command_line
  name: SE3 Stockholm Electricity Spot Price Text
  command: curl -s 'https://elen.nu/dagens-spotpris/se3-stockholm/' | grep -A 1 "`date +'%Y-%m-%d %H:00'`" | sed  's/,/./g'
  scan_interval: 3600

The command is broken up as:
curl - get the raw HTML of the web page
date - print the current date in YYYY-MM-DD HH:00 format
grep - find the line with that date and time, and then print it and the one line after (-A 1)
sed - replace the , in the price (XXX,XX) with a period.

I really wanted to use a second grep to pull out the value directly, but I couldn’t get the grep in home assistant to do that.

  1. So I use a template_sensor to extract it:
  - name: "SE3 Stockholm Electricity Spot Price"
    unique_id: se3_stockholm_electricity_spot_price
    state: >
      {{ states("sensor.se3_stockholm_electricity_spot_price_text") | regex_findall_index("\d+\.\d\d")|float|multiply(0.01) }}
    unit_of_measurement: 'SEK/kWh'
  1. Then I use another template sensor to compute the approximate total price paid:
  - name: "Electricity Spot Price Total"
    unique_id: electricity_spot_price_total
    state: >
      {{ (states("sensor.se3_stockholm_electricity_spot_price") | float + 0.06 + 0.305 + 0.445) * 1.25 }}
    unit_of_measurement: 'SEK/kWh'
# Energiskatt - 0.445 1 jan 2021 -- https://www.energimarknadsbyran.se/el/dina-avtal-och-kostnader/elrakningen/energiskatt-skattesatser-och-kostnader/
# Vatetnfall överföringsavgift - 0.305 -- https://www.vattenfalleldistribution.se/el-hem-till-dig/elnatspriser/
# Skekraft påslag - 0.06 - https://www.skekraft.se/privat/elavtal/rorligt-elpris/#buypopup
# MOMS 25%

I hope this is helpful!
-David

5 Likes

Sweetness! Such a nice explanation! And it does work on the ‘Energy’-tab?

Is it possible to grab the info from the already known data in the nordpool sensor? (see below)

Current price
82.91
Average
78.045
Off peak 1
51.051
Off peak 2
66.41
Peak
97.682
Min
29.241
Max
120.105
Unit
kWh
Currency
SEK
Country
Sweden
Region
SE3
Low price
false
Tomorrow valid
true
Today
29.575, 29.241, 36.009, 40.558, 53.619, 58.229, 63.376, 97.804, 118.2, 120.105, 117.582, 108.423, 90.438, 88.29, 83.184, 84.035, 89.395, 100.428, 100.58, 98.361, 82.91, 63.376, 60.458, 58.897
Tomorrow
57.47, 57.146, 55.727, 54.308, 48.045, 54.278, 57.217, 58.26, 58.737, 71.009, 81.102, 81.842, 82.116, 79.937, 79.157, 80.312, 91.216, 111.464, 122.733, 122.834, 107.36, 95.797, 81.082, 62.577
Raw today
- start: '2021-09-24T00:00:00+02:00'
end: '2021-09-24T01:00:00+02:00'
value: 29.575
- start: '2021-09-24T01:00:00+02:00'
end: '2021-09-24T02:00:00+02:00'
value: 29.241
- start: '2021-09-24T02:00:00+02:00'
end: '2021-09-24T03:00:00+02:00'
value: 36.009
- start: '2021-09-24T03:00:00+02:00'
end: '2021-09-24T04:00:00+02:00'
value: 40.558
- start: '2021-09-24T04:00:00+02:00'
end: '2021-09-24T05:00:00+02:00'
value: 53.619
- start: '2021-09-24T05:00:00+02:00'
end: '2021-09-24T06:00:00+02:00'
value: 58.229
- start: '2021-09-24T06:00:00+02:00'
end: '2021-09-24T07:00:00+02:00'
value: 63.376
- start: '2021-09-24T07:00:00+02:00'
end: '2021-09-24T08:00:00+02:00'
value: 97.804
- start: '2021-09-24T08:00:00+02:00'
end: '2021-09-24T09:00:00+02:00'
value: 118.2
- start: '2021-09-24T09:00:00+02:00'
end: '2021-09-24T10:00:00+02:00'
value: 120.105
- start: '2021-09-24T10:00:00+02:00'
end: '2021-09-24T11:00:00+02:00'
value: 117.582
- start: '2021-09-24T11:00:00+02:00'
end: '2021-09-24T12:00:00+02:00'
value: 108.423
- start: '2021-09-24T12:00:00+02:00'
end: '2021-09-24T13:00:00+02:00'
value: 90.438
- start: '2021-09-24T13:00:00+02:00'
end: '2021-09-24T14:00:00+02:00'
value: 88.29
- start: '2021-09-24T14:00:00+02:00'
end: '2021-09-24T15:00:00+02:00'
value: 83.184
- start: '2021-09-24T15:00:00+02:00'
end: '2021-09-24T16:00:00+02:00'
value: 84.035
- start: '2021-09-24T16:00:00+02:00'
end: '2021-09-24T17:00:00+02:00'
value: 89.395
- start: '2021-09-24T17:00:00+02:00'
end: '2021-09-24T18:00:00+02:00'
value: 100.428
- start: '2021-09-24T18:00:00+02:00'
end: '2021-09-24T19:00:00+02:00'
value: 100.58
- start: '2021-09-24T19:00:00+02:00'
end: '2021-09-24T20:00:00+02:00'
value: 98.361
- start: '2021-09-24T20:00:00+02:00'
end: '2021-09-24T21:00:00+02:00'
value: 82.91
- start: '2021-09-24T21:00:00+02:00'
end: '2021-09-24T22:00:00+02:00'
value: 63.376
- start: '2021-09-24T22:00:00+02:00'
end: '2021-09-24T23:00:00+02:00'
value: 60.458
- start: '2021-09-24T23:00:00+02:00'
end: '2021-09-25T00:00:00+02:00'
value: 58.897
Raw tomorrow
- start: '2021-09-25T00:00:00+02:00'
end: '2021-09-25T01:00:00+02:00'
value: 57.47
- start: '2021-09-25T01:00:00+02:00'
end: '2021-09-25T02:00:00+02:00'
value: 57.146
- start: '2021-09-25T02:00:00+02:00'
end: '2021-09-25T03:00:00+02:00'
value: 55.727
- start: '2021-09-25T03:00:00+02:00'
end: '2021-09-25T04:00:00+02:00'
value: 54.308
- start: '2021-09-25T04:00:00+02:00'
end: '2021-09-25T05:00:00+02:00'
value: 48.045
- start: '2021-09-25T05:00:00+02:00'
end: '2021-09-25T06:00:00+02:00'
value: 54.278
- start: '2021-09-25T06:00:00+02:00'
end: '2021-09-25T07:00:00+02:00'
value: 57.217
- start: '2021-09-25T07:00:00+02:00'
end: '2021-09-25T08:00:00+02:00'
value: 58.26
- start: '2021-09-25T08:00:00+02:00'
end: '2021-09-25T09:00:00+02:00'
value: 58.737
- start: '2021-09-25T09:00:00+02:00'
end: '2021-09-25T10:00:00+02:00'
value: 71.009
- start: '2021-09-25T10:00:00+02:00'
end: '2021-09-25T11:00:00+02:00'
value: 81.102
- start: '2021-09-25T11:00:00+02:00'
end: '2021-09-25T12:00:00+02:00'
value: 81.842
- start: '2021-09-25T12:00:00+02:00'
end: '2021-09-25T13:00:00+02:00'
value: 82.116
- start: '2021-09-25T13:00:00+02:00'
end: '2021-09-25T14:00:00+02:00'
value: 79.937
- start: '2021-09-25T14:00:00+02:00'
end: '2021-09-25T15:00:00+02:00'
value: 79.157
- start: '2021-09-25T15:00:00+02:00'
end: '2021-09-25T16:00:00+02:00'
value: 80.312
- start: '2021-09-25T16:00:00+02:00'
end: '2021-09-25T17:00:00+02:00'
value: 91.216
- start: '2021-09-25T17:00:00+02:00'
end: '2021-09-25T18:00:00+02:00'
value: 111.464
- start: '2021-09-25T18:00:00+02:00'
end: '2021-09-25T19:00:00+02:00'
value: 122.733
- start: '2021-09-25T19:00:00+02:00'
end: '2021-09-25T20:00:00+02:00'
value: 122.834
- start: '2021-09-25T20:00:00+02:00'
end: '2021-09-25T21:00:00+02:00'
value: 107.36
- start: '2021-09-25T21:00:00+02:00'
end: '2021-09-25T22:00:00+02:00'
value: 95.797
- start: '2021-09-25T22:00:00+02:00'
end: '2021-09-25T23:00:00+02:00'
value: 81.082
- start: '2021-09-25T23:00:00+02:00'
end: '2021-09-26T00:00:00+02:00'
value: 62.577

For now, I’ll just steal your setup straight off. :slight_smile: (still learning a lot).

I have plans for HA to tell me if it’s cheaper to charge car/run washer etc… depending on if selling surplus solar pays less than buying from grid.
Also plans to start/stop charging car calculated on if it’s needed, and if it’s cheap.

Side note, do skekraft have a monthly fee? with my current usage, i would land on 31.40Sek per month and that is cheaper than my monthly fee, but without a markup on the spot price

Lastly " Varför betalas moms på energiskatt?" (translated, why pay vat on energy tax).

Bang, I’m sure you could parse it out of that sensor. I didn’t have that one installed, so I found this other source.

You may be right that there isn’t tax on the energy tax. That should be simple enough to change by pulling it out of the sub expression!
-David

First, Thanks! You helped my thinking alot!

I’ve been tearing my hair off so far. :slight_smile: Trying my best to search for what i need but not found yet. :frowning:

I have managed to get cost included on the ENERGY tab but i assume i failed somewhere with the script for the individual sensors. They show up, but all show 0 after 24h of waiting.

And, i was making a snark remark about us paying VAT on both the energy and the energy tax. :slight_smile: The transfer fee is with VAT included

Thank you for a great presentation of Nordpool data.
I think there is any bug in the start of each day 00 to 01 is not included?
Maybe a 24 hours bug of some kind…

type: custom:apexcharts-card
hours_12: false
header:
  show: true
  title: Nordpool Prize -> 48 hours
  show_states: true
now:
  show: true
  color: '#ff0000'
  label: Nåtid
graph_span: 2d
span:
  start: day
series:
  - entity: sensor.nordpool_kwh_krsand_nok_3_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: true
  - entity: sensor.nordpool_kwh_krsand_nok_3_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

image
Last value is 23:00 and next is then 01:00, where is 00:00? Not easy to see, but the space is little vider in the start/middle on each 00:00.
Dataset is value from [0]…[23], but the 0 seems to be ignored by the map.

2 Likes

Hi again.
Ill try one more time to explain what I need, and what I have.


In this image, you can se the calculations based on the percentage of my battery Vs. the price og the electricity. When the green line is above the yellow(price) line, the battery charges.
And when the Red line is under the Yellow line, the battery sends extra power to the net. (this means I have power extra, and the price is high.

But my problem comes the days the price next day is cheaper then today. (as seen is the image under)
Dagens pris 2
The yellow arrow shows right now(white line) . the battery charges, but as we see, the next 5-6 hours are cheaper. It should therefore wait to charge.
This could be done by combining todays prices with tomorrows, but i dont have that skill ! :frowning:

Help please :slight_smile:

The information I use to make calculations is “todays High” and “Todays Low” (and thats easy, there are attributes for it) If there were “High” and “Low” -tomorrow too, I would find a way.
Or even better. “High” and “Low” -all known prices. (today and tomorrow).

Another great example :


It will now charge the batteries the last 4 hours of today, even though the price tomorrow is cheaper.
I will now charge the batteries with expensive power, and use that expensive power when the power in the grid is cheaper.
This is the perfect example of what I need to fix.

I noticed the same thing with putting today’s and tomorrow’s price data together into a single apex chart. Actually it’s apex charts that’s buggy here:

  1. If you count the columns, there are 48 in total, so they’re all there. It’s just that the tomorrow’s columns are incorrectly one hour ahead.
  2. If you hover over tomorrow’s columns, the vertical dotted line appears over the same today’s time and the hover box is also there (but contains tomorrow’s data).