Energy, Gas and Water consumption overview

Get an insight into your energy and gas consumption with the option to change the tariff prices in the frontend instead of backend.

I switch to a different energy company every year and do not want to change the tariff prices for each entity in the backend every time. In this project the Dutch Smart Meters DSMR is used

It calculates prices in each entity (i have)

  • Today
  • Yesterday
  • Last week
  • This week so fa
  • Last month
  • This month so far
  • This year so far
  • Last year

In this example energy and gas consumption is used but of course it is possible with all Utility Meter

Mobile:
19-11-28-10-34-42%20(1)
Browser:

configuration.yaml

utility_meter:

###### DSMR METER READINGS ######
hourly_power_offpeak:
  source: sensor.power_consumption_low
  cycle: hourly
hourly_power_peak:
  source: sensor.power_consumption_normal
  cycle: hourly
hourly_gas:
  source: sensor.gas_consumption
  cycle: hourly

daily_power_offpeak:
  source: sensor.power_consumption_low
  cycle: daily
daily_power_peak:
  source: sensor.power_consumption_normal
  cycle: daily
daily_gas:
  source: sensor.gas_consumption
  cycle: daily

weekly_power_offpeak:
  source: sensor.power_consumption_low
  cycle: weekly
weekly_power_peak:
  source: sensor.power_consumption_normal
  cycle: weekly
weekly_gas:
  source: sensor.gas_consumption
  cycle: weekly

monthly_power_offpeak:
  source: sensor.power_consumption_low
  cycle: monthly
monthly_power_peak:
  source: sensor.power_consumption_normal
  cycle: monthly
monthly_gas:
  source: sensor.gas_consumption
  cycle: monthly

yearly_power_offpeak:
  source: sensor.power_consumption_low
  cycle: yearly
yearly_power_peak:
  source: sensor.power_consumption_normal
  cycle: yearly
yearly_gas:
  source: sensor.gas_consumption
  cycle: yearly

Check the current energy supplier contract for your prices and change the initial values. The entities in the scripts are in Dutch, sorry for that.

input_number:

# STROOM TARIEVEN
all_in_enkeltarief_stroom:
  name: All-in enkeltarief Stroom
  initial: 0.213
  min: 0.000
  max: 0.500
  mode: box
  step: 0.001
  unit_of_measurement: 'EUR per kWh'
vaste_leveringskosten_stroom:
  name: Vaste leveringskosten Stroom
  initial: 71.39 
  min: 0.00
  max: 100.00
  mode: box
  step: 0.01
  unit_of_measurement: 'EUR per jaar'
vermindering_energiebelasting_stroom:
  name: Vermindering Energiebelasting Stroom
  initial: -311.62
  min: -400.00
  max: 0.00
  mode: box
  step: 0.01
  unit_of_measurement: 'EUR per jaar'
netbeheerkosten_stroom:
  name: Netbeheerkosten Stroom
  initial: 252.40
  min: 0.00
  max: 400.00
  mode: box
  step: 0.01
  unit_of_measurement: 'EUR per jaar'
# GAS TARIEVEN
all_in_enkeltarief_gas:
  name: All-in enkeltarief Gas
  initial: 0.725 
  min: 0.000
  max: 0.999
  mode: box
  step: 0.001
  unit_of_measurement: 'EUR per m3'
vaste_leveringskosten_gas:
  name: Vaste leveringskosten Gas
  initial: 71.39
  min: 0.00
  max: 100.00
  mode: box
  step: 0.01
  unit_of_measurement: 'EUR per jaar'
netbeheerkosten_gas:
  name: Netbeheerkosten Gas
  initial: 191.19
  min: 0.00
  max: 300.00 
  mode: box
  step: 0.01
  unit_of_measurement: 'EUR per jaar'

sensor:

# SLIMME METER #
- platform: dsmr
  port: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AK3EMMXY-if00-port0
  dsmr_version: 5

- platform: template
  sensors:

