# How do I add fixed surcharge to the energy tariff?

In Denmark we have two parts of the energy cost.
First part is the transportation, this is a price that is based on the cost of the infrastructure, and thus doesn’t fluctuate, this is usually the most expensive part (though with the current fluctuations, not always).
The other part is the energy cost itself.
I’ve set up the Nordpool integration to get the cost as it changes during the day (I hope the energy dashboard can handle that?)
But how do I add a fixed cost / kwh to that fluctuating price?
This is the energy cost during today:

Usually the price for the transport is around Dkr 2,5 / kWh on top of that.

1 Like

The Nordpool integration allows adding additional costs. They even have an example:

``````    # This option allows the usage of a template to add a tariff.
# now() always refers start of the hour of that price.
# this way we can calculate the correct costs add that to graphs etc.
# The price result of the additional_costs template expects this additional cost to be in kWh and not cents as a float
# default {{0.0|float}}
``````
1 Like

Wow, I didn’t see that, didn’t imagine it was there, so looked everywhere else
Thanks @tom_l

Looks like it changes (or could change) on the hour every hour?

I have adapted the following from a similar but different use case I have for my own calculations but yours is more complicated and therefore some things are untested. I hope the concept is clear enough.

make an input number or sensor that holds the daily supply charge. e.g `sensor.electricity_supply_charge`

Setup a utility meter with 24 tariffs (0 to 23) that’s source is your energy consumption in kWh and cycle is daily

``````utility_meter:
electricity_consumption_hourly:
source: sensor.electricity_consumption
name: Electricity Consumption_hourly
cycle: daily
tariffs:
- 0
- 1
- 2
- 3
- etc etc....
- 22
- 23
``````

I’m assuming you can’t access the 24 different rates as attributes or the nordpool sensor so you’ll need to create 24 input numbers to hold the values.

``````input_number:
electricity_price_hour_0:
name: Electricity Price Hour 0
# initial: 0 # don't use initial as it will reset upon a restart
min: 0
max: 10
step: 0.00001 # as many 0's as you need

electricity_price_hour_1:
name: Electricity Price Hour 1
min: 0
max: 10
step: 0.00001

................

electricity_price_hour_23:
name: Electricity Price Hour 23
min: 0
max: 10
step: 0.00001
``````

Setup an automation that changes the tariff whenever the price changes using the current hour as the data. The second action should also update the relevant input_number

``````trigger:
- platform: state
entity_id: sensor.nordpool_sensor_that_changes_hourly
condition: []
action:
- service: select.select_option
data:
option: '{{ now().hour }}'
target:
entity_id:
- select.electricity_consumption_hourly
- service: input_number.set_value
data_template:
target:
{% set hr = now().hour %}
entity_id: input_number.electricity_price_hour_{{hr}}
data:
value: {{states('sensor.nordpool_sensor_value')}}

``````

Setup a template sensor that calculates the daily total

``````template:
- sensor:
- name: Total Daily Cost
state_class: total_increasing
device_class: monetary
unit_of_measurement: \$
state: >
{% set supply = states('sensor.electricity_supply_charge') | float(0) %}
{% set hour0 = states('sensor.electricity_consumption_hourly_0') | float(0) * states('input_number.electricity_price_hour_0') | float(0) %}

...........
{% set hour23 = states('sensor.electricity_consumption_hourly_23') | float(0) * states('input_number.electricity_price_hour_23') | float(0) %}

{{ (supply + hour0 + hour1 + ........ + hour23) | round(2) }}
``````

Setup a statistic sensor that tracks the cost as a long term statistic (i think but not sure if this is necessary)

``````sensor:
- platform: statistics
entity_id: sensor.total_daily_cost
state_characteristic: total_increasing
``````

lol well i wasted the last hour

1 Like

But @SgtBatten You are still a gem! Thankyou very much for your wish to help.

Thanks,

I have a complicated setup similar to what i posted above to handle demand charges here in australia.

Essentially i have my normal usage rates in peak offpeak and shoulder times, plus the supply charge just like you.

On top of that though i have an amount that is calculated based on the maximum average usage over a 30 minute period during specific hours of the day, on business days, at different rates depending on the time of year multiplied by the number of days in the month.

Geeez, so all in all an electrical bill that’s easy to understand
Oh, and I found out why I didn’t see the ‘additional cost’ thing, it’s because I used the integration through HA, and not by creating a sensor, and the ‘additional cost’ is a bit weird in the integration.