Need help with template (Prijsplafond)

I created 2 utility meters “electra_jaar_hoog” and “electra_jaar_Laag” (since my meter is using 2 tariffs)
my contract has only one tariff so i can combine both to one total.

Tomorrow there will be a new rule. all consumption bellow 2900kw is an expensive tariff. above that… it is even more expensive.
Above rule is not completly correct since there are limits per month. but for now… it is good enough.
however if i add this template. the result is “unavailable”

Tried both ‘2900’ and 2900 but the same result

      - name: Energie-Tarief
        state: >
              {% if states((sensor.electra_jaar_hoog ) + (sensor.electra_jaar_Laag ) ) > '2900'  %}
              0,40
              {% else %}
              0,68
              {%- endif %}

      - name: Energie-Tarief
        state: >
          {% if states('sensor.electra_jaar_hoog')|float(0) + states('sensor.electra_jaar_Laag')|float(0) < 2900 %}
            0.40
          {% else %}
            0.68
          {% endif %}
        availability: >
          {{ states('sensor.electra_jaar_hoog')|is_number and states('sensor.electra_jaar_Laag')|is_number }}

Thanks for the quick response. It works.

Have a great new year.

For people who also do this. Don’t forget to manual set the inactive Tariff to 0 (or wait until it is used)

made it a litle bit more accurate.
now it takes into account what month it is.
only thing that is not correct (but for me it will never happens) is the amount you have left from the previous month.

      - name: Energie-Maand
        state: >
         {% if  now().month == 1  %} {% set _energietarief = { "max": 340,} %} {% endif %}
         {% if  now().month == 2  %} {% set _energietarief = { "max": 280,} %} {% endif %}
         {% if  now().month == 3  %} {% set _energietarief = { "max": 268,} %} {% endif %}
         {% if  now().month == 4  %} {% set _energietarief = { "max": 207,} %} {% endif %}
         {% if  now().month == 5  %} {% set _energietarief = { "max": 181,} %} {% endif %}
         {% if  now().month == 6  %} {% set _energietarief = { "max": 159,} %} {% endif %}
         {% if  now().month == 7  %} {% set _energietarief = { "max": 161,} %} {% endif %}
         {% if  now().month == 8  %} {% set _energietarief = { "max": 176,} %} {% endif %}
         {% if  now().month == 9  %} {% set _energietarief = { "max": 199,} %} {% endif %}
         {% if  now().month == 10  %} {% set _energietarief = { "max": 267,} %} {% endif %}
         {% if  now().month == 11  %} {% set _energietarief = { "max": 306,} %} {% endif %}
         {% if  now().month == 12  %} {% set _energietarief = { "max": 356,} %} {% endif %}
         {{ _energietarief.max }}
      - name: Energie-Tarief
        unit_of_measurement: 'EUR/kWh'
        state: >
          {% if states('sensor.electra_maand_hoog')|float(0) + states('sensor.electra_maand_laag')|float(0) < states('sensor.energie_maand')|float(0)  %}
            0.40
          {% else %}
            0.68
          {% endif %}
        availability: >
          {{ states('sensor.electra_maand_hoog')|is_number and states('sensor.electra_maand_laag')|is_number }}

Is this correct? Now it counts every kWh below the “plafond” as cheap tariff and if you exceed the “plafond” it count every kWh as the expensive tariff? Or am I missing something?

So for january the first 340kWh costs 0.40 euro. If you use 341 only 1 kWh costs the normal price 0.68 euro…I think this sensor doesn’t do it like this?

The “energy ceiling” works like a discount for “regular use” when you use more than regular (like it nerd with an server etc) than you pay more for the above average part.

The energy dashboard uses this as an variable Tariff.
340kw x0,40 = 136
So 350kw (340x0,40=136)+(10x0,68=6,80)142,80
So during the first 340kw the energy dashboard calculates 0,40/kwh
After this the Tariff is changed for the rest of the month and the Tariff is 0,68
Next month it starts again with 0,40 Tariff until the limit is reached.

Hope I explained it correctly. And my template is working as I explained.

There is one thing not correct.
If you use bellow average, the remaining part Wil be added to the next month. However that will never happen to me. But can be a problem if someone else use this template.

Woo thanks!

Ikzelf heb hem gebruikt aan aangepast met waarden welke in een inputnumber staan
enige waarmee ik nog zit of wat mij nog immer niet duidelijk is vanuit de overheid/leverancier
Het tarief dal/piek als je over het max verbruik gaat per maand.
Voor gas is dit eenvoudig natuurlijk echter voor electriciteit heb je te maken met dal/piek.