# DSMR METER READINGS #

    # CALCULATION TARIF LOW + NORMAL
    hourly_power:
      friendly_name: Hourly Power
      unit_of_measurement: kWh
      value_template: "{{ states('sensor.hourly_power_offpeak')|float + states('sensor.hourly_power_peak')|float }}"
    daily_power:
      friendly_name: Daily Power
      unit_of_measurement: kWh
      value_template: "{{ states('sensor.daily_power_offpeak')|float + states('sensor.daily_power_peak')|float }}"
    weekly_power:
      friendly_name: Weekly Power
      unit_of_measurement: kWh
      value_template: "{{ states('sensor.weekly_power_offpeak')|float + states('sensor.weekly_power_peak')|float }}"
    monthly_power:
      friendly_name: Monthly Power
      unit_of_measurement: kWh
      value_template: "{{ states('sensor.monthly_power_offpeak')|float + states('sensor.monthly_power_peak')|float }}"
    yearly_power:
      friendly_name: Yearly Power
      unit_of_measurement: kWh
      value_template: "{{ states('sensor.yearly_power_offpeak')|float + states('sensor.yearly_power_peak')|float }}"
    # LAST PERIODS GAS
    yesterday_gas:
      friendly_name: Yesterday Gas
      unit_of_measurement: m3
      value_template: "{{ state_attr('sensor.daily_gas','last_period') }}"
    last_week_gas:
      friendly_name: last Week Gas
      unit_of_measurement: m3
      value_template: "{{ state_attr('sensor.weekly_gas','last_period') }}"
    last_month_gas:
      friendly_name: last Month Gas
      unit_of_measurement: m3
      value_template: "{{ state_attr('sensor.monthly_gas','last_period') }}"
    last_year_gas:
      friendly_name: last Year Gas
      unit_of_measurement: m3
      value_template: "{{ state_attr('sensor.yearly_gas','last_period') }}"
    # LAST PERIODS POWER
    yesterday_power:
      friendly_name: Yesterday Power
      unit_of_measurement: kWh
      value_template: "{{ state_attr('sensor.daily_power_offpeak','last_period')|float + state_attr('sensor.daily_power_peak','last_period')|float }}"
    last_week_power:
      friendly_name: Last Week Power
      unit_of_measurement: kWh
      value_template: "{{ state_attr('sensor.weekly_power_offpeak','last_period')|float + state_attr('sensor.weekly_power_peak','last_period')|float }}"
    last_month_power:
      friendly_name: Last Month Power
      unit_of_measurement: kWh
      value_template: "{{ state_attr('sensor.monthly_power_offpeak','last_period')|float + state_attr('sensor.monthly_power_peak','last_period')|float }}"
    last_year_power:
      friendly_name: Last Year Power
      unit_of_measurement: kWh
      value_template: "{{ state_attr('sensor.yearly_power_offpeak','last_period')|float + state_attr('sensor.yearly_power_peak','last_period')|float }}"

    # SHORT POWER
    daily_power_short:
      value_template: "{{ '%.3f'%(states('sensor.daily_power') | float) | float }}"
      unit_of_measurement: 'kWh'

    yesterday_power_short:
      value_template: "{{ '%.3f'%(states('sensor.yesterday_power') | float) | float }}"
      unit_of_measurement: 'kWh'

    weekly_power_short:
      value_template: "{{ '%.3f'%(states('sensor.weekly_power') | float) | float }}"
      unit_of_measurement: 'kWh'

    last_week_power_short:
      value_template: "{{ '%.3f'%(states('sensor.last_week_power') | float) | float }}"
      unit_of_measurement: 'kWh'
    
    monthly_power_short:
      value_template: "{{ '%.3f'%(states('sensor.monthly_power') | float) | float }}"
      unit_of_measurement: 'kWh'

    last_month_power_short:
      value_template: "{{ '%.3f'%(states('sensor.last_month_power') | float) | float }}"
      unit_of_measurement: 'kWh'

    yearly_power_short:
      value_template: "{{ '%.3f'%(states('sensor.yearly_power') | float) | float }}"
      unit_of_measurement: 'kWh'

    last_year_power_short:
      value_template: "{{ '%.3f'%(states('sensor.last_year_power') | float) | float }}"
      unit_of_measurement: 'kWh'

    # CACULATIONS
    power_kwh_to_watt:
      friendly_name: 'Actueel Watt'
      unit_of_measurement: 'Watt'
      value_template: "{{ (states.sensor.power_consumption.state | float * 1000) | round(0) }}"
    #Gemiddeld
    average_gas_day:
      unit_of_measurement: 'm3'
      value_template: >-
        {% set a = states('sensor.last_month_gas') | float %}
        {{ (a / 30.41) | round(3) }}
    #Gemiddeld
    average_power_day:
      unit_of_measurement: 'kWh'
      value_template: >-
        {% set a = states('sensor.last_month_power') | float %}
        {{ (a / 30.41) | round(3) }}

  # INNOVA ENERGIE
     # PRICES GAS
    today_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.daily_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 365 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 365 %}
        {{ (((a * b) + c) + d) | round(2) }}

    yesterday_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.yesterday_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 365 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 365 %}
        {{ (((a * b) + c) + d) | round(2) }}

    week_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.weekly_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 52 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 52 %}
        {{ (((a * b) + c) + d) | round(2) }}

    last_week_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_week_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 52 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 52 %}
        {{ (((a * b) + c) + d) | round(2) }}

    month_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.monthly_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 12 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 12 %}
        {{ (((a * b) + c) + d) | round(2) }}

    last_month_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_month_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 12 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 12 %}
        {{ (((a * b) + c) + d) | round(2) }}

    year_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.yearly_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float %}
        {{ (((a * b) + c) + d) | round(2) }}

    last_year_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_year_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float %}
        {{ (((a * b) + c) + d) | round(2) }}
        

     # PRICES POWER
    today_power_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.daily_power') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 365 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 365 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    yesterday_power_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.yesterday_power') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 365 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 365 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    week_power_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.weekly_power') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 52 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 52 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 52 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    last_week_power_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_week_power') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 52 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 52 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 52 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    month_power_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.monthly_power') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 12 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 12 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 12 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    last_month_power_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_month_power') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 12 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 12 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 12 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    year_power_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.yearly_power') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}
      
    last_year_power_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_year_power') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

