Prijsplafond sensor

This is for the Dutch followers.

since we have a “prijsplafond” for 2023 and each month will have it’s own max kwh/gas m3 i’m waondering how could i configure this in Homeassistant in such a wat i can monintor my month usage versus the max kwh of that month,

Want to put all in a graph.
The actual energy usage of day/week/month is all there but how could we do this ?
fe. jan max 340 kwh
may 181 kwh

https://www.gaslicht.com/energienota/prijsplafond-energie

5 Likes

I found this code on github

sensor:
  - platform: prijsplafond
    sources_total_power:
    - sensor.p1_meter_5c2faf0544ee_total_power_import_t1
    - sensor.p1_meter_5c2faf0544ee_total_power_import_t2
    source_total_gas: sensor.p1_meter_5c2faf0544ee_total_gas
    - sensor.p1_meter_total_power_import_t1
    - sensor.p1_meter_total_power_import_t2
    source_total_gas: sensor.p1_meter_total_gas

But don’t have a clue how to implemented this. Would be nice if it could be included in the Energie Dashboard. If the limit is reached or almost reached a alert could be send.

I was able to make a calculation .
With help of the post below. I build further on that and updated my solution there:

If I understand correctly its not a monthly limit/plafond. The whole year is divided in two: before and after the annual invoice.
To calculate how much “budget” you have before, and how much after the annual invoice, you can use the monthly values they published.
So f.e. if your invoice is in May, you add up the values of Jan until May, and that sum is your prijsplafond budget until May.
You can f.e. spend the entire budget in Jan and not use anything in Feb, mrt, Apr and May. And you are still good. Well, “good”. Still 4-8x more expensive than before the EU sanctions.

Someone on tweakers fixed it,
However it requires the monthly totals for gas & pwr.
The HA energy dashboard showes those numbers, but i have no idea which entities or whatever are used to show them. Perhaps the HA team can create additional helpers so we can re-use the monthly totals for the prijsplafond calculation?

https://gathering.tweakers.net/forum/list_messages/2161212

1 Like

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

  1. 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"

  1. 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

  2. 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 :slight_smile:

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

1 Like

I use this compilation of what is posted above. I track on a monthly basis which is accurate enough for me.
Template that calculates my nett power / gas intake, using the data from the smart meter (TOON by Eneco).

- sensor:

    - name: "ExcessPWR"

      unique_id: EXCESSPW

      unit_of_measurement: "W"

      state: >

        {% set solarpower = states('sensor.envoy_122132006964_current_power_production') | int %}

        {% set powerusage = states('sensor.current_power_usage') | int %}

        {{ (solarpower - powerusage) | int }}

       

    - name: "pwrbudget"

      unique_id: pwrbdgt

      unit_of_measurement: "kW"

      device_class: energy

      state: >

          {% if now().strftime("%m") == "01" %}

            {% set plafond = 300 %}

          {% elif now().strftime("%m") == "02" %}

            {% set plafond = 281 %}

          {% elif now().strftime("%m") == "03" %}

            {% set plafond = 267 %}

          {% elif now().strftime("%m") == "04" %}

            {% set plafond = 206 %}

          {% elif now().strftime("%m") == "05" %}

            {% set plafond = 181 %}

          {% elif now().strftime("%m") == "06" %}

            {% set plafond = 159 %}

          {% elif now().strftime("%m") == "07" %}

            {% set plafond = 161 %}

          {% elif now().strftime("%m") == "08" %}

            {% set plafond = 176 %}

          {% elif now().strftime("%m") == "09" %}

            {% set plafond = 199 %}

          {% elif now().strftime("%m") == "10" %}

            {% set plafond = 267 %}

          {% elif now().strftime("%m") == "11" %}

            {% set plafond = 306 %}

          {% elif now().strftime("%m") == "12" %}

            {% set plafond = 356 %}

          {% endif %}

          {% set mnthpwr = states('sensor.nett_pwr') | int %}

          {{ (plafond + mnthpwr/1000) | int }}

         

    - name: "gasbdgt"

      unique_id: gasbudget

      unit_of_measurement: "m3"

      state: >

          {% if now().strftime("%m") == "01" %}

            {% set plafond2 = 196 %}

          {% elif now().strftime("%m") == "02" %}

            {% set plafond2 = 188 %}

          {% elif now().strftime("%m") == "03" %}

            {% set plafond2 = 159 %}

          {% elif now().strftime("%m") == "04" %}

            {% set plafond2 = 86 %}

          {% elif now().strftime("%m") == "05" %}

            {% set plafond2 = 35 %}

          {% elif now().strftime("%m") == "06" %}

            {% set plafond2 = 19 %}

          {% elif now().strftime("%m") == "07" %}

            {% set plafond2 = 17 %}

          {% elif now().strftime("%m") == "08" %}

            {% set plafond2 = 17 %}

          {% elif now().strftime("%m") == "09" %}

            {% set plafond2 = 24 %}

          {% elif now().strftime("%m") == "10" %}

            {% set plafond2 = 81 %}

          {% elif now().strftime("%m") == "11" %}

            {% set plafond2 = 147 %}

          {% elif now().strftime("%m") == "12" %}

            {% set plafond2 = 206 %}

          {% endif %}

          {% set mnthgas = states('sensor.gas_maand') | int %}

          {{ plafond2 - mnthgas | int }}

sensor.gas_maand is a helper (Utility meter type accumulating the gas_meter entity from TOON), same for sensor.nett_pwr (whic accumulates the calculated entity Excess_pwr
These reset monthly.
You can make a gauge card with the needle showing the remaining gas or power budget for this month.
You do need a P1 collector from either a vendor or use TOON (eneco).

1 Like