of is het dan altijd het maximale tarief?

De eerste 340kw (in januari) kost je inclusief btw maximaal 0,40. Hiervoor zal het piek&dal tarief niet uitmaken. Tenzij je dal tarief onder de 40 cent zit (incl alle belasting)
Alles boven de 340kw zal tegen het normale tarief (+21%btw) komen. Hierbij kan je (afhankelijk van je contract) een piek en dal tarief hebben.

Omdat ik een continue tarief heb heb ik daar geen rekening mee gehouden.


Heb ea eindelijk rond.
Tevens een pagina toegevoegd welke statistiek geeft over verbruik.

prijsplafond.yaml

### Prijsplafond 2023
#input numbers staan in config/input_numbers.yaml
# utility meter values staan in de corresponderende files voor electriciteit en gasmeter.
# slimmemeter_gateway.yaml en gasmeter_gateway.yaml
# Prijsplafond sensors.
sensor:
  - platform: template
    sensors:
# Power Consumption Netto
      monthly_energy_netto:
        value_template: "{{ '%.3f'%(states('sensor.monthly_energy_delivered')|float - states('sensor.monthly_energy_returned')|float ) }}"
        unit_of_measurement: 'kWh'
      last_month_energy_netto:
        value_template: "{{ '%.3f'%(states('sensor.last_month_energy')|float - states('sensor.last_month_energy_returned')|float ) }}"
      yearly_energy_netto:
        value_template: "{{ '%.3f'%(states('sensor.yearly_energy_delivered')|float - states('sensor.yearly_energy_returned')|float ) }}"
        unit_of_measurement: 'kWh' 
# GAS Consumption Netto
      monthly_gas_netto:
        unit_of_measurement: m3
        value_template: "{{ (states('sensor.gasverbruik_deze_maand')|float / 1 ) }}"
      last_month_gas_netto:
        unit_of_measurement: m³
        value_template: "{{ state_attr('sensor.gasverbruik_deze_maand','last_period') }}"  
      yearly_gas_netto:
        unit_of_measurement: m3
        value_template: "{{ (states('sensor.gasverbruik_dit_jaar')|float / 1 ) }}"
# CALCULATIONS
# dal en liektarief is lastig te berekenen aangezien daar momenteel geen informatie over te vinden is.
#Prijsplafond per huishouden
#Maximum verbruik prijsplafond  		2900 kWh			1200 m³
#Tarief stroom en gas prijsplafond		 € 0,40				€ 1,45
# based on :https://community.home-assistant.io/t/need-help-with-template-prijsplafond/510710/4
########
      electric_ceiling_year:
        friendly_name: "What's Electric Ceiling for this year"
        value_template: >
          {% set _energietariefjaar = states('input_number.prijs_plaf_kwh_year') |float %} 
          {{ _energietariefjaar }}
      electric_ceiling_month:
        friendly_name: "What's Electric Ceiling for actual month"
        value_template: >-
          {% if  now().month == 1  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_jan.state ,} %} {% endif %}
          {% if  now().month == 2  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_feb.state ,} %} {% endif %}
          {% if  now().month == 3  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_mar.state ,} %} {% endif %}
          {% if  now().month == 4  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_apr.state ,} %} {% endif %}
          {% if  now().month == 5  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_may.state ,} %} {% endif %}
          {% if  now().month == 6  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_jun.state ,} %} {% endif %}
          {% if  now().month == 7  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_jul.state ,} %} {% endif %}
          {% if  now().month == 8  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_aug.state ,} %} {% endif %}
          {% if  now().month == 9  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_sept.state ,} %} {% endif %}
          {% if  now().month == 10  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_oct.state ,} %} {% endif %}
          {% if  now().month == 11  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_nov.state ,} %} {% endif %}
          {% if  now().month == 12  %} {% set _energietarief = { "max": states.input_number.prijs_plaf_kwh_dec.state ,} %} {% endif %}
          {{ _energietarief.max }}
      electric_tarif_month:
        friendly_name: "What's Electric Tarif for actual month"
        unit_of_measurement: 'EUR/kWh'
        value_template: >
          {% if states('sensor.monthly_energy_netto') |float(0) < states('sensor.electric_ceiling_month')|float(0)  %}
          {% set _electric_tarif_month = states('input_number.plafond_prijs_energie') |float %} 
          {{ _electric_tarif_month }}
          {% else %}
          {% set _electric_tarif_month = states('input_number.stroom_tarief_normaal') |float %} 
          {{ _electric_tarif_month }}
          {% endif %}
      electric_plafond_left_year:
        friendly_name: "What's Left of My Electric Ceiling this year"
        unit_of_measurement: 'kWh'
        value_template: >
          {% set electricused = states('sensor.yearly_energy_netto')|float %}
          {% set electricceiling = states('sensor.electric_ceiling_year') |float %}
          {{ electricceiling - electricused}}
      electric_plafond_left_month:
        friendly_name: "What's Left of My Electric Ceiling this Month"
        unit_of_measurement: 'kWh'
        value_template: >
          {% set electricused_month = states('sensor.monthly_energy_netto')|float %}
          {% set electricceiling_month = states('sensor.electric_ceiling_month') |float %}
          {{ electricceiling_month - electricused_month}}          
