Energy dashboard stopped working after upgrade to core-2022.2.0

Hi to everyone, I would like to ask for somebody’s advice concerning an issue I’m having with the energy dashboard since the last upgrade to core-2022.2.0.

The values I feed are coming via MQTT from a PZEM (inflow) and from the inverter (SMA old model) which sends the instant solar production values via Bluetooth, received and translated in MQTT messages which are then sent to Homeassistant. The remaining values are extrapolated through algebraic formulas (templates) which may render correct values or not but the main thing is that I had it running, while since the upgrade it doesn’t show anything any more (There is no data to show/Grid neutrality could not be calculated etc) while the numeric value (the calculated ones) are still correctly shown on the main page. Is somebody else experiencing the same? Where can I look to find a solution? Thanks

The same happened to me. I am using solax inverter. I can see all sensors showing correct values in the developer menu, but the energy dashboard is showing 0 values even sensors are mapped correctly. This happened right after 2022.1 core update.

Hi, I found out there is an issue on github which may have something in common with our problem:

Same here. I have dedicated dashboard for my inverter that like OP pulls data from MQTT (we are probably using the same exact software - SBFspot) . I never noticed any change on my dashboard, all of the readouts are there, but since update Energy dashboard shows all 0.

I can confirm that too. Everything related to the recording and evaluation of the energy no longer worked. Some automations related to the energy were down. I have now downgraded to core-2021.12.10. Now everything works as expected again. Until this problem is fixed I will not upgrade again and I do not recommend it.

In short: Looks like the problem (at least in my case) was that I was still using state_class: measurement for my energy sensors. They should be state_class: total_increasing

Longer explanation: state_class: total_increasing didn’t work when Energy panel was first introduced so many of us used state_class: measurement but as of 2022.2.0 state_class: measurement does not work for sensors that measure accumulated values (like energy etc) and they should be set to total or total_increasing as per documentation: Sensor Entity | Home Assistant Developer Docs

You are most probably right, I tried yesterday that path but being by far not an expert gave up after seeing a strange pattern on the energy dashboard. I’ll give it another try for a longer period now. Thanks

Well I followed your advice and put “state_class: total” with no “last reset” and again I’m getting the strange pattern (behaviour) I was telling about, as you can see in the screenshot, all the figures are zero …

Same here. Energy dashboard based on sensors retrieved by MQTT platform. The sensors have the right values but the dashboard is empty since the upgrade. Important to notice that the cost is providing some values.

Got the same problem.
Single values are okay, but don’t appear in Energy dashboard since 2022 Version.

One of my sensors:
- name: “Netz-Bezug”
unit_of_measurement: “kWh”
state: >
{% set list = states.sensor.smartmeter.state.split(’,’) %}
{{ list[0] | float(default=0) }}
state_class: measurement
device_class: energy
last_reset: ‘1970-01-01T00:00:00+00:00’

measurement → total_increasing seems to Show data

As @ClassicGOD suggested try to follow the instructions on Sensor Entity | Home Assistant Developer Docs which indicate the correct use of state_class and last_reset, but as I mentioned earlier in doing this you will only get the bars showing in the Energy dashboard while the values will remain wrong (almost everything zero). At least that is what happended to me

Stats are updated every hour (12mins past every hour AFAIK), it can take up to 2 hours for them to show up. Have you waited at least this long?
I applied the changes yesterday and today my readouts on energy panel match my sensors exactly. (they also matched yesterday but due to late time I applied the change I was unable to verify the correct readouts for PV production)

what did you set for state_class? I used just “total” with no last reset attribute and yes I modified the settings yesterday and the figures were still wrong today

I have it set to total_increasing but i think I should probably be using total for some of my sensors.
Since Energy dashboard is not mission critical for me I will switch to total and test if it reports correctly.

I changed the state_class to total_increasing more than 12 hours ago and I cannot change last_reset as it is not supported by the MQTT sensor. After a few restarts the dashboard is still empty for values since the date and time of the upgrade. I’m pretty sure that 2022.2 introduced a bug on the energy dashboard. By the way, even if the cost are not in the charts, they are still calculated correctly on a daily basis.

The bug is definitely a possibility. There is an open GitHub issue about this here: there are people suggesting other solutions in there so I recommend taking a look.

When it comes to setting last_reset - I had it in my config but I removed it now as it probably is no longer required (like setting state_class: measurement it was a fix for early long time statistics implementation) but if you want to set it for sensor that does not directly support it in the configuration you can set it via customize.yaml like this:

  last_reset: ‘1970-01-01T00:00:00+00:00’

you have to have customize.yaml enabled in ‘configuration.yaml’:

  customize: !include customize.yaml

of course you can set it directly under customize: in the main config but splitting configuration is good for you :slight_smile:

Hello @ClassicGOD, I realized that I had some custom entries already. I have removed the device_class and state_class (as they are now in the main config) and I left the last_seen that was already there. I’ve restarted and the dashboard is still empty: I will wait for the canonical 2 hours to see if the problem was fixed. Thanks

How can I convert the following “integration” sensor to a total_increasing?

- platform: integration
    source: sensor.power_grid_consumption
    name: energy_grid_consumption
    method: left
    unit_time: h
    unit_prefix: k
    round: 2

These are the current attributes:

state_class: measurement
source: sensor.power_grid_consumption
unit_of_measurement: kWh
device_class: energy
icon: mdi:chart-histogram
friendly_name: energy_grid_consumption
last_reset: '1970-01-01T00:00:00+00:00'

Should I change the platform and use something else? The HA documentation suggests to use the Riemann sum integral, which is what I’ve done. Am I missing something?

1 Like

So 1 hour after changing the state_class to total_increasing in the main config, and keeping only the last_reset in the custom attributes, I have back my dashboard, but the first days of the month have been messed up with huge negative kwh consumption the day of the upgrade, the consumption of today is ok and I think that the problem is fixed. I’m not sure if the situation of the upgrade day can be restored to normal, but it is not that bad (and costs are still ok). Thanks @ClassicGOD

You can use customize.yaml to set it to total_increasing in the same way I outlined in one of my posts above.

@adizanni Happy I could help :slight_smile:

@backtrack I changed my sensors to total as promised. They still seem to operate and show in Energy panel as expected.

1 Like