Have you set up Nordpool via the UI or YAML?
I set it up with the UI and defined precision as 3 and to show price in cents, which seem to be “øre”.
This is a bit “hacky”, but if you go into “.storage/core.config_entries” and search for Nordpool you can compare with my details. If you make any changes, make sure that you have your backups sorted.
Please ignore the additional costs entry as the uses some of my own template sensors.
Did you solve this? Would it not help if you used median instead of average?
The median is the middle number in a data set. To find the median, list your data points in ascending order and then find the middle number. The middle number in this set is 28 as there are 4 numbers below it and 4 numbers above:
23, 24, 26, 26, 28, 29, 30, 31, 33
Note*: If you have an even set of numbers, average the middle two to find the median. For example, the median of this set of numbers is 28.5 (28 + 29 / 2).
23, 24, 26, 26, 28, 29, 30, 31, 33, 34
I am trying to create a custom list of hourly prices from nordpool data, but I am stuck with list item updates/creating a custom list.
My air/water heat pump does not accomplish much in an hour, as first priority is always DHW production. And price fluctuations do not make sence for me to look at only 1 hour prices. Also rounding the prices makes sence, as I do not really care if price is 71,73,74 - 70 would do better for average/median price calculations.
The idea is to sum 00-01 and 01-02 hourly prices together, creating a list of bi-hourly items with same start, end and hourly price attribute values like in nordpool sensor raw data. Hourly price value would be average of the two hours’ prices for the bi-hour values.
Then I would mround the prices and take median price - to get a price level eliminating high peaks for allowing normal operation of heat pump or stopping it. Also I would like to set a low price level to boost the air/water pump operation when price is low - most probably “below average” would be sufficient.
{% set l=state_attr('sensor.nordpool_kwh_ee_eur_4_095_02', 'raw_today')|sort(attribute='value') %}
{{ l[(11)].value*100 }} value at 12
{{ l[(12)].value*100 }} value at 13
{% set a=(l[(12)].value + l[(11)].value)/2 %}
Mean 24h is : {{ a }}
{##% set l[(12)].value= l[(13)].value %##}
{{ l[(12)].value*100 }} new value at 12
In the above, the line I have commented out does not work. I cannot set a new value to list at 12 like this. What could be wrong or what do you suggest as a solution?
Please be aware that you may destroy things by editing directly in that file. You could consider reinstalling the Integration via UI and try to define accuracy and units there.
If you want to go the “hacky” route, this is what I use:
I am using the “Studio Code Server” add-on to browse and edit files directly in the browser.
You could also use the “File Editor”. It’s a bit crude and frustrating to use on the phone, but OK on a computer.
The “.” in front of the folder name defines this folder as a hidden folder. I am not so familiar with Linux yet, but I guess there should be an option to show hidden files and folders.
Some relevant info may possibly be found here.
I would like to have a calculation based on my own real usage to show how much I would save/loose on either fix or nord-pool market price contract.
Does anyone have a solution for calculating the daily/monthly cost using nordpool data? I know I can enter the NP sensor current price to HA-Energy conf. tab, but this is not suiting my needs as I cannot extract the cost from there (I think). I would like to have a custom “cost-meter” where I can manipulate the price better.
a) For power coming from NP price grid - one calculation with NP price as current price cost entity x my consumed energy.
b) For power coming from a fixed price grid - another calculation with fixed price tariffs (day/night) x my consumed energy
c) and then a third calculation showing the difference (profit/loss) either daily/monthly or similar.
I do not need this to be possible on historical data.
Is there some readymade solution for this? Or can I adapt utility meter or some other solution? I would not want to build a custom solution for NP price calculation using hourly meters and multiplying the hourly usage with previous hour’s price.
This seems a little bit off. I’m looking at SE4 and the integration is giving me 0.2 SEK/kWh (15:00-16:00) but if I look at Nordpool on the same time it gives me 15,05 EUR/MWh. 15,05 euro to sek = 159,52 / 1000 (to get kWh) = 0.15952. So I guess that would be 0.16SEK/kWh? Or am I missing something?
I try to change font-size and numbers of decimals for attribute “average” in “Entity”. Shall I do that in config or Card_mod and pleace help me with code.
For previous - update the sensor or input number value so that it is written to be current price at each hour, 59 minutes 55 seconds for instance, this is easiest.
Next 2 hours - you have to access the raw prices list and do calculations there, a bit more tricky. Get current hour, find it from the list, take the next 2 elements from list…
It works fine, but what I cannot get to work is the additional_costs (by using a constant it works fine) But I need to change the value at 17 to 20 clock everydya, and that I cannot get to work, can anybody point me in direction on what I do wrong?
Hi Tue!
Experienced the same issue as you until a few minutes ago THe problem by changing the constants the name also change which will mean that automation’s using the sensor will break… When i was answering your post i realized that you can create several instances of the sensor by just adding several blocks in your config.yaml. It is not as clean as sending parameters but i would guess that it works. I just tried to create one additional sensor with another threshold and it seems to work.
What do you think?
In theory, endhour_kwh_nok should be updated at at XX:59, and then lasthour_kwh_nok should be updated at XX:00.
I’ll leave it up to gasolli or anyone else to create a sensor nextsecondhour_kwh_nok.
One problem is after the templates has been reloaded, endhour_kwh_nok and lasthour_kwh_nok will be unknown. This can be helped with an automation that stores endhour_kwh_nok in the helper lasthour_kwh_nok at the beginning of each hour.
I’ve started to work on something not exactly that but it could be built further I believe. Work and family consumes a lot of time… So far its three sensors, past 72h mean, past72h median and today median. In my head it should be easy to add past and today and use it as a value.
Anyway im not sure witch of the three is the best approach for the level calculation any input on that would be nice
Here’s the code I ended up with using for an average of the last 72 hours + tomorrow. Now that I look at it I see that I may not have included the prices of today that have not yet occured.
- platform: statistics
name: "elpris_3d_snitt"
state_characteristic: mean
entity_id: sensor.nordpool_kwh_se3_sek_5_095_025
precision: 5
sampling_size: 144
max_age:
hours: 72
template:
- sensor:
- name: elpris_long_avg
unit_of_measurement: 'SEK/kWh'
state: >-
{% set pasthours = 72 %}
{% set prices=state_attr('sensor.nordpool_kwh_se3_sek_5_095_025', 'raw_today') + state_attr('sensor.nordpool_kwh_se3_sek_5_095_025', 'raw_tomorrow') -%}
{% set list = namespace(prices=[]) -%}
{% set pastavg = states('sensor.elpris_3d_snitt')|float(default=0.5) %}
{% for price in prices -%}
{%- if price.end > now() -%}{% set list.prices = list.prices + [price] -%}{%- endif -%}
{% endfor -%}
{% set futureprices = (list.prices | map(attribute='value')|join(',')).split(',') -%}
{% set past_count = (state_attr('sensor.elpris_3d_snitt', 'age_coverage_ratio')|float(default=0))*pasthours %}
{% set pastweighted = pastavg*past_count %}
{% set futuresum = (list.prices | sum(attribute='value'))-futureprices[0]|float-%}
{% set future_count = (futureprices | count)-1 %}
{% set futureavg = futuresum/future_count %}
{% set futureweighted = futureavg*future_count %}
{% set longavg = (pastweighted+futureweighted)/(past_count+future_count) %}
{{ longavg | round(5, default=1) }}
Edit: Updated code to redact current hour from list of future prices. A more elegant way would perhaps be to add an hour to the timezone offset, but I’m not sure how to do that.
For future refererence if someone comes in here with this problem.
I had set the color scheme to show green from 0 to 0,8 in my currency
Suddenly it would not show, but when i looked at Nordpool i saw negative numbers.
So i set the green to be from -2 to 0,8 and now it show correctly again.
So basically today is going to be sunny and windy to the point where i will GET money for getting power.
Sadly, when the price is -0,2 this still means that i have to pay the 1,5 in electricity tax to the state, so the price will still be about 1,3 but if i had an electric car, and no solar cells this would be the time i would charge.