home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.01k stars 31.05k forks source link

Energy Dashboard showing only 0 values since 2022.2.1 update #65773

Closed digitalkovik closed 2 years ago

digitalkovik commented 2 years ago

The problem

Energy Dashboard stopped reading values after 2022.2.1 update. Sensors are showing correct values in developer menu, they are correctly plugged in to Energy Dashboard, but in Energy Dashboard they show 0 values since the update was installed.

What version of Home Assistant Core has the issue?

2022.2.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Energy

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

ClassicGOD commented 2 years ago

Same here. I didn't even notice it at first since I have dedicated dashboard for solar production and everything is showing as expected. But when I went to the Energy panel to check current daily production vs estimated curve I found all zeroes in energy panel.

The PV production data is delivered to HA via MQTT and has sensors configured with MQTT platform. Usage data is delivered to HA via Hubitat integration where it's collected by 3 phase whole home energy monitor.

The only common part between all sensors showing 0 in energy panel is that they all have following customization:

  state_class: measurement
  last_reset: 1970-01-01 00:00:00+00:00

I forgot to mention - it definitely started with 2022.2.0 for me. I never updated to 2022.2.1 and went straight to 2022.2.2

ProTofik commented 2 years ago

Exactly the same thing happened to me yesterday after upgrading to 2022.2.1. My energy part of dashboard works but gas is dead.

https://imgur.com/a/ihBp1tr

3 Feb: Still running on old version, everything's fine 4 Feb: Upgraded to 2022.2.1 at around 11pm. Even though I still have some data from before 11pm, summary of the day shows as 0m3. 5 Feb: Today, 0m3 and no new data since the upgrade..

Data makes it into home assistant as I can see counters being increased in developer tools.

My gas sensor is hacked aqara door switch like in this thread: https://community.home-assistant.io/t/gas-meter-from-xiaomi-aqara-door-sensor-zigbee/348032/54

drthanwho commented 2 years ago
  state_class: measurement
  last_reset: 1970-01-01 00:00:00+00:00

Α state_class: measurement shouldn't even be working with energy in the first place.

ClassicGOD commented 2 years ago
  state_class: measurement
  last_reset: 1970-01-01 00:00:00+00:00

Α state_class: measurement shouldn't even be working with energy in the first place.

Well it was required (didn't work without it) when Energy panel was introduced and I had it there since then.

drthanwho commented 2 years ago

Indeed it was required at the very first release in August. But technically after it was changed it should have stopped working 😅

Energy sensors measuring (k)Wh should have a device_class: energy and a state_class of either total or total_increasing. Perhaps something to also look into and adjust https://developers.home-assistant.io/docs/core/entity/sensor?_highlight=total#entities-representing-a-total-amount

ClassicGOD commented 2 years ago

It kept working so I left it as is 🥲 but I remember asking on forums why my configuration with 'total_increasing' is not working while documentation says it should.

Well... I changed it to total_increasing and I started to see values in Energy panel. 😅

ProTofik commented 2 years ago

I measure my gas in m3. I guess after changing from measurement to total_increasing I just have to wait 2 hours for dashboard to update, correct?

ClassicGOD commented 2 years ago

I think the values update every hour, it can take 2 hours before you see any bar graphs. I think I just lucked out changing it right before an hour hit and got some small values like 0.01kWh in energy panel almost immediately.

drthanwho commented 2 years ago

Make sure when you use total_increasing that your sensor never falls to 0. If it does you will have issues. Otherwise use total

statistics get updated at 12 minutes past the hour each hour

ProTofik commented 2 years ago

Make sure when you use total_increasing that your sensor never falls to 0. If it does you will have issues. Otherwise use total

I'm using binary counter that I'm increasing though automation. That shouldn't flip to 0 I hope.

ClassicGOD commented 2 years ago

Make sure when you use total_increasing that your sensor never falls to 0. If it does you will have issues. Otherwise use total

statistics get updated at 12 minutes past the hour each hour

I know this is not place for this but what issues? Documentation states that it can fall to 0 (treated as new meter/period etc). Or do you mean falling to 0 as an error then going back to some value which would cause incorrect reading?

drthanwho commented 2 years ago

do you mean falling to 0 as an error then going back to some value which would cause incorrect reading?

Exactly that. A lot of people use total_increasing in template sensors they make without accounting for disconnects of the source sensor and also using a default of 0 when the sensor isn't available which leads to that issue of incorrect readings

ClassicGOD commented 2 years ago

Thanks for clarifying.

rosch99 commented 2 years ago

Same here with my HA core Installation and sensors from Fronius Integration. No Bars for from/to grid or PV, although from/to battery is displayed. It worked with 2021.12 and stopped right after the update to 2022.2.1. Updating to 2022.2.2 didnt help. The counters are increasing, so no Problem with the fronius Integration.

digitalkovik commented 2 years ago

device_class: energy state_class: total in configuration.yaml for each sensor did the trick. All is working again. I was running state_class: measurement, that obviously caused the troubble after the update.

lesleypersyn commented 2 years ago

All above make sense.

in my case, i was using:

  customize_glob:
    sensor.haenergy_*:
      last_reset: "2021-08-05T08:05:00+00:00"
      state_class: measurement

change to:

  customize_glob:
    sensor.haenergy_*:
      #last_reset: "2021-08-05T08:05:00+00:00"
      state_class: total_increasing

and all works fine again!

more info but not clear:

This state class used to be represented by state class measurement in combination with a last_reset value. This approach has been deprecated and will be interpreted as a total_increasing state class instead with an automatic last reset. https://developers.home-assistant.io/blog/2021/08/16/state_class_total/

lesleypersyn commented 2 years ago

Same here with my HA core Installation and sensors from Fronius Integration. No Bars for from/to grid or PV, although from/to battery is displayed. It worked with 2021.12 and stopped right after the update to 2022.2.1. Updating to 2022.2.2 didnt help. The counters are increasing, so no Problem with the fronius Integration.

Check the state attributes used for your energy entities in Developer Tools. state_class should be total_increasing and not measurement And check if last_reset is in the list. This shouldn't be present in the list!

rosch99 commented 2 years ago

@lesleypersyn your suggestions fixed the problem :-) Many Thanks for your quick help!

