Hey there… I did get it working for myself allthough probably in a very very very bad way.
First off , the data: the actual limits are daily limits, so each and every day there is a limit you can go over:
- find it here Subsidieregeling bekostiging plafond energietarieven kleinverbruikers 2023 | Kamerstuk | Rijksoverheid.nl*
- Secondly As source input i used De Slimme Lezer + , so i have one for Electricty peak,off peak and Gas
- thirdly i am terribly lazy, so i took a fixed price ( Off peak tarriff ) for anything that goes over the limit, so that you would have to calculate yourself in the Template part of this post
( without fixing this, you do not see the exactly costs for a day you pump all your electricity out before off peak tariff, and you meet the high tariff partially untill off peak kicks in , for me its enough, i needed a reasonable calculation, not an exact )
Step 1 Stored the daily gas an electricity values inefficiently as an attribute:
This was done in configuration.yaml
Gas Data(This is not all the code, there is 365 attributes (shame))
- platform: template
sensors:
prijsplafond_gas:
friendly_name: "prijsplafond G"
value_template: >-
{{ glimit }}
attribute_templates:
01-01-2023: "{{7.17361783}}"
02-01-2023: "{{7.29365989}}"
03-01-2023: "{{7.50814813}}"
And so on for the rest of the year , and the same for electricity called elimit instead of glimit
Electricity Data (This is not all the code, there is 365 attributes (shame))
- platform: template
sensors:
prijsplafond_electricity:
friendly_name: "prijsplafond E"
value_template: >-
{{ elimit }}
attribute_templates:
01-01-2023: "{{11.321629}}"
02-01-2023: "{{11.151776}}"
03-01-2023: "{{10.814767}}"
Step 2 Then i made a sensor to check for today’s daily limit for electricity and gas:
- platform: template
sensors:
today_gaslimit:
unit_of_measurement: "m3"
value_template: >-
{% set dev_attr = now().timestamp() | timestamp_custom('%d-%m-%Y') %}
{{ state_attr('sensor.prijsplafond_gas', dev_attr )}}
today_elimit:
unit_of_measurement: "kWh"
value_template: >-
{% set dev_attr = now().timestamp() | timestamp_custom('%d-%m-%Y') %}
{{ state_attr('sensor.prijsplafond_electricity', dev_attr )}}
Step 3 calculating total for Electricity + gas prices + MAking a price template sensor
- Additional REquired : input value total electricity in a day
- platform: template
sensors:
total_energy_nr:
unit_of_measurement: "kWh"
value_template: "{{states('sensor.electricity_peak_daily')|round(3) + states('sensor.energy_meter_daily_off_peak')|round(3)}}"
friendly_name: "Energy Today"
-
Required: my sensor for daily gas total, called gas_daily, i got it from my gas_consumed sensor and made a helper to caocluate daily
-
So with all that i made one daily electricity meter:
LT= Low tariff
HT= High Tarriff
First if kicks off if total energy is lower then limit in other words, all is low tariff that day
Otherwise it takes the full limit and calculates the price of that calculates on top of that whats over that limit and calculates the high tariff for that, and does a sum of both.
day_electricity_price:
friendly_name: "Day Electricity Price"
unit_of_measurement: "EUR/kWh"
value_template: >-
{% set tariff = { "LT": 0.40, "HT": 0.73 } %}
{% if states('sensor.total_energy_nr') | float < states('sensor.today_elimit') | float %}
{{ (states('sensor.total_energy_nr')|float * tariff.LT)|round(2) }}
{% else %}
{{(states('sensor.today_elimit')|float * tariff.LT)|round(2) + ((states('sensor.total_energy_nr')|float - states('sensor.today_elimit')|float) * tariff.HT) |round(2) }}
{%- endif %}
And one Daily Gas meter (See electricity explanation ):
day_gas_price:
friendly_name: "Day Gas Price"
unit_of_measurement: "EUR"
value_template: >-
{% set tariff = { "LT": 1.40, "HT": 2.92 } %}
{% if states('sensor.gas_daily') | float < states('sensor.today_gaslimit') | float %}
{{ (states('sensor.gas_daily')|float * tariff.LT )|round(2) }}
{% else %}
{{ (states('sensor.today_gaslimit')|float * tariff.LT) + (states('sensor.gas_daily')|float - states('sensor.today_gaslimit')|float) * tariff.HT }}
{%- endif %}
Step 4 I calculate them to be my daily price:
day_bill:
friendly_name: "Day Energy Price"
unit_of_measurement: "EUR"
value_template: "{{ (states('sensor.day_gas_price')|float + states('sensor.day_electricity_price')|float )| round(2) }}"
And every day i add to my monthly price ( counter helper , reset with automation and fixed time) and yearly and so on
Its a terrible solution, but with the complexety of the scenario and the lack of real solutions, it works for me… hopefully it gives people a hook to work off on
Sorry for any messy summaries, but i really think people can work this out better, so if this works for me, maybe it inspires people to do much better with the concept disregarding the crappy typing and coding skills i obtain