Any good ideas are welcome. Nordpool Energy Price per hour

You can create a template sensor using the values from attributes and find for current hour-1, however this will most likely fail every day at midnight (when the today attribute is reset), so perhaps will work better if you create a trigger template sensor running every time the minute is 59 and seconds like 55, then you change the value of that sensor to the current value of the NordPool sensor, so you will have 5secs (adjustable) where this value is incorrect every hour, but probably will satisfy your need for calculating the price then a new hour starts.

Something like this:

template:
  - trigger:
      - platform: time_pattern
        minutes: 59
        seconds: 55
    sensor:
      - name: NordPool last hour price
        state: '{{ states('sensor.your_nordpool_current_price_sensor') }}'
        unit_of_measurement: "$/kWh"

Thank you Edward for this quick feedback.
What I forgot to mention is that I have a similar setup today, but in an automation instead looking each hour at -1min(hour) to copy the current price to an input_number that is used at +1min(hour)

What I discovered when restarting HA is that I lost the value until it refreshed next time.
So my thought was that since the value is constantly shown as an attribute I’d try to pick that instead to always have a correct value.

But as you say, and I had not thought about this… it will likely not work for the last hour.

And not having a value for (worst case) 58min isn’t really an issue as long as it’s there when the calculation happen at hour+1min.
So perhaps this is the better solution anyway.
But I will use your sensor instead of my input_number using a helper.

Thank you for this feedback that probably result in the better setup! :slight_smile:

Now I just need to understand how to multiply two sensors and store them in something showing “cost saving last hour” and then add it to a “cost saving today”…
Perhaps here an input_number is better?

To multiply two values it’s probably better to have another template sensor. Some thing like this:

template:
  sensor:
    - name: My sensor with the result of the other two
      availability: '{{ is_number(states("sensor.value_a")) and is_number(states("sensor.value_b")) }}'
      state: '{{ states("sensor.value_a") | float * states("sensor.value_b") | float }}'

About the daily sum, there are different ways to achieve, but most likely you are looking for Utility Meter.

Great, many thanks Edward!

I tweaked your code slightly to what I think is acceptable by HA. At least it passes all tests :slight_smile:

# Take last hour solar consumption from sensor attribute
- sensor:
  - name: "House Consumption SolarEnergy Last Hour"
    unique_id: "house_consumption_solarenergy_last_hour"
    state: >-
      {{ state_attr('sensor.house_consumption_solarenergy_test_hourly', 'last_period') | float(3)}}

# gets nordpool previous hour price
- trigger:
  - platform: time_pattern
    minutes: 59
    seconds: 55
  sensor:
    - name: "NordPool last hour"
      unique_id: "nordpool_last_hour"
      state: '{{ states("sensor.nordpool_kwh_se3_sek_3_10_025") }}'
      unit_of_measurement: "SEK/kWh"

# multiplies last hours solar consumption and last hour spot price
- trigger:
  - platform: time_pattern
    seconds: 5
  sensor:
    - name: House Solar Saving Last Hour
      unique_id: "house_solar_saving_last_hour"
      availability: '{{ is_number(states("sensor.house_consumption_solarenergy_last_hour")) and is_number(states("sensor.nordpool_last_hour")) }}'
      state: '{{ states("sensor.house_consumption_solarenergy_last_hour") | float * states("sensor.nordpool_last_hour") | float }}'

# adds last hour to the day saving
- trigger:
  - platform: time_pattern
    seconds: 10
  sensor:
    - name: House Solar Saving Today
      unique_id: "house_solar_saving_today"
      availability: '{{ is_number(states("sensor.house_consumption_solarenergy_last_hour")) and is_number(states("sensor.nordpool_last_hour")) }}'
      #availability above kept as this sensor is based on those sensors
      state: '{{ states("sensor.house_solar_saving_today") | float + states("sensor.house_solar_saving_last_hour") | float }}'

I took your advise and only use sensors. I added a trigger also to the multiplication sensor. (I hope this is correct).

And based on your feedback I’m making an attempt with the last sensor to add each hourly saving to a “daily saving” 10sek past each hour. so sequence start 5 sec to the full hour and end 15 sec later.
As indicated in the #comment, I kept the “available” sensors the same as really, if these are not available, I wouldn’t get the values needed for this either.