bcutter commented 2 years ago

This screwed up my total energy dashboard. Since updating to HA 2022.2.6 it showed nothing. I now changed state_class: measurement to state_class: total for the energy total and the costs total sensor and I think dashboard starts to recreate.

BUT: this is what I got after the first hourly statistics run:

grafik

This seems to be because of this gap:

id | created | metadata_id | start | mean | min | max | last_reset | state | sum
-- | -- | -- | -- | -- | -- | -- | -- | -- | --
973638 | 2022-02-15 21:00:12.950701 | 133 | 2022-02-15 20:00:00.000000 | 724.3186608655963 | 724.29 | 724.45 | 2021-06-04 00:00:00.000000 | 724.74 | 0.2899999999999636
973243 | 2022-02-15 20:00:13.573504 | 133 | 2022-02-15 19:00:00.000000 | 724.2393464075834 | 724.19 | 724.29 | NULL | NULL | NULL
972848 | 2022-02-15 19:00:13.305835 | 133 | 2022-02-15 18:00:00.000000 | 724.1379075357555 | 724.08 | 724.19 | NULL | NULL | NULL
.....
.....
.....
953956 | 2022-02-13 19:00:13.233516 | 133 | 2022-02-13 18:00:00.000000 | 714.4261287389972 | 714.37 | 714.51 | NULL | NULL | NULL
953575 | 2022-02-13 18:00:14.134961 | 133 | 2022-02-13 17:00:00.000000 | NULL | NULL | NULL | 2021-06-04 00:00:00.000000 | 714.37 | 574.1499999999604
953194 | 2022-02-13 17:00:12.886448 | 133 | 2022-02-13 16:00:00.000000 | NULL | NULL | NULL | 2021-06-04 00:00:00.000000 | 714.24 | 574.0199999999604

Looks like the sum value has been reset (to 0) once the state_class has changed to total (even a last_reset was set). Guess now I need to dig into the database to fix stuff... thinking of setting values for columns state and sum and hoping this will fix the graphes... --> Update 5 hours later: everything fixed in statistics and statistics_short_term.

Makes me feel a bit uncomfortable as I never read about "measurement" being deprecated. A warning in advance would have been nice. I'm just wondering as

Not sure how to avoid this in future. Maybe there was something implemented/fixed/changed without proper communication. Just a thought.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

wormiedk commented 2 years ago

I have a lot of entities in the statistics_meta table with id "null". It seems to have happened some time after the 2022.2 update with sensors added after that time. The sensor show "no issues" in developer tools but still do not populate statistics or energy dashboard image

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.