ui-lovelace:

###### PAGE - STATISTICS ######
  - title: STATISTICS
    icon: mdi:chart-line
    panel: false
    path: statistics
    badges: []
    cards:
          - type: horizontal-stack
            cards:
              - type: vertical-stack
                cards:
                   #LINKS ELEKTRA
                  - type: 'custom:vertical-stack-in-card'
                    title: Elektra
                    cards:
                      - type: custom:gauge-card
                        title: null
                        entity: sensor.power_kwh_to_watt
                        min: 0
                        max: 5000
                        scale: 37px
                        severity:
                          green: 0
                          yellow: 500
                          amber: 5000
                      - type: entities
                        title: null
                        show_header_toggle: false
                        entities:
                          - entity: sensor.average_power_day
                            name: Gemiddeld
                            icon: mdi:home-analytics   
                          - entity: sensor.daily_power_short
                            name: Vandaag
                            icon: 'mdi:flash'
                          - entity: sensor.today_power_price
                            name: Vandaag
                            icon: 'mdi:currency-eur'
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.yesterday_power_short
                        name: Gisteren
                        icon: 'mdi:flash'
                      - entity: sensor.yesterday_power_price
                        name: Gisteren
                        icon: 'mdi:currency-eur'   
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.weekly_power_short
                        name: Deze Week
                        icon: 'mdi:flash'
                      - entity: sensor.week_power_price
                        name: Deze Week
                        icon: 'mdi:currency-eur'  
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.last_week_power_short
                        name: Vorige Week
                        icon: 'mdi:flash'
                      - entity: sensor.last_week_power_price
                        name: Vorige Week
                        icon: 'mdi:currency-eur' 
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.monthly_power_short
                        name: Deze Maand
                        icon: 'mdi:flash'
                      - entity: sensor.month_power_price
                        name: Deze Maand
                        icon: 'mdi:currency-eur' 
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.last_month_power_short
                        name: Vorige Maand
                        icon: 'mdi:flash'
                      - entity: sensor.last_month_power_price
                        name: Vorige Maand
                        icon: 'mdi:currency-eur'    
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.yearly_power_short
                        name: Dit Jaar
                        icon: 'mdi:flash'
                      - entity: sensor.year_power_price
                        name: Dit Jaar
                        icon: 'mdi:currency-eur'
