Energy dashboard stopped working after upgrade to core-2022.2.0

Hi guys,

unfortunately the consumption display did not work for me anymore.
I currently use the following code:

  •   - name: "Energy Total"
        unique_id: energy_total
        state: >-
          {{ states('sensor.phase_1_energy')|float(0) + 
             states('sensor.phase_2_energy')|float(0) + 
             states('sensor.phase_3_energy')|float(0) }}`
        `unit_of_measurement: kWh
        device_class: energy
        state_class: total_increasing
        attributes:
          last_reset: "1970-01-01T00:00:00+00:00"
        availability: >
            {{ not 'unavailable' in 
               [ states('sensor.phase_1_energy'), 
                 states('sensor.phase_2_energy'),
                 states('sensor.phase_3_energy') ] }}`
      - name: "Power Total"
        unique_id: power_total
        state: >-
          {{ (states('sensor.phase_1_power')|float(0) + 
              states('sensor.phase_2_power')|float(0) + 
              states('sensor.phase_3_power')|float(0)) }}
        unit_of_measurement: W
        device_class: power
        state_class: total_increasing
        availability: >
            {{ not 'unavailable' in 
               [ states('sensor.phase_1_power'), 
                 states('sensor.phase_2_power'),
                 states('sensor.phase_3_power') ] }}
    
    

I had changed this accordingly the state_class as total_increasing, which now (almost) works again as before. The solar module is connected to L2 in the apartment. In case of excess power the Shelly 3M measures negative and I get the following log:

Logger: homeassistant.components.sensor.recorder
Source: components/sensor/recorder.py:331
Integration: Sensor (documentation, issues)
First occurred: 13:20:10 (1 occurrences)
Last logged: 13:20:10

Entity sensor.power_total from integration template has state class total_increasing, but its state is negative. Triggered by state -15.8 with last_updated set to 2022-02-07T12:19:09.517860+00:00. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A"integration%3A+template"

and

Logger: homeassistant.components.sensor.recorder
Source: components/sensor/recorder.py:311
Integration: Sensor (documentation, issues)
First occurred: 13:05:10 (1 occurrences)
Last logged: 13:05:10

Entity sensor.power_total from integration template has state class total_increasing, but its state is not strictly increasing. Triggered by state 131.0 (134.5) with last_updated set to 2022-02-07T12:00:17.129803+00:00. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A"integration%3A+template"

Possibly someone knows a solution?

Thanks in advance.

Power is a momentary reading so definitely shouldn’t be set to total_increasing. That is why you are getting those errors. Sensors representing momentary readings should be set to measurement

Also if you have 3 sensors representing energy you don’t have to create a sensor that adds them for the Energy integration. You can just add all 3 sensors to the integration and it will not only take care of adding them for you it will also give you more detailed bar graphs.

Thanks so far for your answer.
I set it back to measurement: Now I am waiting for enough sun to get into “negative measurement” :slight_smile: Germany isn´t the sunniest place actually.

I know, that I can use all three sensors for the energy integration, but the Solar Panel is connected to L2. Therefore that code above summarizes all 3 main cables in the appartement together - including the solar production. (I hope, I explained this correctly.)

I have the same setup (funny enough my inverter is also connected to phase 2) the graphs look like this when you go into negative:

Did you use the L2 return function from the Shelly 3M or do you use another one?
Honestly I just use a 390W Panel with a Hoymiles 350 Inverter on the Balkony. In my case it looks as follows (The current solar power is around 40Watts :smiley: )

I use Aeotec Home Energy Meter Gen5 (zwave device). It does not have dedicated “return” function if that is what you are asking.

My inverter is connected behind the meter so when the PV production is high my entire usage on 2nd phase goes into negative. That is why I don’t have anything configured as return to grid.

If I configure my Inverter as return to grid my calculation in the energy panel is incorrect. (the PV production is counted twice, once as return to grid and once again because it lowers my real usage).
Technically my setup is not optimal and I should change it but I have to run new cable for the inverter from my fuse box so it is connected between meter and the incoming city supply.

1 Like

I had the same problem. After changing my “Solar generation” to total_increasing it worked again, but showed huge negative numbers for today.
For now I restored the Backup I made this morning and continue to live with 2021.12 until theres a good solution.

I don’t think there will be a better solution. Using state_class: measurement was deprecated for a long time and will never be supported for accumulation sensors again.

That negative value is just for that day, when you upgraded that.
I wouldn´t worry about that. :wink:

In my case, the Shelly 3M device has a return function for every clamp. That means if a value gets negative, then this is going to be measured as return.
Anyway… The energy from the panel gets measure with a Shelly Plug S.
Until now…your solution works. Thanks so far for your help.

Yes. I restored the backup and while resoting I decided to update, change to “Total” and change my database at the same time to MAriaDB, because I wanted to do this since a long time.

any chance to change this negative input manually ?? now all reports for month and year will be wrong.


Hi, i seem to have bad readings on produced PV kwh from time to time, does anyone have a clue on what could be wrong?