Again: Issues with Energy Dashboard calculations

Today I’ve faced an issue with the statistic calculation of the energy dashboard again.

The Dashboard is showing a total consumed power of 3,12 kWh between 10:00 and 11:00
But for sure - nothing was running that could have consumed so much energy at that time frame.
grafik

The total solar production was calculated with 5,4 kWh
grafik

Taking the sensor values, this seems totally wrong:
We have a total production (the whole day) of 9,649 kWh when I took the screenshots.
Our total consumption was 1,645 kWh for the day - and the self consumed solar power was 0,531 kWh

The only issue I could see is the last change for “Grid import” - which was last updated / changed 16 Minutes ago, while the others are more up to date…

Could it be, that the calculation of self-consumed energy will be wrong, if not all sensors are updated at the same time?

Else, I can’t explain why the total consumed energy in the graph could be way ahead to the value the sensor is showing…

Most likely some template you use does not have a default value or availability template.

hi, thanks for the reply.

Since the imported / exported sensors have been created manually (there was a topic here in the forum how this could be done) I am a bit unsure about this.

state: "{{(states('sensor.imported_power_yearly') | float(default=0)) / 1000}}"

This is the sensor I am using for getting the imported energy (yes, the sensor from the solaredge integration is called imported power - yet, it does provide the energy in Wh

I can add the “availability_template” - but would that prevent such a wrong calculation from happening again?

# Integrate Import and Export data to the Energy Dashboard.
# This is not possible by default, because the sensor is resetting every day - but the dashboard requires a continues increase.
  customize_glob:
    sensor.*_power_yearly_kwh:
      last_reset: '1970-01-01T00:00:00+00:00'
      device_class: energy
      state_class: measurement
    sensor.*_power_yearly:
      last_reset: '1970-01-01T00:00:00+00:00'
      device_class: energy
      state_class: measurement
      
utility_meter:
  imported_power_yearly:
    source: sensor.solaredge_imported_power
    cycle: yearly 
  exported_power_yearly:
    source: sensor.solaredge_exported_power
    cycle: yearly 

template:
  - sensor:
    - name: "Imported Power Yearly kWh"
      unique_id: imported_power_yearly_kwh
      state_class: measurement
      device_class: energy  
      unit_of_measurement: 'kWh'
      state: "{{(states('sensor.imported_power_yearly') | float(default=0)) / 1000}}"  
    - name: "Exported Power Yearly kWh"
      unique_id: exported_power_yearly_kwh
      state_class: measurement
      device_class: energy    
      unit_of_measurement: 'kWh'
      state: "{{(states('sensor.exported_power_yearly') | float(default=0)) / 1000}}"

As far as I understand, the self consumed power in the energy dashboard is a caluclated value based on the solar production and exported power - right?
On the other hand - I do have a sensor getting this data at least on a daily base from the SolarEdge API, just as it is for imported and exported energy…

| float(default=0) will return you to the blissful state of not knowing when your templates are not getting valid inputs, but a better option is described here:

1 Like

Thanks :slight_smile:
so the below template should be more correct - right?

template:
  - sensor:
    - name: "Imported Power Yearly kWh"
      unique_id: imported_power_yearly_kwh
      state_class: measurement
      device_class: energy  
      unit_of_measurement: 'kWh'
      state: "{{ states('sensor.imported_power_yearly') | float(none) / 1000 }}"

here’s a screenshot from the history graph of solaredge_exported_power (Wh) [top] and exported_power_yearly_kwh (kWh) [bottom]

As you can see, there’s a difference in the sensor values between 10:12 and 10:36 as well as a small difference between 10:48 and 11:00
also visible - but probably not on the screenshot: there are small gaps in the sensor on the bottom (exported Power Yearly kWh) … can this be caused by restarting HA and one of the sensors not yet initialized while the other is already available and its value has changed in that time?