core icon indicating copy to clipboard operation
core copied to clipboard

Incorrect last_valid_state for utility meter

Open szczukot opened this issue 3 months ago • 8 comments

The problem

I created utility meter for energy consumption (reset once a year) and this sensor have incorrect value for last_valid_state Bigger than the state has ever had. I have a few utility metters (increased), and all have bigger value that actual state.

Image

What version of Home Assistant Core has the issue?

core-2025.9.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

utility_meter

Link to integration documentation on our website

https://www.home-assistant.io/integrations/utility_meter/

Diagnostics information

No response

Example YAML snippet

utility_meter:
  returned_energy_year_enea:
    unique_id: energia_oddana_roczna_enea_utility_meter
    name: returned energy
    source: sensor.pro3em_dom_total_active_returned_energy
    cron: "59 23 31 7 *"

Anything in the logs that might be useful for us?


Additional information

No response

szczukot avatar Sep 21 '25 18:09 szczukot

Hey there @dgomes, mind taking a look at this issue as it has been labeled with an integration (utility_meter) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of utility_meter can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign utility_meter Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


utility_meter documentation utility_meter source (message by IssueLinks)

home-assistant[bot] avatar Sep 21 '25 18:09 home-assistant[bot]

Or maybe this is not the last state of the utility meter but the last state of the input sensor?

szczukot avatar Sep 21 '25 18:09 szczukot

Or maybe this is not the last state of the utility meter but the last state of the input sensor?

precisely: https://github.com/home-assistant/core/blob/1e14fb6dab4cfde1a1605addff327f821f2d5cd9/homeassistant/components/utility_meter/sensor.py#L526C34-L526C47

This value is kept to recover utility meter normal functioning after a reboot of HA

dgomes avatar Sep 21 '25 20:09 dgomes

But is this the last state of the utility meter or source sensor?

szczukot avatar Sep 22 '25 06:09 szczukot

source sensor state - the purpose is to keep information from the source in the even the source misbehaves or is unavailable on HA restart

dgomes avatar Sep 22 '25 08:09 dgomes

Thanks for information

szczukot avatar Sep 22 '25 08:09 szczukot

Image Hi, appears that i have a related problem: The untility meter is making a jump when my source sensor value starts to go up from zero (? or unknown, unavailble).

nicolaimokros avatar Sep 23 '25 07:09 nicolaimokros

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.