How to calculate the power consumption of all unmetered devices?

Is there a way to calculate the energy consumption of unmetered devices if I have the total energy consumption of the entire house and the energy consumption of several devices?

At the moment I have:

  • sensor.energy_home_total_kwh - electric meter measuring the consumption of the entire house (kWh, cumulative from the installation of the device)
  • sensor.energy_device1_daily_kwh - provided by the smart socket flashed using ESPHome (kWh, resets to 0 once a day)
  • sensor.energy_device2_daily_kwh - as above

I suppose I should use templates, but also create helpers earlier, but unfortunately I don’t know which ones and how to do it. I also don’t know whether it’s better to add templates in config/helpers (in UI) or in configuration.yaml.

Will the template created in this way automatically collect long-term statistics?

I need this to add “all remaining devices” to charts in the Energy dashboard and custom Apex Charts. At the moment, there is no way to natively visualize the consumption of other devices".


  - sensor:
      - name: "Unmetered Energy"
        device_class: energy
        state_class: total # enables long-term statistics
        state: >
          {{ states('sensor.energy_home_total_kwh')|float -
             states('sensor.energy_device1_daily_kwh')|float - 
             states('sensor.energy_device2_daily_kwh')|float }}
        availability: >
          {{ has_value('sensor.energy_home_total_kwh')|float and
             has_value('sensor.energy_device1_daily_kwh')|float and
             has_value('sensor.energy_device2_daily_kwh')|float }}

You have to use total rather than total_increasing for the state_class as the timing of sensor updates may cause the value to decrease momentarily.

FYI the custom Sankey Chart can do this automatically, but only if you wan that sort of display.

1 Like