Insane values in energy dashboard solar production on template sensor

I recently got my solar panels installed, and of course the first thing to do is to hook the data up to home assistant.
I noticed that the total produced energy the inverter gives me is in an integer format, so the energy dashboard can only display production in whole number steps. Suboptimal.
There is another value on the inverter that measures the production today, which has two decimal precision. So with the magic of some templating, I manage to throw together a sensor that can combine these two to create a “total energy produced” with increased precision. Nice!
The template sensor works exactly as intended, so I decide to add it to the energy dashboard, and the dashboard goes bananas. It shows insane values. I have no clue as to what might be wrong.


The sensor displays correct values:

The template is configured like this:

template:
  - sensor:  
    - name: Solar Energy Total
      unique_id: solar_energy_total_precise
      device_class: energy
      state_class: total_increasing
      unit_of_measurement: kWh
      state: "{{ float(states('sensor.solar_inverter_energy_total'),0) + float(states('sensor.solar_energy_total_decimal'),0) }}"

And both parts of it look correct (there was apparently 0.01kWh of production in between the screenshots =) ):


Does anyone have an idea what could be causing this? Is there an issue in my config or is this some kind of bug in the energy dashboard?
Thanks for your help!

[Edit:]
The history looks like this:


But after checking it in more detail, I found some weird spikes there, which I corrected and now it seems to look ok.The root cause is still unknown, but at least I now know I’m not going crazy :D.
Thanks for the passive nudge in the right direction, and another lesson learned: Double check the history… Thanks a bunch! <3

Please post your sensor configuration as correctly formatted text.

Also showing the history graphs for the three sensors (template and 2x source) would help.

1 Like