#                  - type: entities
#                    title: null
#                    show_header_toggle: false
#                    entities:
#                      - entity: sensor.last_year_power_short
#                        name: Vorig Jaar
#                        icon: 'mdi:power-plug'
#                      - entity: sensor.last_year_power_price
#                        name: Vorig Jaar
#                        icon: 'mdi:currency-eur'   

                #RECHTS GAS
              - type: vertical-stack
                cards:
                  - type: 'custom:vertical-stack-in-card'
                    title: Gas
                    cards:
                      - type: custom:mini-graph-card
                        entities:
                          - entity: sensor.hourly_gas_consumption
                        name: false
                        hour24: true
                        align_state: center
                        line_width: 2
                        font_size: 100
                        hours_to_show: 24
                        points_per_hour: 0.99
                        animate: true
                        show:
                          graph: bar
                          name: false
                          icon: false
                      - type: entities
                        title: null
                        show_header_toggle: false
                        entities:
                          - entity: sensor.average_gas_day
                            name: Gemiddeld
                            icon: mdi:home-analytics           
                          - entity: sensor.daily_gas
                            name: Vandaag
                            icon: 'mdi:fire'
                          - entity: sensor.today_gas_price
                            name: Vandaag
                            icon: 'mdi:currency-eur'
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.yesterday_gas
                        name: Gisteren
                        icon: 'mdi:fire'
                      - entity: sensor.yesterday_gas_price
                        name: Gisteren
                        icon: 'mdi:currency-eur'
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.weekly_gas
                        name: Deze Week
                        icon: 'mdi:fire'
                      - entity: sensor.week_gas_price
                        name: Deze Week
                        icon: 'mdi:currency-eur'
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.last_week_gas
                        name: Vorige Week
                        icon: 'mdi:fire'
                      - entity: sensor.last_week_gas_price
                        name: Vorige Week
                        icon: 'mdi:currency-eur'
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.monthly_gas
                        name: Deze Maand
                        icon: 'mdi:fire'
                      - entity: sensor.month_gas_price
                        name: Deze Maand
                        icon: 'mdi:currency-eur'
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.last_month_gas
                        name: Vorige Maand
                        icon: 'mdi:fire'
                      - entity: sensor.last_month_gas_price
                        name: Vorige Maand
                        icon: 'mdi:currency-eur'
                  - type: entities
                    title: null
                    show_header_toggle: false
                    entities:
                      - entity: sensor.yearly_gas
                        name: Dit Jaar
                        icon: 'mdi:fire'
                      - entity: sensor.year_gas_price
                        name: Dit Jaar
                        icon: 'mdi:currency-eur'
#                  - type: entities
#                    title: null
#                    show_header_toggle: false
#                    entities:
#                      - entity: sensor.last_year_gas
#                        name: Vorig Jaar
#                        icon: 'mdi:fire'
#                      - entity: sensor.last_year_gas_price
#                        name: Vorig Jaar
#                        icon: 'mdi:currency-eur'
          - type: horizontal-stack
            cards:
              - type: vertical-stack
                cards:
                # TARIEVEN
                  - type: entities
                    title: Tarieven
                    show_header_toggle: false
                    entities:
                      - entity: input_number.all_in_enkeltarief_stroom
                        name: Tarief per kWh
                        icon: 'mdi:flash'
                      - entity: input_number.netbeheerkosten_stroom
                        name: Vaste netbeheerkosten per jaar
                        icon: 'mdi:flash'
                      - entity: input_number.vaste_leveringskosten_stroom
                        name: Vaste leveringskosten per jaar
                        icon: 'mdi:flash'
                      - entity: input_number.vermindering_energiebelasting_stroom
                        name: Vermindering energiebelasting per jaar
                        icon: 'mdi:flash'

                      - entity: input_number.all_in_enkeltarief_gas
                        name: Tarief per m3
                        icon: 'mdi:fire'                       
                      - entity: input_number.vaste_leveringskosten_gas
                        name: Vaste leveringskosten per jaar
                        icon: 'mdi:fire' 
                      - entity: input_number.netbeheerkosten_gas
                        name: Netbeheerkosten per jaar
                        icon: 'mdi:fire'
22 Likes

Looks really impressive, but have one ā€œmaybe stupidā€ question.
How can I use this nice work with a double meter instead off a single meter. for now I use a avarage energy price but it would be nice if I can use the actual values from my provider UnitedConsumers 3 jaar wind mee.

