Is it a bug in Energy Dashboard? It peaks almost daily

I have a Solax inverter wich I have integrated via API into Home Assistant. In the Energy Dashboard I use the ‘Yield Total’ entity. But sometimes, several days in a week, there is a large spike in the yield.

I have investigated a bit further and looked in the database. There is nothing strange to see in the raw datastream, nor are the values from my Solax inverter in error.

This is what I have investigated:


There is a drop visible in value around 8:52 AM and at 8:56 AM it restores to the normal value. Due to this, the Energy Dashboard is showing this:

When I get into the database I see nothing strange in the data (statistics table for id of the Yield Total device). The data from this day in my screenshots are:

id,created,start,mean,min,max,last_reset,state,sum,metadata_id
413969,2023-01-11 01:00:10.546225,2023-01-11 00:00:00,303.6,1123.89999999999,217
414028,2023-01-11 02:00:10.553339,2023-01-11 01:00:00,303.6,1123.89999999999,217
414087,2023-01-11 03:00:10.567614,2023-01-11 02:00:00,303.6,1123.89999999999,217
414146,2023-01-11 04:00:10.547915,2023-01-11 03:00:00,303.6,1123.89999999999,217
414205,2023-01-11 05:00:10.562661,2023-01-11 04:00:00,303.6,1123.89999999999,217
414264,2023-01-11 06:00:10.584949,2023-01-11 05:00:00,303.6,1123.89999999999,217
414323,2023-01-11 07:00:10.543737,2023-01-11 06:00:00,303.6,1123.89999999999,217
414382,2023-01-11 08:00:10.548912,2023-01-11 07:00:00,303.6,1427.49999999999,217
414441,2023-01-11 09:00:10.573077,2023-01-11 08:00:00,303.6,1427.49999999999,217
414500,2023-01-11 10:00:10.862617,2023-01-11 09:00:00,303.9,1427.7999999999897,217
414559,2023-01-11 11:00:10.549494,2023-01-11 10:00:00,305.0,1428.8999999999887,217
414618,2023-01-11 12:00:10.578808,2023-01-11 11:00:00,306.2,1430.0999999999885,217
414677,2023-01-11 13:00:10.585019,2023-01-11 12:00:00,307.7,1431.5999999999883,217
414736,2023-01-11 14:00:10.561141,2023-01-11 13:00:00,309.3,1433.199999999988,217
414795,2023-01-11 15:00:10.576158,2023-01-11 14:00:00,310.6,1434.4999999999877,217
414854,2023-01-11 16:00:10.585979,2023-01-11 15:00:00,310.9,1434.7999999999874,217
414913,2023-01-11 17:00:10.562824,2023-01-11 16:00:00,310.9,1434.7999999999874,217
414972,2023-01-11 18:00:10.560430,2023-01-11 17:00:00,310.9,1434.7999999999874,217
415031,2023-01-11 19:00:10.563663,2023-01-11 18:00:00,310.9,1434.7999999999874,217
415090,2023-01-11 20:00:10.586077,2023-01-11 19:00:00,310.9,1434.7999999999874,217
415149,2023-01-11 21:00:10.586752,2023-01-11 20:00:00,310.9,1434.7999999999874,217
415208,2023-01-11 22:00:10.604266,2023-01-11 21:00:00,310.9,1434.7999999999874,217
415267,2023-01-11 23:00:10.580512,2023-01-11 22:00:00,310.9,1434.7999999999874,217
415326,2023-01-12 00:00:10.581244,2023-01-11 23:00:00,310.9,1434.7999999999874,217

There is no value of ‘0’ in the raw data. So I can’t manualy alter the data to get it right.

Yes there is. As shown in your first screen shot, your total yield drops from 300 to 0 then back to 300 at just before 9am. This is what is causing the spike.

Can you share the configuration for this sensor?

Yes I have seen this, but this only occures in the sensor Yield Total. In the sensordata itself (Solax Yield Today, the third graph) and in the raw data in the database of sensor Yield Total there is no value “0”. I can’t explain where this drop of value is comming from.

Share your configuration for the sensor with the dip.

