Components Home Assistant "Utility Meter"

3 minutes of reading
Proconductor: Home Assistant Community
Availability: included in thepersonale HUB Home Assistant
Category: software
Type: components Home Assistant
Implementation difficulties: low

The "Utility Meter" component di Home Assistant allows you to create entity that allow the user to monitor consumption from readings of other sensors, accounting for them on a daily, weekly, monthly and annual basis. Consumption "counters", so to speak.

In essence, this component generates additional sensors (virtual) they provide consumption totals over a given accounting period, allowing us to keep track of consumption trends over time.

At the end of the accounting cycle (regardless of the duration set) the value of the "Utility Meter" entity is reset and the total value of the terminated cycle is saved in the attribute "last_period", Allowing us to make any comparison, performance and forecast calculations, income statement (for example through the implementation of the platform"trend“).

Given that some proenergy service vider also provide tariffs for time slot, (eg the classical one two-hourly energy), the component allows you to customize the configuration in defining these bands, thus allowing us to account for consumption in an ap mode.propriato.

Nb As a sensor source "Utility Meter" It can be used any numeric sensor, as long as it provides constantly growing values. However, the metering device merely adds the positive difference between the second last reading received and the last one. For example, a sensor that provides a first value 0, then 10, then 11, upon receipt of this last value (11) will have a total accounting of 21 These are:

(20 - 0) + (11 - 10) = 21


Define entities using the component "Utility Meter" it's very simple. An example of configuration in configuration.yaml is the following:

#Esempi di configurazione
    source: sensor.energia_in_kwh

In the example above, "energy" is the name of the entity, which consequently will be called "sensor.energia". You can obviously create more entities, as many as you want, always under the block “utility_meter:"

Configuration details:

source(string, mandatory) the sensor entity to monitor (eg. "sensor.energia_in_kwh")
cycle(string, mandatory) defines the duration of the accounting cycle. Could be "daily","weekly","monthly","yearly"
offset(integer, optional) by default the cycles begin at the T0 provided by the cycle (00: 00 for the daily, 00: 00 of Monday for the weekly etc.). This parameter allows you to adjust a offset. Default: 0
tariffs(list, optional) list of possible tariffs. Default: []


The services connected to this component are three:

  • utility_meter.reset
  • utility_meter.next_tariff
  • utility_meter.select_tariff


Allows you to reset the meter.

entity_idNo.The entity to be zeroed.


It allows to pass to the following tariff (based on the list defined in the configuration). If the entity was set to the last rate, it positions itself on the first one.

entity_idNo.The entity to which to impose the accounting tariff change.


Allows you to select a specific tariff among those defined in the configuration.

entity_idNo.The entity to which to impose the accounting tariff change.
tariffNo.The tariff to set for the accounting.

Advanced configuration

In the following example we create two sensors "Utility Meter”To account for energy consumption daily and monthly, divided on two time slots: F1 and F2 (the typical bioraria one).

The monitored sensor is always the same, "sensor.energia_in_kwh"

    source: sensor.energia_in_kwh
    cycle: daily 
      - F1
      - F2
    source: sensor.energia_in_kwh
    cycle: monthly
      - F1
      - F2

This configuration does not generate two sensors (as the configuration would suggest), but six:

  • sensor.daily_energy
  • sensor.monthly_energy
  • sensor.daily_energy_F1
  • sensor.daily_energy_F2
  • sensor.monthly_energy_F1
  • sensor.monthly_energy_F2

The first two will count the totals for day and month; the rest will count each a specific cycle for specific bands.

Now imagine that the F1 band corresponds to the 9: 00 - 21: 00 and the F2 band from 21: 00 to 9: 00 the following day.
To automate the band passage, we use the following automation:

    - platform: time
      at: '09:00:00'
    - platform: time
      at: '21:00:00'
    - service: utility_meter.next_tariff
      entity_id: utility_meter.daily
    - service: utility_meter.next_tariff
      entity_id: utility_meter.monthly

This component can be particularly useful in scenarios like the linked one integration of energy readings su Home Assistant means Sonoff POW.

Home Assistant Official LogoATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Home Assistant, for any doubt, question, information on the specific merit of these components.

Please comment below