I’m not sure I want a utility meter as I thought it requires a continuously increasing sensor value? I’m feeding it an hourly value once an hour. Will that work?
Perhaps there are settings to be made that will cover this?

My problem seem to remain, do you have any advise to give how I stop/restart the sensor each day?
And preferably I’d like to store the value before resetting it to a “weekly” tracker… then to a “monthly” and potentially “yearly”.

Thank you so much your your support! Very much appreciated!!! :heart:

Edit…
I see now that the Utility meter do support both increasing and delta values… and it has a periodic reset. But will it help me with my last hour each day… last hour each week, each month etc?
I made this so far:

Edit 2:
May have come to a solution with those 10 sec that the “automation” runs… offseting the reset of the cycle 20sec should let me capture the last calculation each day??
Both a daily and monthly meter created… I think??? :smiley:

utility_meter:
  house_solar_saving_today:
    source: sensor.house_solar_saving_last_hour
    cycle: daily
    delta_values: true
    offset: '00:00:20'
    unique_id: "house_solar_saving_today"
    name: House Solar Saving Today


  house_solar_saving_montly:
    source: sensor.house_solar_saving_last_hour
    cycle: monthly
    delta_values: true
    offset: '00:00:20'
    unique_id: "house_solar_saving_monthly"
    name: House Solar Saving Monthly

Apologies for all the edits… Also found some typos in code etc that I fixed

Edit 3:
Ok, one more edit, haha… but only as time just passed the full hour and I managed to get all the code in place,
These are now my sensors, and they do seem accurate so far… Let’s see what happens next hour… and more exciting tonight :slight_smile:
Just need to fix the units of measure and the number of decimals…
image

Unfortunately the roll over to the next day didn’t work as expected.
Although I thought I had set an offset by 20sec, the meter reset at 00:00:00
Then updated 00:00:05 with the value valid for 23-00, this value should have been included in “today’s” total, not be part of tomorrow.

Any idea?

utility_meter:
  house_solar_saving_today:
    source: sensor.house_solar_saving_last_hour
    cycle: daily
    delta_values: true
    offset: '00:00:20'
    unique_id: "house_solar_saving_today"
    name: House Solar Saving Today

A strange thing happened last night.
As mentioned in posts above I’ve set up this sensor.
It multiplies my house solar consumption last hour with the nordpool price of last hour.

- trigger:
  - platform: time_pattern
    seconds: 5
  sensor:
    - name: House Solar Saving Last Hour
      unique_id: "house_solar_saving_last_hour"
      availability: '{{ is_number(states("sensor.house_consumption_solarenergy_last_hour")) and is_number(states("sensor.nordpool_last_hour")) }}'
      state: '{{ states("sensor.house_consumption_solarenergy_last_hour") | float * states("sensor.nordpool_last_hour") | float }}'
      unit_of_measurement: "SEK"