Hope someone can help me a bit further.
Beneath the code Iā€™ve to modify for correct calculation, but I donā€™t know how :wink:
Iā€™ve added the two tariffs on the input_number but get stuck on the calculation part.

     # PRICES POWER
    today_power_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.daily_power') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 365 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 365 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}


@Alwin_Hummels have you looked here? there is an example how to use two tarifs peak and offpeak add these two together and that will be your daily consumption or/and price

Thanx Iā€™m a little bit further but how to automate it with weekend and holidays. thatā€™s when we have low tarif too here in the Netherlands. Low tariff from 23:00 till 07:00 on weekdays and on weekend and holidays also.

thanks for helping me

Looks nice only I try to integrate it in my HA only I get all error messages

Component error: yearly_power_offpeak - Integration ā€˜yearly_power_offpeakā€™ not found.

My DSMR cable is working fine and I can see the results on my lovelace UI.

What am I doing wrong?

the entity names has been changed. look here https://www.home-assistant.io/integrations/utility_meter/

power has changed to energy and low/normal is tarif_1 and tarif_2

Thank for the reply! I get is to work now very very nice for a beginner like me :slight_smile:

Only problem is that I get this error with the Gauge en Graph. Is the vertical-stack-in-card removed?

Error see below

Custom element doesnā€™t exist: vertical-stack-in-card.

type: ā€˜custom:vertical-stack-in-cardā€™
title: Elektra
cards:

  • type: ā€˜custom:gauge-cardā€™
    title: null
    entity: sensor.energy_kwh_to_watt
    min: 0
    max: 5000
    scale: 37px
    severity:
    green: 0
    yellow: 500
    amber: 5000

Hi Lenz-art,

I just stumbled upon this page as I was looking for getting a lot of (history) information out of my DSMR setup with nice Graphs.
I havenā€™t had the time to try this all out yet, but I think I know what your issue is. Some custom Graphs have been used here. You need to install them first, before you can use them. I found some information here. I hope this is what you are looking for.

1 Like

Hi @Alwin_Hummels, Did you mange to implement the 2 Tarif scenario ?

For those who are intrested. I have been using DSMR reader that is made by Dennis Siemensma. I have installed this parallel to home assistant in a separate VM. DSMR reader stores data read and visualizes. The data is forwarded in real time to Home Assistant via MQTT so that I can use this project and DSMR-Reader side by side.

1 Like

Care to share your setup? Keep running into difficulties with this. Much appreciated

Will do it when Iā€™m ready with my system. I just started over my config because it was a big mesh :wink:
Give me a week or maybe two and I post my config.
Please be paitient :upside_down_face:

1 Like

Thanks for this nice post!

1 Like

I use the workday sensor in an automation for switching between tarrifs