#GAS          
      gas_ceiling_year:
        friendly_name: "What's GAS Ceiling for this year"
        value_template: >
          {% set _gastariefjaar = states('input_number.prijs_plaf_m3_year') |float %} 
          {{ _gastariefjaar }}
      gas_ceiling_month:
        friendly_name: "What's GAS Ceiling for actual month"
        value_template: >-
          {% if  now().month == 1  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_jan.state ,} %} {% endif %}
          {% if  now().month == 2  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_feb.state ,} %} {% endif %}
          {% if  now().month == 3  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_mar.state ,} %} {% endif %}
          {% if  now().month == 4  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_apr.state ,} %} {% endif %}
          {% if  now().month == 5  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_may.state ,} %} {% endif %}
          {% if  now().month == 6  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_jun.state ,} %} {% endif %}
          {% if  now().month == 7  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_jul.state ,} %} {% endif %}
          {% if  now().month == 8  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_aug.state ,} %} {% endif %}
          {% if  now().month == 9  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_sept.state ,} %} {% endif %}
          {% if  now().month == 10  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_oct.state ,} %} {% endif %}
          {% if  now().month == 11  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_nov.state ,} %} {% endif %}
          {% if  now().month == 12  %} {% set _gastarief = { "max": states.input_number.prijs_plaf_m3_dec.state ,} %} {% endif %}
          {{ _gastarief.max }}
      gas_tarif_month:
        friendly_name: "What's GAS Tarif for actual month"
        unit_of_measurement: 'EUR/m3'
        value_template: >
          {% if states('sensor.monthly_gas_netto') |float(0) < states('sensor.gas_ceiling_month')|float(0)  %}
          {% set _gas_tarif_month = states('input_number.plafond_prijs_gas') |float %} 
          {{ _gas_tarif_month }}
          {% else %}
          {% set _gas_tarif_month = states('input_number.gas_prijs_per_m3') |float %} 
          {{ _gas_tarif_month }}
          {% endif %}
      gas_plafond_left_year:
        friendly_name: "What's Left of My GAS Ceiling this year"
        unit_of_measurement: 'kWh'
        value_template: >
          {% set gasused = states('sensor.yearly_gas_netto')|float %}
          {% set gasceiling = states('sensor.gas_ceiling_year') |float %}
          {{ gasceiling - gasused}}
      gas_plafond_left_month:
        friendly_name: "What's Left of My GAS Ceiling this Month"
        unit_of_measurement: 'kWh'
        value_template: >
          {% set gasused_month = states('sensor.monthly_gas_netto')|float %}
          {% set gasceiling_month = states('sensor.gas_ceiling_month') |float %}
          {{ gasceiling_month - gasused_month}}

