Hi all,
I have set up the EV Smart Charging integration with data from Nord Pool. But it doesn’t take the changing tariffs in to account (peak, off peak, low). So, the time for charging my EV is only based on the raw spot price.
I have tried to create a template sensor that adds the relevant tarif to the hourly prices in the Nord Pool sensors attributes. But i cannot get it to work.
Did anybody succeed in adding tariffs to the input for EV Smart Charging?
Cheers
If anybody has the same issue. I got Claude to help me generate this template senosor. Problem solved
# Input værdier
input_number:
c_tarif_peak:
name: "C-tarif Spids"
initial: 0.4760
min: 0
max: 5
step: 0.0001
mode: box
c_tarif_high:
name: "C-tarif Høj"
initial: 0.1831
min: 0
max: 5
step: 0.0001
mode: box
c_tarif_offpeak:
name: "C-tarif Lav"
initial: 0.1220
min: 0
max: 5
step: 0.0001
mode: box
systemtarif:
name: "Systemtarif"
initial: 0.0920
min: 0
max: 5
step: 0.0001
mode: box
transmissionsnettarif:
name: "Transmissionsnettarif"
initial: 0.0760
min: 0
max: 5
step: 0.0001
mode: box
# Template-sensor
template:
- trigger:
- platform: homeassistant
event: start
- platform: time_pattern
hours: "*"
- platform: state
entity_id: sensor.nordpool_kwh_dk2_dkk_3_10_025
sensor:
- name: "EV Price with Tarif Forecast"
unique_id: "ev_price_with_tarif_forecast"
unit_of_measurement: "DKK/kWh"
device_class: monetary
availability: >
{{ states('sensor.nordpool_kwh_dk2_dkk_3_10_025') not in ['unavailable', 'unknown', 'none'] and
state_attr('sensor.nordpool_kwh_dk2_dkk_3_10_025', 'raw_today') is not none }}
state: >
{% set np = states('sensor.nordpool_kwh_dk2_dkk_3_10_025') | float(none) %}
{% if np is not none %}
{% set hour = now().hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{% set total = np +
states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif %}
{{ total | round(3) }}
{% else %}
unavailable
{% endif %}
attributes:
state_class: total
average: >
{% set prices = state_attr('sensor.nordpool_kwh_dk2_dkk_3_10_025', 'raw_today') %}
{% if prices is not none and prices != [] %}
{% set total = 0 %}
{% for p in prices %}
{% set hour = as_datetime(p.start).hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{% set price_with_tarif = p.value | float(0) +
states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif %}
{% set total = total + price_with_tarif %}
{% endfor %}
{{ (total / prices | length) | round(6) }}
{% else %}
0
{% endif %}
min: >
{% set prices = state_attr('sensor.nordpool_kwh_dk2_dkk_3_10_025', 'raw_today') %}
{% if prices is not none and prices != [] %}
{% set min_price = none %}
{% for p in prices %}
{% set hour = as_datetime(p.start).hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{% set price_with_tarif = p.value | float(0) +
states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif %}
{% if min_price is none or price_with_tarif < min_price %}
{% set min_price = price_with_tarif %}
{% endif %}
{% endfor %}
{{ min_price | round(3) }}
{% else %}
0
{% endif %}
max: >
{% set prices = state_attr('sensor.nordpool_kwh_dk2_dkk_3_10_025', 'raw_today') %}
{% if prices is not none and prices != [] %}
{% set max_price = none %}
{% for p in prices %}
{% set hour = as_datetime(p.start).hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{% set price_with_tarif = p.value | float(0) +
states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif %}
{% if max_price is none or price_with_tarif > max_price %}
{% set max_price = price_with_tarif %}
{% endif %}
{% endfor %}
{{ max_price | round(3) }}
{% else %}
0
{% endif %}
mean: >
{% set prices = state_attr('sensor.nordpool_kwh_dk2_dkk_3_10_025', 'raw_today') %}
{% if prices is not none and prices != [] %}
{% set total = 0 %}
{% for p in prices %}
{% set hour = as_datetime(p.start).hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{% set price_with_tarif = p.value | float(0) +
states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif %}
{% set total = total + price_with_tarif %}
{% endfor %}
{{ (total / prices | length) | round(3) }}
{% else %}
0
{% endif %}
unit: kWh
currency: DKK
country: Denmark
region: DK2
current_price: >
{% set np = states('sensor.nordpool_kwh_dk2_dkk_3_10_025') | float(none) %}
{% if np is not none %}
{% set hour = now().hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{% set total = np +
states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif %}
{{ total | round(3) }}
{% else %}
0
{% endif %}
additional_costs_current_hour: >
{% set hour = now().hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{{ (states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif) | round(3) }}
price_in_cents: false
today: >
{% set prices = state_attr('sensor.nordpool_kwh_dk2_dkk_3_10_025', 'raw_today') %}
{% if prices is not none and prices != [] %}
{% set today_prices = [] %}
{% for p in prices %}
{% set hour = as_datetime(p.start).hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{% set price_with_tarif = p.value | float(0) +
states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif %}
{% set today_prices = today_prices + [price_with_tarif | round(3)] %}
{% endfor %}
{{ today_prices | join(', ') }}
{% else %}
""
{% endif %}
tomorrow: >
{% set prices = state_attr('sensor.nordpool_kwh_dk2_dkk_3_10_025', 'raw_tomorrow') %}
{% if prices is not none and prices != [] %}
{% set tomorrow_prices = [] %}
{% for p in prices %}
{% set hour = as_datetime(p.start).hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{% set price_with_tarif = p.value | float(0) +
states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif %}
{% set tomorrow_prices = tomorrow_prices + [price_with_tarif | round(3)] %}
{% endfor %}
{{ tomorrow_prices | join(', ') }}
{% else %}
""
{% endif %}
tomorrow_valid: "{{ state_attr('sensor.nordpool_kwh_dk2_dkk_3_10_025', 'tomorrow_valid') | default(false) }}"
raw_today: >
{% set prices = state_attr('sensor.nordpool_kwh_dk2_dkk_3_10_025', 'raw_today') %}
{% if prices is not none and prices != [] %}
{% set raw = namespace(items=[]) %}
{% for p in prices %}
{% if p.start is defined and p.value is defined %}
{% set hour = as_datetime(p.start).hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{% set total = p.value | float(0) +
states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif %}
{% set new_item = {
'start': as_datetime(p.start).isoformat(),
'end': as_datetime(p.end).isoformat(),
'value': total | round(3)
} %}
{% set raw.items = raw.items + [new_item] %}
{% endif %}
{% endfor %}
{{ raw.items }}
{% else %}
[]
{% endif %}
raw_tomorrow: >
{% set prices = state_attr('sensor.nordpool_kwh_dk2_dkk_3_10_025', 'raw_tomorrow') %}
{% if prices is not none and prices != [] %}
{% set raw = namespace(items=[]) %}
{% for p in prices %}
{% if p.start is defined and p.value is defined %}
{% set hour = as_datetime(p.start).hour %}
{% set tarif =
states('input_number.c_tarif_offpeak') | float(0) if hour < 6 else
states('input_number.c_tarif_high') | float(0) if hour < 17 or hour >= 21 else
states('input_number.c_tarif_peak') | float(0) %}
{% set total = p.value | float(0) +
states('input_number.systemtarif') | float(0) +
states('input_number.transmissionsnettarif') | float(0) +
tarif %}
{% set new_item = {
'start': as_datetime(p.start).isoformat(),
'end': as_datetime(p.end).isoformat(),
'value': total | round(3)
} %}
{% set raw.items = raw.items + [new_item] %}
{% endif %}
{% endfor %}
{{ raw.items }}
{% else %}
[]
{% endif %}
max4148
(Max4148)
August 20, 2025, 1:12pm
3
hey helmaar
your post is a godsend
im fighting with getting ev smart charging to read the nordpool dk trariff while configuring the integration
it says on their developer page that it gets data automatically from the nordpool integration which i already have
what am i doing wrong?
regards
Hi max4148,
It is hard to say from your description what is wrong with your setup. This is a screenshot of the configuration that is working for me (with the sensor including the tariffs above).
max4148
(Max4148)
August 20, 2025, 3:53pm
5
thanks for the quick reply
but i guess u have made the sensors first
mine should be this but throws off this error
I am using the custom Nordpool integration from HACS. Maybe that is your problem. How does the attributes of your sensor look? Mine looks like this:
max4148
(Max4148)
August 20, 2025, 4:57pm
7
are you on insta or messenger or maybe reddit?
let me send me an invite there
mine is definieltey not this one
can you share a link to the nordpool repo you have installed
regards
max4148
(Max4148)
August 26, 2025, 10:02am
9
got it working finally
big relief and thanks for the big help
cheers
Great discussion — layering tariffs on top of Nord Pool is exactly the right move, since the raw spot price is never what lands on the bill. When comparing what different contracts add on top of spot, I use a Finnish page like fortum sähkön hinta that shows Fortum’s price against live spot prices, which makes the provider margin and fees easy to sanity-check. Just remember the Nord Pool sensor values are ex-VAT, so add your local VAT rate in the template or the charging plan will systematically undershoot the real cost.