- platform: workday
  country: NL
  workdays: [mon, tue, wed, thu, fri]
  excludes: [sat, sun, holiday]
  add_holidays:
    - '2020-04-10' #Goede vrijdag
    - '2020-04-12' #Pasen
    - '2020-04-13' #Paasmaandag
    - '2020-04-27' #Koningsdag
    - '2020-05-05' #Bevrijdingsdag
    - '2020-05-21' #O.H. Hemelvaart
    - '2020-05-31' #Pinksteren
    - '2020-06-01' #Pinkstermaandag
    - '2020-12-25' #Kerstmis
    - '2020-12-26' #2de Kerstdag  
    - '2021-01-01' #Nieuwjaarsdag
    - '2021-04-02' #Goede vrijdag
    - '2021-04-04' #Pasen
    - '2021-04-05' #Paasmaandag
    - '2021-04-27' #Koningsdag
    - '2021-05-05' #Bevrijdingsdag
    - '2021-05-13' #O.H. Hemelvaart
    - '2021-05-23' #Pinksteren
    - '2021-06-24' #Pinkstermaandag
    - '2021-12-25' #Kerstmis
    - '2021-12-26' #2de Kerstdag  
    - '2022-01-01' #Nieuwjaarsdag
    - '2022-04-15' #Goede vrijdag
    - '2022-04-17' #Pasen
    - '2022-04-18' #Paasmaandag
    - '2022-04-27' #Koningsdag
    - '2022-05-05' #Bevrijdingsdag
    - '2022-05-26' #O.H. Hemelvaart
    - '2022-06-05' #Pinksteren
    - '2022-06-06' #Pinkstermaandag
    - '2022-12-25' #Kerstmis
    - '2022-12-26' #2de Kerstdag  
    - '2023-01-01' #Nieuwjaarsdag
    - '2023-04-07' #Goede vrijdag
    - '2023-04-09' #Pasen
    - '2023-04-10' #Paasmaandag
    - '2023-04-27' #Koningsdag
    - '2023-05-05' #Bevrijdingsdag
    - '2023-05-18' #O.H. Hemelvaart
    - '2023-05-28' #Pinksteren
    - '2023-05-29' #Pinkstermaandag
    - '2023-12-25' #Kerstmis
    - '2023-12-26' #2de Kerstdag  
    - '2024-01-01' #Nieuwjaarsdag
    - '2024-03-29' #Goede vrijdag
    - '2024-04-31' #Pasen
    - '2024-05-01' #Paasmaandag
    - '2024-04-27' #Koningsdag
    - '2024-05-05' #Bevrijdingsdag
    - '2024-05-09' #O.H. Hemelvaart
    - '2024-05-19' #Pinksteren
    - '2024-05-20' #Pinkstermaandag
    - '2024-12-25' #Kerstmis
    - '2024-12-26' #2de Kerstdag  
    - '2025-01-01' #Nieuwjaarsdag
    - '2025-04-18' #Goede vrijdag
    - '2025-04-21' #Pasen
    - '2025-04-21' #Paasmaandag
    - '2025-04-27' #Koningsdag
    - '2025-05-05' #Bevrijdingsdag
    - '2025-05-29' #O.H. Hemelvaart
    - '2025-06-08' #Pinksteren
    - '2025-06-09' #Pinkstermaandag
    - '2025-12-25' #Kerstmis
    - '2025-12-26' #2de Kerstdag  
1 Like

Dont get this. Your DSMR reader should switch automatically from low to high tarif and vice versa, when the low tarif is active de high tarif sensor stop counting. If you combine (peak + offpeak) in a template sensor you always have your total. The physical peak of peak aka high low tarif switch in your meter is managed by your provider. So no need to exclude weekends and holidays

1 Like

You are right thanks for your explanation

1 Like

exactly, difficulty I am facing is that there seems to be something wrong in calculations. Average is always zero and some numbers/ amounts are negative? any tips?

3 Likes

Please share your config so we can have a look. Btw nice layout!

Thanks Buddy :slight_smile:

groups:

meter_readings:
  name: Meter readings
  entities:
    - sensor.energy_consumption_tarif_1
    - sensor.energy_consumption_tarif_2
    - sensor.energy_production_tarif_1
    - sensor.energy_production_tarif_2
    - sensor.gas_consumption

utilitymeter:

utility_meter: ###### DSMR METER READINGS ######
  hourly_energy_offpeak:
    source: sensor.energy_consumption_tarif_1
    cycle: hourly
  hourly_energy_peak:
    source: sensor.energy_consumption_tarif_2
    cycle: hourly
  hourly_gas:
    source: sensor.gas_consumption
    cycle: hourly

  daily_energy_offpeak:
    source: sensor.energy_consumption_tarif_1
    cycle: daily
  daily_energy_peak:
    source: sensor.energy_consumption_tarif_2
    cycle: daily
  daily_gas:
    source: sensor.gas_consumption
    cycle: daily

  weekly_energy_offpeak:
    source: sensor.energy_consumption_tarif_1
    cycle: weekly
  weekly_energy_peak:
    source: sensor.energy_consumption_tarif_2
    cycle: weekly
  weekly_gas:
    source: sensor.gas_consumption
    cycle: weekly

  monthly_energy_offpeak:
    source: sensor.energy_consumption_tarif_1
    cycle: monthly
  monthly_energy_peak:
    source: sensor.energy_consumption_tarif_2
    cycle: monthly
  monthly_gas:
    source: sensor.gas_consumption
    cycle: monthly

  yearly_energy_offpeak:
    source: sensor.energy_consumption_tarif_1
    cycle: yearly
  yearly_energy_peak:
    source: sensor.energy_consumption_tarif_2
    cycle: yearly
  yearly_gas:
    source: sensor.gas_consumption
    cycle: yearly

sensor:

# SLIMME METER #
- platform: dsmr
  port: /dev/ttyUSB0
  dsmr_version: 4