Dashboard yaml

  - theme: Backend-selected
    title: Prijsplafond
    path: Prijsplafond
    icon: mdi:chart-line
    badges: []
    cards:
      - type: horizontal-stack
        cards:
          - type: vertical-stack
            title: Prijsplafond :Electriciteit Verbruik
            cards:
              - type: custom:dual-gauge-card
                outer:
                  colors:
                    - color: var(--label-badge-green)
                      value: 60%
                    - color: var(--label-badge-yellow)
                      value: 80%
                    - color: var(--label-badge-red)
                      value: 90%
                  entity: sensor.monthly_energy_netto
                  label: Used
                max: 360
                min: 0
                inner:
                  colors:
                    - color: var(--label-badge-red)
                      value: 100%
                    - color: var(--label-badge-yellow)
                      value: 20
                    - color: var(--label-badge-blue)
                      value: 0
                  entity: sensor.electric_ceiling_month
                  label: Max
                title: Maand (kWh)
              - type: custom:dual-gauge-card
                outer:
                  colors:
                    - color: var(--label-badge-green)
                      value: 60%
                    - color: var(--label-badge-yellow)
                      value: 80%
                    - color: var(--label-badge-red)
                      value: 90%
                  entity: sensor.yearly_energy_netto
                  label: Used
                max: 360
                min: 0
                inner:
                  colors:
                    - color: var(--label-badge-red)
                      value: 100%
                    - color: var(--label-badge-yellow)
                      value: 20
                    - color: var(--label-badge-blue)
                      value: 0
                  entity: sensor.electric_ceiling_year
                  label: Max
                title: Jaar(kWh)
              - type: entities
                title: 'Prijsplafond tarieven Stroom '
                card_mod:
                  style: |
                    .card-header {
                      font-size: 18px;
                      padding: 2px 15px 2px 15px
                    }
                entities:
                  - type: section
                  - entity: sensor.electric_tarif_month
                    icon: mdi:currency-eur
                    name: Tarief Electriciteit
                    card_mod:
                      style: |
                        :host {
                          color: 
                          {% set tarief = states('sensor.electric_tarif_month') | float %}
                          {% if tarief <= 0.4 %}
                            green
                          {% else %}
                            red
                          {% endif %}
      - type: horizontal-stack
        cards:
          - type: vertical-stack
            title: Gas Verbruik
            cards:
              - type: custom:dual-gauge-card
                outer:
                  colors:
                    - color: var(--label-badge-green)
                      value: 60%
                    - color: var(--label-badge-yellow)
                      value: 80%
                    - color: var(--label-badge-red)
                      value: 90%
                  entity: sensor.monthly_gas_netto
                  label: Used
                max: 240
                min: 0
                inner:
                  colors:
                    - color: var(--label-badge-red)
                      value: 100%
                  entity: sensor.gas_ceiling_month
                  label: Max
                title: Maand (M3)
              - type: custom:dual-gauge-card
                outer:
                  colors:
                    - color: var(--label-badge-green)
                      value: 60%
                    - color: var(--label-badge-yellow)
                      value: 80%
                    - color: var(--label-badge-red)
                      value: 90%
                  entity: sensor.yearly_gas_netto
                  label: Used
                max: 1200
                min: 0
                inner:
                  colors:
                    - color: var(--label-badge-red)
                      value: 100&
                    - color: var(--label-badge-yellow)
                      value: 20
                    - color: var(--label-badge-blue)
                      value: 0
                  entity: sensor.gas_ceiling_year
                  label: Max
                title: Jaar (M3)
              - type: entities
                title: 'Prijsplafond tarieven GAS '
                card_mod:
                  style: |
                    .card-header {
                      font-size: 18px;
                      padding: 2px 15px 2px 15px
                    }
                entities:
                  - type: section
                  - entity: sensor.gas_tarif_month
                    icon: mdi:currency-eur
                    name: Tarief GAS
                    card_mod:
                      style: |
                        :host {
                          color: 
                          {% set tarief = states('sensor.gas_tarif_month') | float %}
                          {% if tarief <= 1.45 %}
                            green
                          {% else %}
                            red
                          {% endif %}

in elk geval dank voor het opweg helpen

Perhaps a bit of a dumb question. I was looking to do this exact thing. Only, I currently use HomeWizard plugged into my smart meter. It seems to only give me current use and overall use. Home Assistant’s Energy Dashboard seems to make sense of this all for days, months, etc. How do I create a monthly sensor or can I somehow use what the dashboard creates to do this?

Is it also possible to do this for gas? As that is the real killer at the moment of course when it comes to prices.

Alvast bedankt! :slight_smile:

Okay it was a dumb question. just found out about Utility Meter helpers :slight_smile:

1 Like

Can you explain a little bit? I have dsmrreader that pushes values to home assistant and a dsmr directly into home assistant.

but I misses the last_month option. But don’t know how I can made them and if the sensrors below are the correct ones:

helpers:  input.numbers.
set values in the developertools:
plafond_prijs_energie: 0,40
stroom_tarief_normaal: 1,45
prijs_plaf_m3_year:    1200
prijs_plaf_kwh_year:   2900

utility meter values
sensor.monthly_energy_delivered         > sensor.dsmr_current_month_electricity_returned_merged
sensor.monthly_energy_returned		> sensor.dsmr_current_month_electricity_returned_merged
sensor.last_month_energy		         > ?
sensor.last_month_energy_returned       >  ?
sensor.yearly_energy_delivered		> sensor.dsmr_current_year_electricity_merged
sensor.yearly_energy_returned		> sensor.dsmr_current_year_electricity_returned_merged

sensor.gasverbruik_deze_maand		> sensor.dsmr_current_month_gas
sensor.gasverbruik_dit_jaar		        > sensor.dsmr_current_year_gas

That looks amazing! Are you willing and or able to make a tutorial how to implement that?

  • wich files where?
  • Helpers etc.

Unfortunatly i know to little about HA to implement it from your example.

1 Like

Thanx, works great!

Edited the float values use 1 decimal in stead of 3. The layout is more clean now.

1 Like

I figured it out after I asked my question. At least I think I did. From my reader (Home Wizard) you get only total values:

  • Total power used low and high tariffs,
  • total power supplied back low and high tariffs
  • total gas use.
  • Current power use (think on the minute?) - Which will drop in the minus if you are supplying back at that time…

And through my solarpanels I also have what they are currently producing.

But I was missing things like how much electricity and gas is used on a daily, monthly or even year basis. As that total use is simply since Home Wizard has been registering I think.

So I was missing my start point for these great examples. Being able to know how much you use per month. But googling and searching here some more very quickly ran across that there is a ‘Utitity meter’ helper. And created those. I am not sure if the month one actually goes per month now, I think I miscreated that (that is it from the moment I created it).

Another thing I noticed for Home Wizard users. I used to have double tariff, but went to single. Home Wizard keeps sending both figures based on time (T1 and T2). So in my case I just created this to add both and use the same single tariff for both power types.

I’ve not gone into the last month part found in these examples yet. Also not really sure how to do this yet. Yesterday was mostly spend on getting the basics of day, month and year setup correctly and figuring out the tariffs of my provider (as they made it quite a bit of work to lookup and all, being on one hand to detailed and listed on different places). And contacting my provider if they perhaps have an API or something as tariffs can now change every month for everything above the ‘plafond’. I highly doubt that they will however.

Interesting sensor configuration. Shouldn’t they be updated to the new templates, in order to preserve their data (and not being purged after 10 days)?

I’m using daily ‘plafonds’ for electricity and gas. The daily info is to large for a template, so I created a python script ‘database’ with the daily plafond data in it.
The script is available as a service and updates every day (just after midnight) the plafond sensors I use in my dashboard.
If you are interested in daily plafonds you can read more and download the script here.

2 Likes

Well I did my best to quickly get this sorted. Created all the sensors and added them to a stacked overview including a mini-graph to see the course of the consumption levels per month.
Painful to see how much kWh we’ve already consumed. Still waiting for the response of the solar panel company so we can mitigate this.

1 Like

Looks fantastic what you’ve made EDouna, can you share the yaml. code with use?

It’s made of two parts (inspired what I’ve seen above, but added my own touch to it). I hope you can read through the Dutch parts. :slight_smile:

  1. A generic input numbers yaml to contains the price ceiling per utility and month;
  2. Price ceiling yaml that uses utility meters I already had for my DSMR reader, creating sensors that now apply to the ceiling.
  3. Lastly, this is all being showcased on the dedicated dashboard. I use mini-graph from HACS to generate the charts.

1. Generic input numbers file

#PC stands for price ceiling
# Electricity
pc_kwh_year:
  min: 0
  max: 2900
  initial: 2900
pc_kwh_jan:
  min: 0
  max: 340
  initial: 340
pc_kwh_feb:
  min: 0
  max: 280
  initial: 280
pc_kwh_mar:
  min: 0
  max: 268
  initial: 268
pc_kwh_apr:
  min: 0
  max: 204
  initial: 204
pc_kwh_may:
  min: 0
  max: 181
  initial: 181
pc_kwh_jun:
  min: 0
  max: 159
  initial: 159
pc_kwh_jul:
  min: 0
  max: 161
  initial: 161
pc_kwh_aug:
  min: 0
  max: 176
  initial: 176
pc_kwh_sep:
  min: 0
  max: 199
  initial: 199
pc_kwh_oct:
  min: 0
  max: 267
  initial: 267
pc_kwh_nov:
  min: 0
  max: 306
  initial: 306
pc_kwh_dec:
  min: 0
  max: 356
  initial: 356
# Gas
pc_m3_year:
  min: 0
  max: 1200
  initial: 1200
pc_m3_jan:
  min: 0
  max: 221
  initial: 221
pc_m3_feb:
  min: 0
  max: 188
  initial: 188
pc_m3_mar:
  min: 0
  max: 159
  initial: 159
pc_m3_apr:
  min: 0
  max: 86
  initial: 86
pc_m3_may:
  min: 0
  max: 35
  initial: 35
pc_m3_jun:
  min: 0
  max: 19
  initial: 19
pc_m3_jul:
  min: 0
  max: 17
  initial: 17
pc_m3_aug:
  min: 0
  max: 17
  initial: 17
pc_m3_sep:
  min: 0
  max: 24
  initial: 24
pc_m3_oct:
  min: 0
  max: 81
  initial: 81
pc_m3_nov:
  min: 0
  max: 147
  initial: 147
pc_m3_dec:
  min: 0
  max: 206
  initial: 206

2. Template sensor (modern style)

- sensor:
    # Main meta settings
    - name: "Electriciteit (kWh) plafond per jaar"
      unique_id: a_pc_kwh_per_year
      state: >
        {{ states('input_number.pc_kwh_year') | float(0) }}
    - name: Gas (m³) plafond per jaar
      unique_id: a_pc_m3_per_year
      state: >
        {{ states('input_number.pc_m3_year') | float(0) }}
    # Current kWh for the month
    - name: Electriciteit (kWh) plafond huidige maand
      unique_id: kwh_ceiling_month
      state: >-
        {% if now().month == 1  %} {{ state_attr('input_number.pc_kwh_jan', 'max') }} {% endif %}
        {% if now().month == 2  %} {{ state_attr('input_number.pc_kwh_feb', 'max') }} {% endif %}
        {% if now().month == 3  %} {{ state_attr('input_number.pc_kwh_mar', 'max') }} {% endif %}
        {% if now().month == 4  %} {{ state_attr('input_number.pc_kwh_apr', 'max') }} {% endif %}
        {% if now().month == 5  %} {{ state_attr('input_number.pc_kwh_may', 'max') }} {% endif %}
        {% if now().month == 6  %} {{ state_attr('input_number.pc_kwh_jun', 'max') }} {% endif %}
        {% if now().month == 7  %} {{ state_attr('input_number.pc_kwh_jul', 'max') }} {% endif %}
        {% if now().month == 8  %} {{ state_attr('input_number.pc_kwh_aug', 'max') }} {% endif %}
        {% if now().month == 9  %} {{ state_attr('input_number.pc_kwh_sep', 'max') }} {% endif %}
        {% if now().month == 10  %} {{ state_attr('input_number.pc_kwh_oct', 'max') }} {% endif %}
        {% if now().month == 11  %} {{ state_attr('input_number.pc_kwh_nov', 'max') }} {% endif %}
        {% if now().month == 12  %} {{ state_attr('input_number.pc_kwh_dec', 'max') }} {% endif %}
    # Current m3 for the month
    - name: Gas (m)³ plafond huidige maand
      unique_id: m3_ceiling_month
      state: >-
        {% if now().month == 1  %} {{ state_attr('input_number.pc_m3_jan', 'max') }} {% endif %}
        {% if now().month == 2  %} {{ state_attr('input_number.pc_m3_feb', 'max') }} {% endif %}
        {% if now().month == 3  %} {{ state_attr('input_number.pc_m3_mar', 'max') }} {% endif %}
        {% if now().month == 4  %} {{ state_attr('input_number.pc_m3_apr', 'max') }} {% endif %}
        {% if now().month == 5  %} {{ state_attr('input_number.pc_m3_may', 'max') }} {% endif %}
        {% if now().month == 6  %} {{ state_attr('input_number.pc_m3_jun', 'max') }} {% endif %}
        {% if now().month == 7  %} {{ state_attr('input_number.pc_m3_jul', 'max') }} {% endif %}
        {% if now().month == 8  %} {{ state_attr('input_number.pc_m3_aug', 'max') }} {% endif %}
        {% if now().month == 9  %} {{ state_attr('input_number.pc_m3_sep', 'max') }} {% endif %}
        {% if now().month == 10  %} {{ state_attr('input_number.pc_m3_oct', 'max') }} {% endif %}
        {% if now().month == 11  %} {{ state_attr('input_number.pc_m3_nov', 'max') }} {% endif %}
        {% if now().month == 12  %} {{ state_attr('input_number.pc_m3_dec', 'max') }} {% endif %}
    # Calculate the consumptions
    - name: Resterend electriciteit (kWh) plafond huidige maand
      unique_id: kwh_ceiling_month_left
      state_class: measurement
      state: >
        {{ states('sensor.electriciteit_kwh_plafond_huidige_maand') | float(0) - (states('sensor.energy_usage_peak_monthly') | float(0) + states('sensor.energy_usage_offpeak_monthly') | float(0)) | round(2, default=0) }}
    - name: Resterend electriciteit (kWh) plafond huidige maand percentage
      unique_id: kwh_ceiling_month_left_percentage
      state_class: measurement
      state: >
        {{ ((states('sensor.resterend_electriciteit_kwh_plafond_huidige_maand') |float(0) / states('sensor.electriciteit_kwh_plafond_huidige_maand') | float(0)) * 100 ) | round(2) }}
    - name: Resterend electriciteit (kWh) plafond jaar
      unique_id: kwh_ceiling_year_left
      state_class: measurement
      state: >
        {{ states('sensor.electriciteit_kwh_per_jaar') | float(0) - (states('sensor.energy_usage_peak_yearly') | float(0) + states('sensor.energy_usage_offpeak_yearly') | float(0)) | round(2, default=0) }}
    - name: Resterend electriciteit (kWh) plafond huidig jaar percentage
      unique_id: kwh_ceiling_year_left_percentage
      state_class: measurement
      state: >
        {{ ((states('sensor.resterend_electriciteit_kwh_plafond_jaar') | float(0) / states('sensor.electriciteit_kwh_per_jaar') | float(0)) * 100 ) | round(2) }}
    - name: Resterend gas (m³) plafond huidige maand
      unique_id: m3_ceiling_month_left
      state_class: measurement
      state: >
        {{ states('sensor.gas_m_3_plafond_huidige_maand') | float(0) - states('sensor.energy_usage_gas_monthly') | float(0) | round(2) }}
    - name: Resterend gas (m³) plafond huidige maand percentage
      unique_id: m3_ceiling_month_left_percentage
      state_class: measurement
      state: >
        {{ ((states('sensor.resterend_gas_m3_plafond_huidige_maand') | float(0) / states('sensor.gas_m_3_plafond_huidige_maand') | float(0)) * 100 ) | round(2) }}
    - name: Resterend gas (m³) plafond jaar
      unique_id: m3_ceiling_year_left
      state_class: measurement
      state: >
        {{ states('sensor.gas_m3_per_jaar') | float(0) - states('sensor.energy_usage_gas_yearly') | float(0) | round(2) }}
    - name: Resterend gas (m³) plafond huidig jaar percentage
      unique_id: m3_ceiling_year_left_percentage
      state_class: measurement
      state: >
        {{ ((states('sensor.resterend_gas_m3_plafond_jaar') |float(0) / states('sensor.gas_m3_per_jaar') | float(0)) * 100 ) | round(2) }}

3. Dashboard yaml

- theme: minimalist-desktop
    title: Energie
    path: energie
    badges: []
    cards:
      - type: vertical-stack
        title: Gas m3 prijsplafond
        cards:
          - type: horizontal-stack
            cards:
              - type: vertical-stack
                title: Maandelijks
                cards:
                  - type: custom:mushroom-entity-card
                    entity: sensor.resterend_gas_m3_plafond_huidige_maand_percentage
                    icon_type: none
                    name: Percentage
                    fill_container: false
                  - type: custom:mushroom-entity-card
                    entity: sensor.resterend_gas_m3_plafond_huidige_maand
                    icon: mdi:window-maximize
                    icon_color: red
                    icon_type: none
                    name: Resterend m³
                  - type: custom:mushroom-entity-card
                    entity: sensor.gas_m_3_plafond_huidige_maand
                    icon: mdi:window-maximize
                    icon_color: pink
                    fill_container: false
                    icon_type: none
                    name: Plafond
                  - type: custom:mushroom-entity-card
                    entity: sensor.energy_usage_gas_monthly
                    icon_type: none
                    name: Verbruik m3
              - type: vertical-stack
                title: Jaarlijks
                cards:
                  - type: custom:mushroom-entity-card
                    entity: sensor.resterend_gas_m3_plafond_huidig_jaar_percentage
                    icon_type: none
                    name: Percentage
                    fill_container: false
                  - type: custom:mushroom-entity-card
                    entity: sensor.resterend_gas_m3_plafond_jaar
                    icon: mdi:window-maximize
                    icon_color: red
                    icon_type: none
                    name: Resterend m³
                  - type: custom:mushroom-entity-card
                    entity: sensor.gas_m3_per_jaar
                    icon: mdi:window-maximize
                    icon_color: pink
                    fill_container: false
                    icon_type: none
                    name: Plafond
                  - type: custom:mushroom-entity-card
                    entity: sensor.energy_usage_gas_yearly
                    icon_type: none
                    name: Verbruik m3
          - type: custom:mini-graph-card
            entities:
              - entity: sensor.gas_m_3_plafond_huidige_maand
                aggregate_func: max
                name: Plafond
                color: red
              - entity: sensor.energy_usage_gas_monthly
                name: Verbruik
              - entity: sensor.resterend_gas_m3_plafond_huidige_maand
                name: Resterend
                color: green
            name: m3 huidige maand
            hours_to_show: 730
            group_by: date
            hour24: true
      - type: vertical-stack
        title: Electriciteit kWh prijsplafond
        cards:
          - type: horizontal-stack
            cards:
              - type: vertical-stack
                title: Maandelijks
                cards:
                  - type: custom:mushroom-entity-card
                    entity: >-
                      sensor.resterend_electriciteit_kwh_plafond_huidige_maand_percentage
                    icon_type: none
                    name: Percentage
                  - type: custom:mushroom-entity-card
                    entity: sensor.resterend_electriciteit_kwh_plafond_huidige_maand
                    icon: mdi:window-maximize
                    icon_color: red
                    icon_type: none
                    name: Resterend kWh
                  - type: custom:mushroom-entity-card
                    entity: sensor.electriciteit_kwh_plafond_huidige_maand
                    icon: mdi:window-maximize
                    icon_type: none
                    name: Plafond
                  - type: custom:mushroom-entity-card
                    entity: sensor.energy_usage_peak_monthly
                    icon_type: none
                    name: Normaal
                  - type: custom:mushroom-entity-card
                    entity: sensor.energy_usage_offpeak_monthly
                    icon_type: none
                    name: Dal
              - type: vertical-stack
                title: Jaarlijks
                cards:
                  - type: custom:mushroom-entity-card
                    entity: >-
                      sensor.resterend_electriciteit_kwh_plafond_huidig_jaar_percentage
                    icon_type: none
                    name: Percentage
                  - type: custom:mushroom-entity-card
                    entity: sensor.resterend_electriciteit_kwh_plafond_jaar
                    icon: mdi:window-maximize
                    icon_color: red
                    icon_type: none
                    name: Resterend kWh
                  - type: custom:mushroom-entity-card
                    entity: sensor.electriciteit_kwh_per_jaar
                    icon: mdi:window-maximize
                    icon_color: pink
                    icon_type: none
                    name: Plafond
                  - type: custom:mushroom-entity-card
                    entity: sensor.energy_usage_peak_yearly
                    icon_type: none
                    name: Normaal
                  - type: custom:mushroom-entity-card
                    entity: sensor.energy_usage_offpeak_yearly
                    icon_type: none
                    name: Dal
          - type: custom:mini-graph-card
            entities:
              - entity: sensor.electriciteit_kwh_plafond_huidige_maand
                aggregate_func: max
                name: Plafond
                color: red
              - entity: sensor.energy_usage_peak_monthly
                name: Normaal
              - entity: sensor.energy_usage_offpeak_monthly
                name: Dal
              - entity: sensor.resterend_electriciteit_kwh_plafond_huidige_maand
                name: Resterend
                color: green
            name: kWh huidige maand
            hours_to_show: 730
            group_by: date
            hour24: true

Later on I might add some trending functionality, like: with the average consumption of the month, will you top over the ceiling or stay right under (on yearly, quarterly basis as well), how much extra is being topped over and pre-calculate the total utility costs per month (including service costs, etc.).
I like to build it, yet I also wish to be able to check my utility company whereas this is a special circumstance with risks for errors.
I hope this can help some other users setting up their environment and be able to monitor their price ceiling. Enjoy!

1 Like