rest:
- resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=...&sn=...
  scan_interval: 120
  sensor:
  - name: "Solax"
    json_attributes_path: "$.result"
    json_attributes:
      - inverterSN
      - sn
      - acpower
      - yieldtoday
      - yieldtotal
      - feedinpower
      - feedinenergy
      - consumeenergy
      - feedinpowerM2
      - soc
      - peps1
      - peps2
      - peps3
      - inververterType
      - inverterStatus
      - uploadTime
      - batPower
      - powerdc1
      - powerdc2
      - powerdc3
      - powerdc4
    value_template: >
      {% if value_json.result.inverterStatus == '100' %}Wait
      {% elif value_json.result.inverterStatus == '101' %}Check
      {% elif value_json.result.inverterStatus == '102' %}Normal
      {% elif value_json.result.inverterStatus == '103' %}Fault
      {% elif value_json.result.inverterStatus == '104' %}Permanent Fault
      {% elif value_json.result.inverterStatus == '105' %}Update
      {% elif value_json.result.inverterStatus == '106' %}EPS Check
      {% elif value_json.result.inverterStatus == '107' %}EPS
      {% elif value_json.result.inverterStatus == '108' %}Self-test
      {% elif value_json.result.inverterStatus == '109' %}Idle
      {% elif value_json.result.inverterStatus == '110' %}Standby
      {% elif value_json.result.inverterStatus == '111' %}Pv Wake Up Bat
      {% elif value_json.result.inverterStatus == '112' %}Gen Check
      {% elif value_json.result.inverterStatus == '113' %}Gen Run
      {% else %}I dont know{% endif %}
  - name: "Solax DC power string1"
    value_template: "{{ value_json.result.powerdc1 }}"
    unit_of_measurement: "W"
    device_class: power
  - name: "Solax DC power string2"
    value_template: "{{ value_json.result.powerdc2 }}"
    unit_of_measurement: "W"
    device_class: power
  - name: "Solax Current Power"
    value_template: "{{ value_json.result.acpower }}"
    unit_of_measurement: "W"
    device_class: power
  - name: "Solax upload time"
    value_template: "{{ as_timestamp(value_json.result.uploadTime) | timestamp_local }}"
    device_class: timestamp
  - name: "Solax Yield Total"
    value_template: "{{ value_json.result.yieldtotal }}"
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
  - name: "Solax Yield Today"
    value_template: "{{ value_json.result.yieldtoday }}"
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total

First, it depends what sensor you are using for the energy dashboard.
If you are using the Yield Total, the drop to 0 and back to the previous value will cause the peak in the energy dashboard.

Since the sensor has a state_class of total_increasing, it should not drop to 0.

The energy dashboard will read the 0 as a valid value - adding it to the previous state.
When the sensor comes back to its previous value, the 300 will again added to the previous state - generating the peak.

So, you should check why the yield total value drops to zero - if it is because the sensor becomes “unavailable”, you should add the availability options to the sensors configuration.
That would prevent at least the zero values when the sensor cannot be reached.

Thanks for your reply, it makes sense. But when I configure the availability_template I receive a message that this is an invalid option for [rest]. I think you are on the right track though, is there another way to prevent 0-values?

Unfortunately an availability option is not available for the rest sensor. You can vote here if you think it would be a good addition: Availability template in RESTful Sensor

As a work-around, you can implement an availability template by including tests in your value template.

e.g.

  - name: "Solax Yield Total"
    value_template: >
      {% set yield = value_json.result.yieldtotal %}
      {% if yield == 0 %}
        unavailable
      {% else %}
        {{ yield }}
      {% endif %}
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing

From the gaps in the graphs you posted it does seem that your sensor in often unavailable.

1 Like

Many thanks, I have added your solution to the code without error. Now I have to wait for a situation when the value is 0.

The gaps in data can be explained during reboots of the HA server after config changes on that specific day. Normally this is not the case.

Is there a way to get rid of the pike in the Energy dashboard by deleting errorous data from the db?

Yes, go to Developer Tools → Statistics. Find your yield entity. Click the ramp icon to the right. Navigate to the time the erroneous reading occurred. Either set it to 0 or set it to an average of the values either side.

1 Like

I didn’t know this feature, thank you. It works like a charme!

So I can delete faulty data from the dashboard, and hopefully the addition to the script will prevent future errors in the data.

I would say case closed :wink:

Give it a few days and see if it helps. Then if all is ok, pick the post that helped the most and mark it as the solution with the tick box in the menu below the post.