- platform: template
  sensors:

# DSMR METER READINGS #

    # CALCULATION TARIF LOW + NORMAL
    hourly_energy:
      friendly_name: Hourly energy
      unit_of_measurement: kWh
      value_template: "{{ states('sensor.hourly_energy_offpeak')|float + states('sensor.hourly_energy_peak')|float }}"
    daily_energy:
      friendly_name: Daily energy
      unit_of_measurement: kWh
      value_template: "{{ states('sensor.daily_energy_offpeak')|float + states('sensor.daily_energy_peak')|float }}"
    weekly_energy:
      friendly_name: Weekly energy
      unit_of_measurement: kWh
      value_template: "{{ states('sensor.weekly_energy_offpeak')|float + states('sensor.weekly_energy_peak')|float }}"
    monthly_energy:
      friendly_name: Monthly energy
      unit_of_measurement: kWh
      value_template: "{{ states('sensor.monthly_energy_offpeak')|float + states('sensor.monthly_energy_peak')|float }}"
    yearly_energy:
      friendly_name: Yearly energy
      unit_of_measurement: kWh
      value_template: "{{ states('sensor.yearly_energy_offpeak')|float + states('sensor.yearly_energy_peak')|float }}"
    # LAST PERIODS GAS
    yesterday_gas:
      friendly_name: Yesterday Gas
      unit_of_measurement: m3
      value_template: "{{ state_attr('sensor.daily_gas','last_period') }}"
    last_week_gas:
      friendly_name: last Week Gas
      unit_of_measurement: m3
      value_template: "{{ state_attr('sensor.weekly_gas','last_period') }}"
    last_month_gas:
      friendly_name: last Month Gas
      unit_of_measurement: m3
      value_template: "{{ state_attr('sensor.monthly_gas','last_period') }}"
    last_year_gas:
      friendly_name: last Year Gas
      unit_of_measurement: m3
      value_template: "{{ state_attr('sensor.yearly_gas','last_period') }}"
    
