Any good ideas are welcome. Nordpool Energy Price per hour

Thank you, but still i get errors, i really do not understand it.

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml


climate:
  - platform: touchline
    host: http://10.0.0.59

platform: template
sensors:
  delta_t_solar_heating:
    friendly_name: Surplus solar 3
    unit_of_measurement: W
    value_template: >-
      {{ ( states('sensor.pv_power') | float | 
      round(0)) -  ( states('sensor.load_power') | float 
      | round(0))}} 

Now i get

Integration error: sensors - Integration ‘sensors’ not found.
Integration error: platform - Integration ‘platform’ not found.

I added the link for this reason, your syntax is incomplete, check description Legacy Sensor configuration format

You need to invoke “sensor:” first followed by the code I shared. But don’t forget the -

If you check the link you will figure it out.

Thank you for trying, but i looked at the link and understood nothing.

I know i copied the “sensor” from some thread, but can not remember if it was in this thread or somewhere else.

I will just have to trawl through this site and see if i can find where i copied it from, i am not very good at this, i can easily copy something that works, but understanding exactly what makes, what work, is not my forte sadly.

But thanks for trying, i know i am a bit of a lost cause :slight_smile:

Hi
Any chance you would like to share your automation for charging battery when price is low?

Niklas

Hi!
Yesterday i changed the nordpool sensor to cents (Living in Finland)
Unistalled nordpool and installed again, so the settings are correct
But the energy dashboard does not calculate it correct? Any suggestions?

Imported should be 30cent and exported 1.19€… its hard to know those numbers exactly but something around that number.
Not 123€ and 3€

1 Like

Did you figure it out? It seems I am getting the sensor readings always in cents. So the energy dashboard has a x100 factor in price calculation. This happened after the last update.

1 Like

Is it possible to find the cheapest hours between hour 21-06 ?

Try this:

{{ (state_attr('sensor.nordpool_kwh_se3_sek_3_10_025', 'raw_today') + state_attr('sensor.nordpool_kwh_se3_sek_3_10_025', '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
| first
}}
1 Like

Perfect … it works :slight_smile: wow Thanks!

Can you make it so I can choose the 1,2,3, or 4 cheapest hour – so it shows True or False
is that easy to make ?

I’m not sure if I understood what you are looking for.
I can easily change that to show the “n” cheapest hour on that interval. Just change that last number on [0:n] for the number of hour you want.
For the cheapest 4 hours on that interval, in ther order from the cheapest hour to the 4th cheapest hour:

{{ ((state_attr('sensor.nordpool_kwh_se3_sek_3_10_025', 'raw_today') + state_attr('sensor.nordpool_kwh_se3_sek_3_10_025', '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’m not sure what you mean by shown true/false… compare to what?

Hi … thanks

I want to use it in an automation - and i will trigger when ex. it is the 4 cheapest hours from 21-06
I hope it make sens :slight_smile:

with your new code I get this

Well, you can have an automation running every time the price changes between this time interval and then check if it is cheaper than the max of the 4 cheapest prices and based on that turn on or off your device.

I would try something like this:

mode: single
trigger:
  - platform: state
    entity_id:
      - sensor.nordpool_kwh_se3_sek_3_10_025
condition:
  - condition: time
    after: "21:00:00"
    before: "06:00:00"
action:
  - if:
      - condition: template
        value_template: >
          {{ states('sensor.nordpool_kwh_se3_sek_3_10_025') <= ((state_attr('sensor.nordpool_kwh_se3_sek_3_10_025', 'raw_today') + state_attr('sensor.nordpool_kwh_se3_sek_3_10_025', '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)[0:4]
            | max
            | float(0)
          }}
    then:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.my_car_charger
    else:
      - service: switch.turn_off
        data: {}
        target:
          entity_id: switch.my_car_charger

But please note this is turning on/off bested on the cheapest 4 hours, not on the cheapest 4 CONSECUTIVE hours, which will require a bit more complexity.
For a car charger, you probably want 4 cheapest hours, but for a dishwasher, you probably want the cheapest 4 consecutive hours.

1 Like

Thanks for your time, I will check this out.

1 Like

Hi, i can’t seem to get the extrema’s showing, anyone see why ? :

type: custom:apexcharts-card
graph_span: 23h
span:
  start: day
now:
  show: true
  label: Nu
header:
  show: true
  show_states: false
  title: Electriciteitsprijzen Vandaag (€/kwh)
yaxis:
  - min: '|-0.10|'
    max: '|+0.10|'
    decimals: 2
    apex_config:
      tickAmount: 15
series:
  - entity: sensor.day_ahead_average_electricity_price_today
    show:
      extremas: true
      legend_value: true
    name: Uurprijs
    stroke_width: 0
    float_precision: 2
    type: column
    opacity: 0.8
    color: ''
    data_generator: |
      return entity.attributes.prices.map((entry) => { 
      return [new Date(entry.time), entry.price];
      });

image

Did anyone find a fix for the hour 23-24 not showing in apexcard?

The push for extra datapoint didn’t work, as said. I also tried extend to end, which fills it to end of day2. Also setring group_by 1h and duration 1h didn’t work

Hello All,

I’m trying to create a template that shows the true cost for electricity. I’m using a template from smarthomejunkie as a starting point. He created a helper to add additional cost but i want to add it to the template file.
What i have so far:

- sensor:
    - name: "Nordpool Energie Prijzen"
      unique_id: 46c4adb8-b582-4dcf-8b19-0b80646c82f0
      icon: mdi:currency-eur
      unit_of_measurement: "€"
      state: >
        {% set energy_tax = 0.1524 | float %}
        {% set extra_cost = 0.0175 | float %}
        {% set VAT = 1.21 | float %}
        state: {{ (((states('sensor.nordpool_kwh_nl_eur_3_10_021') | float / 121) * 100) + energy_tax + extra_cost) * VAT }}
        attributes:
        times: >
          {% set ns = namespace(times=[]) -%}
          {%- set today = state_attr('sensor.nordpool_kwh_nl_eur_3_10_021', 'raw_today') -%}
          {%- for hours in today -%}
            {%- set ns.times = ns.times + [as_local((hours.start)).strftime("%Y-%m-%d %H:%M:%S")] -%}
          {%- endfor -%}
          {%- set tomorrow = state_attr('sensor.nordpool_kwh_nl_eur_3_10_021', 'raw_tomorrow') -%}
          {%- for hours in tomorrow -%}
            {%- set ns.times = ns.times + [as_local((hours.start)).strftime("%Y-%m-%d %H:%M:%S")] -%}
          {%- endfor -%}
          {{ ns.times }}
        prices: >
          {% set ns = namespace(prices=[]) -%}
          {%- set today = state_attr('sensor.nordpool_kwh_nl_eur_3_10_021', 'raw_today') -%}
          {%- for hours in today -%}
            {%- set ns.prices = ns.prices + [(((hours.value / 121) * 100) + energy_tax + extra_cost) * VAT] -%}
          {%- endfor -%}
          {%- set tomorrow = state_attr('sensor.nordpool_kwh_nl_eur_3_10_021', 'raw_tomorrow') -%}
          {%- for hours in tomorrow -%}
          {% if hours.value %}
            {%- set ns.prices = ns.prices + [(((hours.value / 121) * 100) + energy_tax + extra_cost) * VAT] -%}
          {% endif %}
          {%- endfor -%}
          {{ ns.prices }}

When i insert it to “template” in “developers tools” it gives the following output


but it doesn’t load any data in the tabel.
(see image in next post because i can only embed 1 image)
What am i missing in this?

Remote state: from the 10th line in your paste and move attributes: two spaces to the left.

Thank you! That did the trick.
Had some other errors bur those are resolved already.
In case anybody else is interrested, below is the full script with the prices rounded to 2.

# Nordpool Settings
- sensor:
    - name: "Nordpool Energie Prijzen"
      unique_id: 46c4adb8-b582-4dcf-8b19-0b80646c82f0
      icon: mdi:currency-eur
      unit_of_measurement: "€"
      state: >
        {% set energy_tax = 0.1524 | float %}
        {% set extra_cost = 0.0175 | float %}
        {% set VAT = 1.21 | float %}
        {{ ((((states('sensor.nordpool_kwh_nl_eur_3_10_021') | float / 121) * 100) + energy_tax + extra_cost) * VAT) | round(2) }}
      attributes:
        times: >
          {% set ns = namespace(times=[]) -%}
          {%- set today = state_attr('sensor.nordpool_kwh_nl_eur_3_10_021', 'raw_today') -%}
          {%- for hours in today -%}
            {%- set ns.times = ns.times + [as_local((hours.start)).strftime("%Y-%m-%d %H:%M:%S")] -%}
          {%- endfor -%}
          {%- set tomorrow = state_attr('sensor.nordpool_kwh_nl_eur_3_10_021', 'raw_tomorrow') -%}
          {%- for hours in tomorrow -%}
          {%- if hours.value -%}
            {%- set ns.times = ns.times + [as_local((hours.start)).strftime("%Y-%m-%d %H:%M:%S")] -%}
          {%- endif -%}
          {%- endfor -%}
          {{ ns.times }}
        prices: >
          {% set energy_tax = 0.1524 | float %}
          {% set extra_cost = 0.0175 | float %}
          {% set VAT = 1.21 | float %}
          {% set ns = namespace(prices=[]) -%}
          {%- set today = state_attr('sensor.nordpool_kwh_nl_eur_3_10_021', 'raw_today') -%}
          {%- for hours in today -%}
            {%- set ns.prices = ns.prices + [((((hours.value / 121) * 100) + energy_tax + extra_cost) * VAT) | float | round(2)] -%}
          {%- endfor -%}
          {%- set tomorrow = state_attr('sensor.nordpool_kwh_nl_eur_3_10_021', 'raw_tomorrow') -%}
          {%- for hours in tomorrow -%}
          {% if hours.value %}
            {%- set ns.prices = ns.prices + [((((hours.value / 121) * 100) + energy_tax + extra_cost) * VAT) | float | round(2)] -%}
          {% endif %}
          {%- endfor -%}
          {{ ns.prices }}

I needed to define the variables twice

1 Like

Is there a way to create a sensor that always show the price of the previous hour?

I want to use it to multiply it with my house solar energy consumption for the previous hour.
In this way calculating every 1min after each hour my “real saving”.

Sorry this may be slightly off topic but this thread seem to contain many experts on how to pull the attribute data off the nordpool sensor.

Many thanks