Energy Management in Home Assistant

Thanks for posting. It was very helpful to get my aeotec meter power sensors working in the energy dashboard.

I see that the energy management dashboard is configured around the home’s electrical usage, is it possible to seperate out an energy dashboard for just heat?

I have a bunch of Kamstrup Multical Heat Meters that I am trying to integrate via Modbus -
I have meters for:
Heat input from Oil Boiler
Heat input from Biomass Boiler
Heat output to House
Heat output to Laundry Building
Heat output to Domestic Hot Water System

I would love one of the diagrams with the moving dots e.t.c. but probably think this should sit seperately from the electrical inputs and outputs for clarity.
Is it possible to duplicate the energy management features, but for heat?

I have created a new mqtt sensor for my EV charger and successfully added it to the energy dashboard as an individual device. Is there any way to add it to the Energy distribution widget (linked to the home energy consumption)?

If I understand correctly have a look here Energy Dashboard Add Electric Car consumption - #14 by bartland

Good morning, I’m seeing some strange behavior on a template sensor in the Energy Dashboard:

I checked at 9.55am:

  • The value of the sensor entity is 0,78m3. This is the correct value
  • Energy dashboard: Gas_49b shows usage of 0.2 m3 between 3-4am
  • Energy dashboard: Gas_49b shows usage of 0.2 m3 between 4-5am
  • Energy dashboard: Gas_49b shows usage of 0 m3 between 9-10am
  • Energy dashboard: Gas_49b total usage is 0.4 m3

I checked at 10.01am:

  • The value of the sensor entity is 0,78m3. This is the correct value.
  • Energy dashboard: Gas_49b shows usage of 0.4 m3 between 3-4am
  • Energy dashboard: Gas_49b shows usage of 0.4 m3 between 4-5am
  • Energy dashboard: Gas_49b shows usage of 1.6 m3 between 9-10am
  • Energy dashboard: Gas_49b total usage is 2.4 m3

Ie… all hourly values seemed to have doubled once the hour passed…??

Gas_49b is a calculated template sensor as follows:

sensor:
 - platform: template
   sensors:
    gas_49b:
     unit_of_measurement: m³
     value_template: >
       {{ (states('sensor.gas_49ab_daily')|float) - (states('sensor.huisbaasje_gas_today')|float) }}
     device_class: gas
     #availability_template: "{{ states('sensor.gas_49ab_daily') not in ['unavailable', 'unknown', 'none'] }}"

homeassistant:
 customize:
  sensor.gas_49ab_daily:
   device_class: gas
  sensor.gas_49b:
   device_class: gas
   state_class: total_increasing
   last_reset: '1970-01-01T00:00:00+00:00'

sensor.gas_49ab_daily is a utility meter (with a daily cycle),based on the sensor of my gas meter (via P1 port, homewizard) and shows the correct value. sensor.huisbaasje_gas_today is a sensor on a submeter which I would like to subtract from the total, and also the value of this sensor is correct.

If I assume you use the HomeWizard P1 meter; why do you try to calculate the daily usage for the energy dashboard? You just need ‘total’ and all should just work out.

I think that if you calculate some daily usage for a total_increasing sensor, stuff gets messed up.

I have a split house (A and B), with 1 gas/electricity meter. The top floor goes via a submeter (gas), the down floor does not has a separate gas-meter. To know the down floor, I have to subtract.

In other words:
A+B = Homewizard P1 sensor
A (top floor) = Huisbaasje sensor
B (down floor) = Homewizard - Huisbaasje

Try to subtract ‘total’ instead of ‘daily’. Maybe that will work?

Unfortunately doesnt work.

A+B = Homewizard P1 sensor = 13000 m3
A (top floor) = Huisbaasje sensor = measured on a daily basis
B (down floor) = Homewizard - Huisbaasje

What I don’t get, is why the sensor entity Gas_49B performs the subtraction correctly. It actually shows the right values there, however when I use that sensor in the Energy Dashboard, it goes haywire.

Note that the sensor entity reading stays correct when I view it in a different dashboard, just the Energy Dashboard comes up with nonsense…

Hi, I have the same problem (Core 2022.5.0). For some reason I am not aware of, it seems that my energy metering device returned implausible values. It does not only drop to zero, but it looks like there are missing values, as well:
[Edit: It is probably not the metering device but a global issue. Two energy metering devices dropped to zero at the same time. Possibly, I restarted HA at these times. This would make the issue even more dramatic. Did HA or ZHA (it is a Zigbee device) insert the zero values?]

I mean, actually, this is not a big deal since after a short while the device returned the correct values again.

However, what I don’t understand is: Why does the Energy Dashboard show this high consumption for the two time slots in which the energy time series dropped to zero?

If the dashboard would calculate “Energy(22:00) minus Energy(21:00)” as the consumed amount of energy between 21:00 and 22:00, then these annoying peaks wouldn’t appear, instead the correct value would be displayed.