It triggers 5sec past every full hour. It was setup yesterday evening. And this morning something strange happened. It increase in value four more times around 4:30 as well. How can this happen? The above code is the only code applicable to this sensor.
(you can see the correct increase of this sensor happening at 4:00:05 and 5:00:05

Anyone experienced this before and know what the issue is?
I have utility meters running for this sensor to capture the saving made over the day/month/year so this behavior is messing up the utility meters

apologies, but this condition template does not validate.
It gives TypeError: ‘<=’ not supported between instances of ‘dict’ and ‘dict’

		{{ ((state_attr('sensor.nordpool_kwh_lv_eur_3_083_0', 'raw_today') <= state_attr('sensor.nordpool_kwh_lv_eur_3_083_0', 'raw_tomorrow'))
		| selectattr('start', 'defined')
		| selectattr('start', '>=', today_at('21:00'))
		| selectattr('end', 'defined')
		| selectattr('end', '<', today_at('07:00') + timedelta(days=1))
		| sort(attribute='value')
		| map(attribute='start')
		| list)[0:4]
        }}

I am looking for a template to return true during 4 any most expensive hours within 24h period .

Try this:

{{ states('sensor.nordpool_kwh_lv_eur_3_083_0') | float(-999) >= ((state_attr('sensor.nordpool_kwh_lv_eur_3_083_0', 'raw_today')+state_attr('sensor.nordpool_kwh_lv_eur_3_083_0', 'raw_tomorrow'))
		| selectattr('start', 'defined')
		| selectattr('start', '>=', today_at('21:00'))
		| selectattr('end', 'defined')
		| selectattr('end', '<', today_at('07:00') + timedelta(days=1))
		| sort(attribute='value')
		| map(attribute='value')
		| list)[-4]
        }}

By the way, this one is returning highest between 21 and 7. If you want use the whole period, you should remove those filters.

Like this:

{{ states('sensor.nordpool_kwh_lv_eur_3_083_0') | float(-999) >= ((state_attr('sensor.nordpool_kwh_lv_eur_3_083_0', 'raw_today')+state_attr('sensor.nordpool_kwh_lv_eur_3_083_0', 'raw_tomorrow'))
		| sort(attribute='value')
		| map(attribute='value')
		| list)[-4]
        }}
1 Like

Please define better what you mean by 24h period. Sometimes you have around 36h of price available.
24h from now? 24h of today? 24h of tomorrow?

Thanks for your assistance with templating!
24 hours of today is what would serve my purpose the best.

This is today only:

{{ states('sensor.nordpool_kwh_lv_eur_3_083_0') | float(-999) >= (state_attr('sensor.nordpool_kwh_lv_eur_3_083_0', 'raw_today')
		| sort(attribute='value')
		| map(attribute='value')
		| list)[-4]
        }}
1 Like

Just in case someone else wants to have nordpool today and tomorrow prices in single series for apexcharts. Kind of odd to have them separated anyway.

  data_generator: |
      var res = entity.attributes.raw_today.map((start, index) => {
        return [new Date(start["start"]).getTime(), entity.attributes.raw_today[index]["value"]];
      });
      entity.attributes.raw_tomorrow.map((start, index) => {
        res.push([new Date(start["start"]).getTime(), entity.attributes.raw_tomorrow[index]["value"]]);
      });
      return res;

Also additional cost template is useful to add your spot margin and transfer prices in. For example my case Elenia Finland day (4.33snt) and night (2.64snt) transfer price per kwh + Oomi spot margin (0.25 set at the moment) . And then your nordpool sensor will be showing your exact prices.


{% if now().hour >= 7 and now().hour < 22 %} {{ 0.0458 | float }} {% else %} {{ 0.0289 | float }} {% endif %}
1 Like

I have the same problem. Did you find a solution?

Nordpool vs. EPEX Spot.

Maybe I am mistaken, but I thought Nordpool and EPEX Spot delivers the same values.

My current config for Nordpool looks like that:

##### NORD POOL SPOT Prices ###

- platform: nordpool
  # Country/region to get the energy prices for. 
  region: "AT"
    
  # Override HA local currency used to fetch the prices from the API.
  currency: "EUR"
    
  # Add Value Added Taxes (VAT)?
  VAT: False
    
  # Energy price rounding precision.
  precision: 4
    
  # Percentage of average price to set the low price attribute
  # low_price = hour_price < average * low_price_cutoff
  low_price_cutoff: 0.95

  # Display price in cents in stead of (for example) Euros.
  price_in_cents: True

  # Price displayed for MWh, kWh or Wh
  price_type: kWh

  # Template to specify additional cost to be added to the tariff.
  # The template price is in EUR, DKK, NOK or SEK (not in cents).
  # For example: "{{ current_price * 0.19 + 0.023 | float}}" 
  additional_costs: "{{ (0.0144 + (current_price * 0.2)) | float }}"
  # my current provder adds 1,44ct and 20% tax on the energy price

I defined some current energy price based on the EPEX Spot as well:

- platform: template
  sensors:
    epex_spot_price_ct_per_kwh:
      friendly_name: "Aktueller Strompreis"
      unit_of_measurement: "ct/kWh"
      availability_template: '{{ states("sensor.epex_spot_at_price") != "unavailable" }}'
      value_template: '{{ states("sensor.epex_spot_at_price") | float * 0.1 * 1.2 + 1.44 }}'

I would naively assume that both values should be the same - but they are not, not even close:

EPEX for today:

Attribute
Data
- start_time: '2023-08-15T22:00:00+00:00'
end_time: '2023-08-15T23:00:00+00:00'
price_eur_per_mwh: 106.73
price_ct_per_kwh: 10.673
- start_time: '2023-08-15T23:00:00+00:00'
end_time: '2023-08-16T00:00:00+00:00'
price_eur_per_mwh: 97.45
price_ct_per_kwh: 9.745000000000001
- start_time: '2023-08-16T00:00:00+00:00'
end_time: '2023-08-16T01:00:00+00:00'
price_eur_per_mwh: 92.92
price_ct_per_kwh: 9.292
- start_time: '2023-08-16T01:00:00+00:00'
end_time: '2023-08-16T02:00:00+00:00'
price_eur_per_mwh: 92.89
price_ct_per_kwh: 9.289
- start_time: '2023-08-16T02:00:00+00:00'
end_time: '2023-08-16T03:00:00+00:00'
price_eur_per_mwh: 92.26
price_ct_per_kwh: 9.226
- start_time: '2023-08-16T03:00:00+00:00'
end_time: '2023-08-16T04:00:00+00:00'
price_eur_per_mwh: 97.5
price_ct_per_kwh: 9.75
- start_time: '2023-08-16T04:00:00+00:00'
end_time: '2023-08-16T05:00:00+00:00'
price_eur_per_mwh: 115.39
price_ct_per_kwh: 11.539
- start_time: '2023-08-16T05:00:00+00:00'
end_time: '2023-08-16T06:00:00+00:00'
price_eur_per_mwh: 138.14
price_ct_per_kwh: 13.813999999999998
- start_time: '2023-08-16T06:00:00+00:00'
end_time: '2023-08-16T07:00:00+00:00'
price_eur_per_mwh: 128.51
price_ct_per_kwh: 12.850999999999999
- start_time: '2023-08-16T07:00:00+00:00'
end_time: '2023-08-16T08:00:00+00:00'
price_eur_per_mwh: 108.97
price_ct_per_kwh: 10.897
- start_time: '2023-08-16T08:00:00+00:00'
end_time: '2023-08-16T09:00:00+00:00'
price_eur_per_mwh: 98.91
price_ct_per_kwh: 9.891
- start_time: '2023-08-16T09:00:00+00:00'
end_time: '2023-08-16T10:00:00+00:00'
price_eur_per_mwh: 93.85
price_ct_per_kwh: 9.385
- start_time: '2023-08-16T10:00:00+00:00'
end_time: '2023-08-16T11:00:00+00:00'
price_eur_per_mwh: 91.32
price_ct_per_kwh: 9.132
- start_time: '2023-08-16T11:00:00+00:00'
end_time: '2023-08-16T12:00:00+00:00'
price_eur_per_mwh: 86.69
price_ct_per_kwh: 8.669
- start_time: '2023-08-16T12:00:00+00:00'
end_time: '2023-08-16T13:00:00+00:00'
price_eur_per_mwh: 89.9
price_ct_per_kwh: 8.99
- start_time: '2023-08-16T13:00:00+00:00'
end_time: '2023-08-16T14:00:00+00:00'
price_eur_per_mwh: 93.25
price_ct_per_kwh: 9.325
- start_time: '2023-08-16T14:00:00+00:00'
end_time: '2023-08-16T15:00:00+00:00'
price_eur_per_mwh: 97.29
price_ct_per_kwh: 9.729000000000001
- start_time: '2023-08-16T15:00:00+00:00'
end_time: '2023-08-16T16:00:00+00:00'
price_eur_per_mwh: 109.99
price_ct_per_kwh: 10.998999999999999
- start_time: '2023-08-16T16:00:00+00:00'
end_time: '2023-08-16T17:00:00+00:00'
price_eur_per_mwh: 130.62
price_ct_per_kwh: 13.062000000000001
- start_time: '2023-08-16T17:00:00+00:00'
end_time: '2023-08-16T18:00:00+00:00'
price_eur_per_mwh: 155.39
price_ct_per_kwh: 15.538999999999998
- start_time: '2023-08-16T18:00:00+00:00'
end_time: '2023-08-16T19:00:00+00:00'
price_eur_per_mwh: 158.57
price_ct_per_kwh: 15.857
- start_time: '2023-08-16T19:00:00+00:00'
end_time: '2023-08-16T20:00:00+00:00'
price_eur_per_mwh: 136.1
price_ct_per_kwh: 13.61
- start_time: '2023-08-16T20:00:00+00:00'
end_time: '2023-08-16T21:00:00+00:00'
price_eur_per_mwh: 119.9
price_ct_per_kwh: 11.99
- start_time: '2023-08-16T21:00:00+00:00'
end_time: '2023-08-16T22:00:00+00:00'
price_eur_per_mwh: 99.99
price_ct_per_kwh: 9.998999999999999
Price ct per kwh
8.67

Nordpool for today:

Attribute
Average
17.24
Off peak 1
16.44
Off peak 2
19.96
Peak
16.86
Min
13.92
Max
24.27
Mean
15.76
Unit
kWh
Currency
EUR
Country
Austria
Region
AT
Low price
true
Price percent to average
0.81
Today
16.81, 15.47, 14.82, 14.82, 14.73, 15.48, 18.06, 21.33, 19.95, 17.13, 15.68, 14.95, 14.59, 13.92, 14.39, 14.87, 15.45, 17.28, 20.25, 23.82, 24.27, 21.04, 18.71, 15.84
Tomorrow
16.54, 15.61, 15.54, 15.12, 14.87, 16, 18.27, 19.98, 19.67, 17.77, 16.21, 15.12, 14.63, 14.4, 14.4, 14.99, 15.78, 17.43, 19.59, 22.68, 22.12, 20, 18.23, 16.85
Tomorrow valid
true
Raw today
- start: '2023-08-16T00:00:00+02:00'
end: '2023-08-16T01:00:00+02:00'
value: 16.8091
- start: '2023-08-16T01:00:00+02:00'
end: '2023-08-16T02:00:00+02:00'
value: 15.4728
- start: '2023-08-16T02:00:00+02:00'
end: '2023-08-16T03:00:00+02:00'
value: 14.8205
- start: '2023-08-16T03:00:00+02:00'
end: '2023-08-16T04:00:00+02:00'
value: 14.8162
- start: '2023-08-16T04:00:00+02:00'
end: '2023-08-16T05:00:00+02:00'
value: 14.7254
- start: '2023-08-16T05:00:00+02:00'
end: '2023-08-16T06:00:00+02:00'
value: 15.48
- start: '2023-08-16T06:00:00+02:00'
end: '2023-08-16T07:00:00+02:00'
value: 18.0562
- start: '2023-08-16T07:00:00+02:00'
end: '2023-08-16T08:00:00+02:00'
value: 21.3322
- start: '2023-08-16T08:00:00+02:00'
end: '2023-08-16T09:00:00+02:00'
value: 19.9454
- start: '2023-08-16T09:00:00+02:00'
end: '2023-08-16T10:00:00+02:00'
value: 17.1317
- start: '2023-08-16T10:00:00+02:00'
end: '2023-08-16T11:00:00+02:00'
value: 15.683
- start: '2023-08-16T11:00:00+02:00'
end: '2023-08-16T12:00:00+02:00'
value: 14.9544
- start: '2023-08-16T12:00:00+02:00'
end: '2023-08-16T13:00:00+02:00'
value: 14.5901
- start: '2023-08-16T13:00:00+02:00'
end: '2023-08-16T14:00:00+02:00'
value: 13.9234
- start: '2023-08-16T14:00:00+02:00'
end: '2023-08-16T15:00:00+02:00'
value: 14.3856
- start: '2023-08-16T15:00:00+02:00'
end: '2023-08-16T16:00:00+02:00'
value: 14.868
- start: '2023-08-16T16:00:00+02:00'
end: '2023-08-16T17:00:00+02:00'
value: 15.4498
- start: '2023-08-16T17:00:00+02:00'
end: '2023-08-16T18:00:00+02:00'
value: 17.2786
- start: '2023-08-16T18:00:00+02:00'
end: '2023-08-16T19:00:00+02:00'
value: 20.2493
- start: '2023-08-16T19:00:00+02:00'
end: '2023-08-16T20:00:00+02:00'
value: 23.8162
- start: '2023-08-16T20:00:00+02:00'
end: '2023-08-16T21:00:00+02:00'
value: 24.2741
- start: '2023-08-16T21:00:00+02:00'
end: '2023-08-16T22:00:00+02:00'
value: 21.0384
- start: '2023-08-16T22:00:00+02:00'
end: '2023-08-16T23:00:00+02:00'
value: 18.7056
- start: '2023-08-16T23:00:00+02:00'
end: '2023-08-17T00:00:00+02:00'
value: 15.8386
Raw tomorrow
- start: '2023-08-17T00:00:00+02:00'
end: '2023-08-17T01:00:00+02:00'
value: 16.5427
- start: '2023-08-17T01:00:00+02:00'
end: '2023-08-17T02:00:00+02:00'
value: 15.6067
- start: '2023-08-17T02:00:00+02:00'
end: '2023-08-17T03:00:00+02:00'
value: 15.5448
- start: '2023-08-17T03:00:00+02:00'
end: '2023-08-17T04:00:00+02:00'
value: 15.1214
- start: '2023-08-17T04:00:00+02:00'
end: '2023-08-17T05:00:00+02:00'
value: 14.8723
- start: '2023-08-17T05:00:00+02:00'
end: '2023-08-17T06:00:00+02:00'
value: 15.9998
- start: '2023-08-17T06:00:00+02:00'
end: '2023-08-17T07:00:00+02:00'
value: 18.2693
- start: '2023-08-17T07:00:00+02:00'
end: '2023-08-17T08:00:00+02:00'
value: 19.9829
- start: '2023-08-17T08:00:00+02:00'
end: '2023-08-17T09:00:00+02:00'
value: 19.6718
- start: '2023-08-17T09:00:00+02:00'
end: '2023-08-17T10:00:00+02:00'
value: 17.7667
- start: '2023-08-17T10:00:00+02:00'
end: '2023-08-17T11:00:00+02:00'
value: 16.2101
- start: '2023-08-17T11:00:00+02:00'
end: '2023-08-17T12:00:00+02:00'
value: 15.1229
- start: '2023-08-17T12:00:00+02:00'
end: '2023-08-17T13:00:00+02:00'
value: 14.6333
- start: '2023-08-17T13:00:00+02:00'
end: '2023-08-17T14:00:00+02:00'
value: 14.3971
- start: '2023-08-17T14:00:00+02:00'
end: '2023-08-17T15:00:00+02:00'
value: 14.3971
- start: '2023-08-17T15:00:00+02:00'
end: '2023-08-17T16:00:00+02:00'
value: 14.9947
- start: '2023-08-17T16:00:00+02:00'
end: '2023-08-17T17:00:00+02:00'
value: 15.7766
- start: '2023-08-17T17:00:00+02:00'
end: '2023-08-17T18:00:00+02:00'
value: 17.4298
- start: '2023-08-17T18:00:00+02:00'
end: '2023-08-17T19:00:00+02:00'
value: 19.5869
- start: '2023-08-17T19:00:00+02:00'
end: '2023-08-17T20:00:00+02:00'
value: 22.6771
- start: '2023-08-17T20:00:00+02:00'
end: '2023-08-17T21:00:00+02:00'
value: 22.1227
- start: '2023-08-17T21:00:00+02:00'
end: '2023-08-17T22:00:00+02:00'
value: 19.9987
- start: '2023-08-17T22:00:00+02:00'
end: '2023-08-17T23:00:00+02:00'
value: 18.2347
- start: '2023-08-17T23:00:00+02:00'
end: '2023-08-18T00:00:00+02:00'
value: 16.8451
Current price
13.92
Additional costs current hour
0.04
Price in cents
true

Is my assumption that both should be the same, not correct? The calculation via EPEX is correct - but I would like to use the Nordpool data if possible as well. Can someone lighten me up?

I took your part of the Data_generator code to display the last hour that was missing in a 24hour chart
but the problem still excist with the last hour if you have 48 hours in same chart.
But for now i’m fine with this solution.

type: custom:apexcharts-card
graph_span: 25h
apex_config:
  chart:
    height: 200px
show:
  last_updated: true
experimental:
  color_threshold: true
header:
  title: Strømpriser i dag
  show: true
  show_states: true
  colorize_states: true
span:
  start: day
now:
  show: true
  label: Nu
series:
  - entity: sensor.nordpool_kwh_se3_sek_3_10_025
    show:
      extremas: true
      in_header: raw
      header_color_threshold: true
    type: column
    data_generator: |
      var res = [];
       entity.attributes.raw_today.forEach((entry) => {
         res.push([new Date(entry.start).getTime(), entry.value]);
      });
      entity.attributes.raw_tomorrow.forEach((entry) => {
        res.push([new Date(entry.start).getTime(), entry.value]);
      });
      return res;
    color_threshold:
      - value: 1
        color: darkgreen
        opacity: 1
      - value: 1
        color: goldenrod
      - value: 3
        color: darkred

i also played with the code for this graph that was provided in this thread to fix the gap when raw_today and raw_tomorrow was provided.

data_generator was modified and if someone can rewrite it to be better go ahead!

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.5
      color: '008000'
    - value: 1
      color: DAA520
    - value: 2
      color: FF0000
now:
  show: true
  label: Now
  color: red
series:
  - entity: sensor.nordpool_kwh_se3_sek_3_10_025
    name: Current day
    opacity: 0.7
    extend_to: false
    data_generator: >
      var todayData = entity.attributes.raw_today.map((entry) => {
       return [new Date(entry.start).getTime(), entry.value];
      });


      var tomorrowData = entity.attributes.raw_tomorrow.slice(0, 1).map((entry)
      => {
        return [new Date(entry.start).getTime(), entry.value];
      });


      return todayData.concat(tomorrowData);
  - entity: sensor.nordpool_kwh_se3_sek_3_10_025
    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

2 Likes

Here is mine with 48’ish hours.

Screenshot 2023-08-31 222904

type: custom:apexcharts-card
graph_span: 46h
header:
  title: Energy price
  show: true
  show_states: true
  colorize_states: true
span:
  start: day
now:
  show: true
  label: Now
  color: '#0074D9'
experimental:
  color_threshold: true
series:
  - entity: sensor.nordpool
    name: Price
    type: column
    color_threshold:
      - value: 0
        color: '#2ECC40'
      - value: 10
        color: '#FFDC00'
      - value: 20
        color: '#FF4136'
    show:
      extremas: true
      header_color_threshold: true
      name_in_header: false
      in_header: raw
    data_generator: >
      return [...entity.attributes.raw_today,
      ...entity.attributes.raw_tomorrow].map((item) =>
        [Date.parse(item.start), item.value]);
apex_config:
  chart:
    height: 300px
  tooltip:
    x:
      show: false
2 Likes

Heya! First winter with no fixed energy price, so 100% hourly price!
Is there a collection of all smart tools to use to give you the status of the current energy price? I guess this thread with its 458 pages have a lot of good tips, but going through it could take time.
I have one that sort the daily energy price into 5 parts giving me how cheap/expensive the price is. Is this one still valid? Is there some other like this that may be better?

- sensor:
    - name: Daily Energy Price Status
      unique_id: XXXX
      state: >
        {% set yest_min_price = states('sensor.daily_min_price')  | float %}
        {% set yest_max_price = states('sensor.daily_max_price')  | float %}
        {% set current_price = states('sensor.daily_current_price')  | float %}
        {% set price_quantiles = {0: 'Very Cheap 1/5', 1: 'Cheap 2/5', 2: 'In Between 3/5', 3: 'Expensive 4/5', 4: 'Very Expensive 5/5'} %}
        {% if current_price < yest_min_price%}
          Very Cheap
        {% elif current_price > yest_max_price %}
          Very Expensive
        {% else %}
          {{ price_quantiles[(current_price - yest_min_price) / (yest_max_price - yest_min_price) // 0.2] }}
        {% endif %}

I think you might find this interesting. It’s not perfect but offers very easy way to take an advantage of thecheapest hours.

Home Assistant: Advanced Nord Pool Cheapest Hours automation with local calendar support – Creating Smart Home

1 Like