# LAST PERIODS energy
    yesterday_energy:
      friendly_name: Yesterday energy
      unit_of_measurement: kWh
      value_template: "{{ state_attr('sensor.daily_energy_offpeak','last_period')|float + state_attr('sensor.daily_energy_peak','last_period')|float }}"
    last_week_energy:
      friendly_name: Last Week energy
      unit_of_measurement: kWh
      value_template: "{{ state_attr('sensor.weekly_energy_offpeak','last_period')|float + state_attr('sensor.weekly_energy_peak','last_period')|float }}"
    last_month_energy:
      friendly_name: Last Month energy
      unit_of_measurement: kWh
      value_template: "{{ state_attr('sensor.monthly_energy_offpeak','last_period')|float + state_attr('sensor.monthly_energy_peak','last_period')|float }}"
    last_year_energy:
      friendly_name: Last Year energy
      unit_of_measurement: kWh
      value_template: "{{ state_attr('sensor.yearly_energy_offpeak','last_period')|float + state_attr('sensor.yearly_energy_peak','last_period')|float }}"

    # SHORT energy
    daily_energy_short:
      value_template: "{{ '%.3f'%(states('sensor.daily_energy') | float) | float }}"
      unit_of_measurement: 'kWh'

    yesterday_energy_short:
      value_template: "{{ '%.3f'%(states('sensor.yesterday_energy') | float) | float }}"
      unit_of_measurement: 'kWh'

    weekly_energy_short:
      value_template: "{{ '%.3f'%(states('sensor.weekly_energy') | float) | float }}"
      unit_of_measurement: 'kWh'

    last_week_energy_short:
      value_template: "{{ '%.3f'%(states('sensor.last_week_energy') | float) | float }}"
      unit_of_measurement: 'kWh'
    
    monthly_energy_short:
      value_template: "{{ '%.3f'%(states('sensor.monthly_energy') | float) | float }}"
      unit_of_measurement: 'kWh'

    last_month_energy_short:
      value_template: "{{ '%.3f'%(states('sensor.last_month_energy') | float) | float }}"
      unit_of_measurement: 'kWh'

    yearly_energy_short:
      value_template: "{{ '%.3f'%(states('sensor.yearly_energy') | float) | float }}"
      unit_of_measurement: 'kWh'

    last_year_energy_short:
      value_template: "{{ '%.3f'%(states('sensor.last_year_energy') | float) | float }}"
      unit_of_measurement: 'kWh'

    # CACULATIONS
    energy_kwh_to_watt:
      friendly_name: 'Actueel Watt'
      unit_of_measurement: 'Watt'
      value_template: "{{ (states.sensor.power_consumption_phase_l1.state | float * 1000) | round(0) }}"
    #Gemiddeld
    average_gas_day:
      unit_of_measurement: 'm3'
      value_template: >-
        {% set a = states('sensor.last_month_gas') | float %}
        {{ (a / 30.41) | round(3) }}
    #Gemiddeld
    average_energy_day:
      unit_of_measurement: 'kWh'
      value_template: >-
        {% set a = states('sensor.last_month_energy') | float %}
        {{ (a / 30.41) | round(3) }}

  # INNOVA ENERGIE
     # PRICES GAS
    today_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.daily_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 365 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 365 %}
        {{ (((a * b) + c) + d) | round(2) }}

    yesterday_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.yesterday_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 365 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 365 %}
        {{ (((a * b) + c) + d) | round(2) }}

    week_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.weekly_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 52 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 52 %}
        {{ (((a * b) + c) + d) | round(2) }}

    last_week_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_week_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 52 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 52 %}
        {{ (((a * b) + c) + d) | round(2) }}

    month_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.monthly_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 12 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 12 %}
        {{ (((a * b) + c) + d) | round(2) }}

    last_month_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_month_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float / 12 %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float / 12 %}
        {{ (((a * b) + c) + d) | round(2) }}

    year_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.yearly_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float %}
        {{ (((a * b) + c) + d) | round(2) }}

    last_year_gas_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_year_gas') | float %}
        {% set b = states('input_number.all_in_enkeltarief_gas') | float %}
        {% set c = states('input_number.netbeheerkosten_gas') | float %}
        {% set d = states('input_number.vaste_leveringskosten_gas') | float %}
        {{ (((a * b) + c) + d) | round(2) }}
        

     # PRICES energy
    today_energy_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.daily_energy') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 365 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 365 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    yesterday_energy_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.yesterday_energy') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 365 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 365 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 365 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    week_energy_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.weekly_energy') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 52 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 52 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 52 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    last_week_energy_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_week_energy') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 52 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 52 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 52 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    month_energy_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.monthly_energy') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 12 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 12 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 12 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    last_month_energy_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_month_energy') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float / 12 %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float / 12 %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float / 12 %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

    year_energy_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.yearly_energy') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}
      
    last_year_energy_price:
      unit_of_measurement: 'EUR'
      value_template: >-
        {% set a = states('sensor.last_year_energy') | float %}
        {% set b = states('input_number.all_in_enkeltarief_stroom') | float %}
        {% set c = states('input_number.netbeheerkosten_stroom') | float %}
        {% set d = states('input_number.vaste_leveringskosten_stroom') | float %}
        {% set e = states('input_number.vermindering_energiebelasting_stroom') | float %}
        {{ ((((a * b) + c) + d) + e) | round(2) }}

lovelace:

entities:
  - entity: input_number.all_in_enkeltarief_stroom
    icon: 'mdi:flash'
    name: Tarief per kWh
  - entity: input_number.netbeheerkosten_stroom
    icon: 'mdi:flash'
    name: Vaste netbeheerkosten per jaar
  - entity: input_number.vaste_leveringskosten_stroom
    icon: 'mdi:flash'
    name: Vaste leveringskosten per jaar
  - entity: input_number.vermindering_energiebelasting_stroom
    icon: 'mdi:flash'
    name: Vermindering energiebelasting per jaar
  - entity: input_number.all_in_enkeltarief_gas
    icon: 'mdi:fire'
    name: Tarief per m3
  - entity: input_number.vaste_leveringskosten_gas
    icon: 'mdi:fire'
    name: Vaste leveringskosten per jaar
  - entity: input_number.netbeheerkosten_gas
    icon: 'mdi:fire'
    name: Netbeheerkosten per jaar
show_header_toggle: false
title: Tarieven
type: entities
1 Like

Have you set your input number somewhere? Cant find them in your configuration. You donā€™t have to use these but if you leave these then it is necessary to use fixed price values in your calculations.