So I wonder, what does HA calculate here? And why? At first glance, it looks like the differences (numpy.diff) of the series is computed and the negative values are removed from the diff, because they are assumed to be wrong. Then the consumption is the sum of all diff values. Am I right? However, making this assumption is disadvantageous here. Whenever there is some implausible value dropping below the actual value, this computation would be faulty. I see that the simple computation “Energy(22:00) minus Energy(21:00)” is also prone to outliers, but only if at least one of the border values is wrong. With the current implementation, it looks like one wrong value within the whole hour leads to wrong estimates.

Could the computation be made more stable in a future release, please? Missing and implausible values from sensor devices do occur quite often. It would be very nice if HA can deal with some common cases so that not all HA users need to hack it in manually.

Also, a very great feature would be to allow users to manually change historical sensor values directly in HA without setting up a DB and so one.

Yep, I can confirm that the HA restart invokes this issue. Today at ~8pm I restarted HA and the energy time series of my two devices dropped to zero for a short moment and then showed the correct values again. And the hourly statistics is wrong again :frowning:



I have had the same problem, the error occurs when restarting, it also happens when the internet connection is lost.
I have read somewhere that the following line solves it. Since I put it in sensors.yaml it has not happened to me again.
availability_template: “{{ states(‘sensor.analyzer_channel_1_energy’) not in [‘unknown’, ‘unavailable’, ‘none’] }}”

yes. This happens, when the sensor, provided from the integration does not have any availability template.
This template should define the state the sensor should have, when it is not ready or unavailable at all.

Without this template, the sensor would become “0” - which is a possible value for a statistics sensor - and therefore, the zero will be written into the statistics table.

To prevent this, you can change the sensor in your yaml file - or try to submit a ticket to the git repository of your integration- so that the developers can fix this behave for others as well.

Thank you. Yes, I forgot to mention that I defined a template sensor based on the device’s sensor. The problem was indeed that I converted a none value to zero by converting to float. Keeping the none values fixes the problem.

However, I still believe that the procedure for computing the hourly/daly/… statistics is systematically flawed. One outlier value should not destroy the whole statistic. Obviously, only positive energy differences are counted. If HA would also count the negative energy differences, the statistic would be okay.

yes, but negative values for a measuring sensor, like a solar panel or energy import shouldn’t get negative values per definition.
In that case, I can completely understand the design that has been choosen.

For example:
Due to an issue, one of my sensors was unavailable for two or three days (and I have switched to another integration to compensate this).

during that time, the sensor was “unavailable”… but the system was producing energy.
After the issue has been fixed, the sensor value was about 450 kWh higher than the last time when it has been written into the statistics.

Now, having the difference of 450 kWh on the sensor would show a high peak in the dashboard - of course, but that’s how it is - and it is clear why this happened.

what I haven’t faced:
That the complete sensor value has been added (again) to the statistic - only the difference, so there was already some improvement - but I don’t know if it was within the dashboard design, or within the integration

Hello.
I’ve been playing with the addition of WiFi and zigbee sockets to the power monitoring panel for a few days now. It’s acting weird.
Types and id extracted from iot.tuya.xxx
2x WiFi ZM-wi-Fi without problems are in the energy monitoring panel and without writing in customize.yaml
4x WiFi socket type after writing in customize.yaml:
LSP-16DL - product_id: j0zozzoarutv0nu1 - are without problems in the energy monitoring panel.
3x BSD01BPS - product_id: gyqisermskjxzycc - neither can be added to the power panel.

ZigBee sockets:
2x WGH-JLCZ02 - product_id “:” cphmq0q7 - one has been added to the energy monitoring panel and the other is not present …

Grafana nicely displays graphs of the above drawers …

common notation in customize.yaml for all is:

sensor. * sensor name * _total_increasing:
       name: xxxx
       device_class: energy
       unit_of_measurement: Wh
       unit_prefix: W
       unit: Wh
       last_reset: '1970-01-01T00: 00: 00 + 00: 00'
       state_class: total_increasing

What is the problem?
Thank you

The unit prefix is invalid.
Metric unit to prefix the integration result. Available units are k , M , G and T .

Also maybe you don’t need both unit_of_measure as well as unit+unit_prefix.

Sorry? Which newsletter? I Need it! Thanks!

It’s not clear to me how to setup the energy dashboard.

Currently I have configured the energy dashboard as follow:
a) GRID consumption: energy consumption from grid (kWh, increasing positive number, based on : sum of the energy consumption from all devices in home : does not take solar energy into account)
b) SOLAR PANELS: - solar panel production (kWh, increasing positive number, energy produced by the solar panels)

==> RESULT of this setup in Energy dashboard:
total consumption house = [energy consumption from grid + solar panel production] which I think is not correct.

Do I need to split the grid energy consumption so I have:

  • a new sensor with the solar energy that is returned to the grid (based on [grid consumption - solar energy] if more solar energy is produced than grid consumption, otherwise = 0)

Which sensor do I need to use for ‘grid consumption’? The one based on the energy sum of all devices?

Short answer is yes Setting up the NEW Home Energy Management Dashboard in Home Assistant - YouTube

Edit: These templates might also help but you will use your consumed-solar calculation in lieu of the single sensor Energy Management in Home Assistant - #1201 by petro