Automations

How to Track Energy Use With the Home Assistant Utility Meter

Track daily, monthly and peak/off-peak energy use with the Home Assistant Utility Meter helper, covering reset cycles, tariffs and the Energy dashboard.

On this page
  1. What the input sensor must be
  2. Create the helper
  3. Reset cycles and offsets
  4. Peak and off-peak tariffs
  5. Net consumption and delta values
  6. Using it with the Energy dashboard
  7. Limits to expect
  8. Safety

The Utility Meter helper takes a running energy total, such as the kWh counter on a smart meter, and splits it into totals for each day, week, month or other period. It can also split usage between tariffs, such as peak and off-peak.

What the input sensor must be

The helper needs a sensor that only goes up over time: a cumulative energy reading in kWh or Wh.

It does not work directly with a power sensor that reports watts (W), because power rises and falls with whatever is running. To use a power sensor, first convert it to energy with the Integral helper, which uses a Riemann sum. Pick the method that matches the load:

  • left suits loads that switch fully on or off.
  • trapezoidal, the default, suits loads that change gradually.

If your meter gives you a cumulative reading, see how to connect a P1 meter for one common way to get it.

Create the helper

Go to Settings > Devices & services > Helpers, select Create helper, and choose Utility Meter. Pick your input sensor, name the meter, and choose a reset cycle and any tariffs. You can also write the helper in YAML.

Reset cycles and offsets

The reset cycle can be quarter-hourly, hourly, daily, weekly, monthly, bimonthly, quarterly or yearly. At each reset the meter starts a new total and keeps the previous period’s value as an attribute, so you can compare periods.

To line up resets with a billing date, use an offset. For example, an offset can move a monthly reset to the 15th. The YAML version also accepts a cron expression for a custom schedule.

Peak and off-peak tariffs

If you add tariffs such as peak and offpeak, the helper creates one sensor per tariff, plus a select entity that chooses the active tariff. Tariffs do not switch on their own. An automation has to change the select at the times your supplier changes the rate.

The select is named after your helper, so check its entity ID under Settings > Devices & services > Entities before you copy this example.

automation:
  - alias: "Switch to peak tariff on weekdays"
    triggers:
      - trigger: time
        at: "09:00:00"
    conditions:
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
    actions:
      - action: select.select_option
        target:
          entity_id: select.home_energy_daily
        data:
          option: peak

  - alias: "Switch to off-peak tariff in the evening"
    triggers:
      - trigger: time
        at: "22:00:00"
    actions:
      - action: select.select_option
        target:
          entity_id: select.home_energy_daily
        data:
          option: offpeak

The option names must match the tariff names exactly. The evening automation runs every day, so the weekend stays on off-peak. This pattern does not handle public holidays. For those, you need a separate condition, such as a calendar-based check.

Net consumption and delta values

Two settings cover less common sensors:

  • net_consumption: true lets the meter go down as well as up. Use it for a reading that can decrease, such as net import and export. It is not needed for a plain consumption counter.
  • delta_values: true is for a sensor that reports the amount used in each interval, rather than a running total.

By default, the meter also handles a source that resets to zero, through periodically_resetting.

Using it with the Energy dashboard

The Energy dashboard needs an energy sensor with device_class: energy and a state_class of total or total_increasing. The dashboard also builds its own hourly, daily and monthly totals from the source sensor, so a utility meter is optional there. It is most useful for fixed billing periods, tariff splits and your own dashboard cards.

Dashboard totals come from long-term statistics, so the latest figures can lag behind a live reading. To set it up, go to Settings > Dashboards > Energy.

Limits to expect

  • A utility meter does not backfill. It counts only from the moment you create it.
  • Readings can differ slightly from your utility bill, because of sensor accuracy, rounding and when your supplier resets its own counts.
  • Long-term statistics are kept by default. Raw history is kept for 10 days by default, which is set by the recorder’s purge_keep_days option.
  • utility_meter.calibrate sets the meter to a value you choose. utility_meter.reset starts a new period now. Use calibrate to line the meter up with a known reading.

Safety

Some energy monitors clip around cables inside the breaker panel. That is mains work. Have a qualified electrician fit them, and do not open a breaker panel yourself.

For the automation basics behind the tariff switch, see the automations and actions guide.

The complete guide to automations

Home Assistant Automations: Services, Actions and REST Commands
Read the guide

Keep exploring

Guides from other topics

All topics →