Any good ideas are welcome. Nordpool Energy Price per hour

Sorry, on phone, so apologies for any formatting issues. This is what I have on a markdown card. I don’t trust the tomorrow_valid flag, so I just assume that tomorrow’s values are available at 13:01 local time:

Complete card code below:

type: markdown
content: >-

  Snitt: {{state_attr('sensor.nordpool_kwh_trheim_nok_3_095_025',

  Max: {{state_attr('sensor.nordpool_kwh_trheim_nok_3_095_025', 

  Min: {{state_attr('sensor.nordpool_kwh_trheim_nok_3_095_025', 

  Nå: {{(states('sensor.nordpool_kwh_trheim_nok_3_095_025')|float|round(1))}}

  {% if (now().strftime('%T')) > '13:01:00'  %}

  I morgen:

  Snitt: {{state_attr('sensor.nordpool_kwh_trheim_nok_3_095_025', 

  Max: {{state_attr('sensor.nordpool_kwh_trheim_nok_3_095_025', 

  Min: {{state_attr('sensor.nordpool_kwh_trheim_nok_3_095_025',

  {%- else %}

  Strømpris for i morgen er ikke klar.           

  {% endif -%}
title: Strømpris


You can replace this:

By this:

{% if state_attr('sensor.nordpool_kwh_trheim_nok_3_095_025', 'tomorrow') | count > 0 %}

So you only display if tomorrow have some content.


Well. actually, the entire content “fails” if tomorrow is unavailable, but it has been more reliable than using the tomorrow_valid flag. It’s quite some time since I tried to use the flag, but since this is mostly working I am sticking with it.

Before 13:01 it shows this (The last sentence says: “The energy price for tomorrow is not ready”:


Wow, works great! Big thank you @ThoStaKa

Haha, that was way easier than my “hack”. Time to change my card, I guess :grinning_face_with_smiling_eyes:

This is an English only forum please edit your post and use English.

This thread is really cool and super helpful for a Newbie like myself.

I live in Denmark and have solar panels on the roof and I am selling excessive power to a company called “Jysk Energi”. The price I get is my consumption price in DKK reduced by 25 ore, I believe.

Of course I would like to assess the “returned to grid” in monetary terms. Could I use the Nordpool price per hour and somehow apply “minus 0,25 DKK”?

You can easily create a template sensor to do that.

It would be something like this (please change the entity_id for your NordPool sensor):

  - sensor:
      - name: Electricity selling price
        unique_id: electricity_selling_price
        unit_of_measurement: "DKK/kWh"
        device_class: monetary
        availability: "{{ is_number('sensor.nordpool_kwh_se3_sek_3_10_025') }}"
        state: "{{ states('sensor.nordpool_kwh_se3_sek_3_10_025') | float(0) - 0.25 }}"

Then you will have a new sensor.electricity_selling_price with the adjusted value.

By the way, what if the NordPool price is lower than 0.25 ore/kWh? How should be your selling price in this case?

1 Like

Edward, that’s awesome. Many thanks.

But I do have a problem it seems (see screenshot).
I need to read up on your question on the negative price though :slight_smile:

You are missing the beginning of the code I’ve shared where the template: is and also some Indentation.
Try to copy my code again, including the first line.

Good, I am a step further but now I have this :slight_smile:

Go to Developer Tools, select the tab Status and then search for sensor.electricity_selling_price. Please share what you find there.

This is awesome, many thanks, buddy.

For less cluttered & easy to scan UI, replace

const timeString = startDate.toLocaleTimeString(locale)


const timeString = startDate.toLocaleTimeString([], { hour12: false, hour: "2-digit" })


cmon guys, such a long thread and nobody has come up with a graph that includes tariffs?
Or am i just bad at search? :slight_smile:
Isnt the day and night difference in tariffs common in most countries?

for example in EE the tariff price changes to night at 22:00, so doing whatever automation to track cheapest hours, might be thrown off a lot, if market price between 21-22 and 22-23 is reversing the tariffs gain.
One should calculate the, lets say, “cheapest hours” by a table that includes tariffs.

Can we get @arva, @kalapragu, @wjaceh or any other smart guy to show how this nordpool array can be shot through the tariffs template to come up with “final price” graph?

There is an example on how to add (non-fixed) tarrifs in the price on the GitHub page. That way, the graph does not need to contain this logic.

example to the graph or just “current price”?
We have many examples how to take current price and add current tariff to that.
But I see none that go through the whole graph and adjust this to tariffs.
Current is easy. But that does not visualize the day with changing tariffs.

If you check the apex chart integration on this forum you will see many examples

didnt you really read the problem before answering or am i really bad at search?
You say there are examples of nordpool graph that includes in it’s prices not just market price but also changing tariffs prices, on the graph columns throughout the day?
Could you link one please?

I have a template sensor for Võrk4 tariff:

  - platform: template 
      el_tariff: #hinnad KM-ita, template arvutiab km-i otsa *1.2
        friendly_name: "Electricity Tariffs"
        unit_of_measurement: '€/kWh'
        value_template: >-
          {% macro calc(v) -%}
            {%set d = {"operator_margin": 0.000, 
                      "electricity_excise": 0.001,
                      "renewable_tariff": 0.0113,
                      "nw_fee_night": 0.0186,
                      "nw_fee_day": 0.0326
           } %}
          {%set day_price = v + ((d.operator_margin + d.renewable_tariff + d.electricity_excise + d.nw_fee_day) * 1.2 | float ) | round(4)%}
          {%set night_price = v + ((d.operator_margin + d.renewable_tariff + d.electricity_excise + d.nw_fee_night) * 1.2 | float ) | round(4)%}
          {% if now().weekday() in (5,6) %}
          {% else %}
            {% if now().hour >= 7 and now().hour < 22%}
            {% else %}
            {% endif %}
          {% endif %}
          {%- endmacro %}

If you have this, you can use it in Nordpool integration configuration. Example 4:

additional_costs: ''{{ (states('sensor.el_tariff')) | float(0) }}''

As i havent’t tested it, i cannot tell if it then shows the current value + additional cost (eg. "final price) on the graph, but I’m quite sure it does. Test it out and let us know.

I do have Võrk4 tariff, and you should check yours, since in your example they are old, life got more expensive while you were not looking!
But now i get it, tariff sensor can be added into the additional costs… thank you sir.
But nordpool graph with tariff added this way seems to only look at the tariff entity’s current value and slaps that onto everything. It seems like we cant get away that easy… because the tariff value should change when daytime begins etc, so it cant be just looking at the entitys current value…