Negative Values in Energy Dashboard since last update

Looks like a fix is scheduled for 2023.5.3

Commit: Don't try to restore unavailable nor unknown states (#92825) · home-assistant/core@23e24d7 · GitHub

Not sure if it will fix the historical data automatically or if that will need manual tinkering but it’s some good news at least!

2 Likes

I think not. IMHO you need a script to do that.

Great, it would be greater if they’d finally release it.

does anyone have a sql script to fix the wrong values?

Installed the new version yesterday. Had a reset today :frowning:

3 Likes

Hello, I Just installed last version and the utility helper sensor get reset after ha restart causing a negative value in the sensor.
I could immediately adjust it manually in the developer tools. I hope this will be fixed soon. :grin:

1 Like

@Prime69 - Thanks for the update. I’m still on 2023.4.5 and haven’t had any resets/lost data since rolling back.

Edit: I mention this only to reinforce there is definitely a continuing bug/issue with the 2023.5.x release, but perhaps we’re beyond that.

1 Like

Got resets about 12h after upgrading…

Logger: homeassistant.components.utility_meter.sensor
Source: components/utility_meter/sensor.py:456
Integration: Contor de utilități (documentation, issues)
First occurred: 15:56:02 (4 occurrences)
Last logged: 15:56:02

Energie Diverse Zilnica received an invalid state change coming from sensor.misc_kwh_rmn (unavailable > 0.00)
Energie Diverse Lunara received an invalid state change coming from sensor.misc_kwh_rmn (unavailable > 0.00)
Misc Zilnica Retea received an invalid state change coming from sensor.grid_power_used_by_misc_rmn (unavailable > 0.0000)
Misc Lunara Retea received an invalid state change coming from sensor.grid_power_used_by_misc_rmn (unavailable > 0.0000

this is how the source sensor for riemann calculations looks like:

template:
  - sensor:
      - name: "misc_power"
        unit_of_measurement: "W"
        icon: mdi:power-socket-eu
        device_class: power
        state_class: measurement
        state: >
          {% if not is_number(states('sensor.shellyem_98cdac1f3e9e_channel_2_power'))
                or not is_number(states('sensor.total_hvac_power')) %}
            None
          {% else %}
            {% set total_power = states('sensor.shellyem_98cdac1f3e9e_channel_2_power') | float %}
            {% set hvac_power = states('sensor.total_hvac_power') | float %}
            {{ (total_power - hvac_power) | round(1) }}
          {% endif %}

Not working again with the new version (upgraded directly)

@dgomes do you think open a new issue with logs or reopen one of the “old” issue.
Thanks :slight_smile:

please open a new one

1 Like

I am using a template sensor to obtain the POWER consumption which i then use to feed a Riemann helper. The code I use works perfectly in the HA DEVTools and it returns value or ZERO when no value available. As soon I deploy it and restart HA, the sensor returns Unavailable or Unknown. What is wrong in the code and any support to adjust? The idea is to have a Power sensor for the Riemann helper that never goes into a NO-NUMBER state.

    # Power
    - name: "TPL Shelly 3EM Grid net used Watt"
      unique_id: tpl_shelly_3em_grid_net_used_power
      state: >-
        {{ max(0, 
            (states('sensor.shelly_3em_l1_power')|float if states('sensor.shelly_3em_l1_power')|float is number else 0) + 
            (states('sensor.shelly_3em_l2_power')|float if states('sensor.shelly_3em_l2_power')|float is number else 0) +
            (states('sensor.shelly_3em_l3_power')|float if states('sensor.shelly_3em_l3_power')|float is number else 0)) | abs | round(2) }}
        availability: >-
        {{ [states('sensor.shelly_3em_l1_power'), states('sensor.shelly_3em_l2_power'), states('sensor.shelly_3em_l3_power')] | map('is_number') | max | default (0.0)}}
      unit_of_measurement: W
      state_class: measurement
      device_class: power

As far as I understand, the issue has been identified:

1 Like

Also I am facing this issue. The challenge is that quite often I cannot manually correct the values in developer tools as in there the values appear correct. Do I need to dive into the underlying MariaDB to correct the negative values or is there some other trick?


Having the same issue (no way to find the negative value anymore in the statistics…) since this morning with 2023.6.
I guess that the correction brought in the last release has made things worse :frowning: at least for me.
I was able at least to manually correct the values every morning before 2023.6

2 Likes

Same for me happened this morning with 2023.6 update. Hope there will be solution soon!

1 Like

Well it’s rather hard as all fixes so far during 2023.5 release didn’t help yet more and more people report this problem. Only solution for now is to get back to last working version - 2023.4.6

1 Like

@cpu and @ints and @mfmanca2000 you can help. Enable logging and share it and attach ist to the issue. Then maybe the developer can find a solution

I think it would make more sense to create a python script with the necessary SQL that corrects all erroneous records.

Any specific ideas to expert here?

I’m waiting one more day before shouting YES! but this morning I didn’t see any negative value for the first time since weeks.
Maybe what I’ve seen yesterday, the day after the update to 2023.6, was just the last wrong calculation…

But did you apply any fix? If not - sorry to let you down it’s a matter of time and it’s going to screw up again:-/