I already tried starting on an empty database several again but the behavior happens randomly on some days. I also have the same configuration on another HA with SqlLite and I haven’t seen this behavior. Also in my MariaDb configuration this used to work in the past and at some point it started with this behavior and I haven’t changed the database version either.
Also please don’t post pictures of config text. Post the actual text and format it correctly for the forum. That way we can copy and edit it to help you.
The Shelly 3 EM graph is correct, because it is a daily graph that shows power consumption at each hour, that same values should be shown in the daily energy dashboard if it were working correctly.
Updated the post with the template code instead of the picture
Energy per hour is not the correct sensor to feed the energy dashboard.
Yes that is what the energy dashboard displays in the daily chart, but it calculates this from being fed a total energy sensor. It can also display energy per day, week, or month depending on the view selected. All calculated from a total energy sensor, not an hourly one.
@tom_l I am not using an energy per hour sensor, I showed the Shelly 3EM daily graph just to tell what the dashboard should show on that same day but it doesn’t.
My sensor is based on the template I showed in my first post that as you can see is a total energy sensor anyway here I post the graph of it
also if you read my post I have that same configuration working on another HA installation (SqlLite based) for more than 1 year without any issue, so probably this is a bug that has something to do with the target database MariaDb (that for the record was working without issues for months also).
Now I cleaned everything and started from scratch against SqlLite on this installation.
No ist is because you have no availability template in your template sensors.
The 3 EM device became unavailable for whatever reason.
Your template substituted zero (from the float filter defaults). On return of the sensor the entire total was added to your energy dashboard, because it went from 0 → total.
If the sensor had gone total → unavailable → total everything would have been ok.
So in summary:
Total → 0 → total: add the entire total to the energy dashboard
Total → unavailable → total: continue counting from the previous total.
You can protect against your template returning zero when the source sensors are unavailable with an availability template.