Template sensor and utility meter - wrong calculation?

Hi there,

i do have a strange experience and would like to hear your opinion.
Perhaps i’m just blind on one eye :slight_smile:

I have an energy meter in my house which is giving an absolute reading of kWh.

  • i defined a template sensor, that is getting it’s absolute value every minute
  • i defined three utility meters (daily, monthly, yearly) to get these data (that’s my main goal)

The template sensor works fine and is giving me the correct value that i’m seeing at the hardware meter as well:

- name: "zähler_einspeisung_powerfox"
  unique_id: "zahler_einspeisung_powerfox"
  state: "{{ state_attr('sensor.powerfox_alle_werte', 'A_Minus') }}"
  unit_of_measurement: "kWh"
  device_class: "energy"
  state_class: "total_increasing"

The utility meters are (and also working):

utility_meter:
  haus_einspeisung_daily_kwh:
    source: sensor.zahler_einspeisung_powerfox
    cycle: daily
  haus_einspeisung_monthly_kwh:
    source: sensor.zahler_einspeisung_powerfox
    cycle: monthly
  haus_einspeisung_yearly_kwh:
    source: sensor.zahler_einspeisung_powerfox
    cycle: yearly

But, what happens is:

  • i take the reading from the template sensor at 00:00 (for instance 946,937)
  • then i take a reading at say 15:15 with a value of 952,228)
    → the difference is 5,291
    → the daily utility meter shows 5,242

The difference is even bigger (and still getting bigger) in the monthly and yearly meters.
As the real meter was installed two months ago, at least the value of my yearly utility meter should be exactly the same as the actual reading at the hardware meter, right? But it’s not. It’s off by somewhat 20 kWh and keeps getting bigger (as does daily and monthly).

This happens also in between reboots, so rebooting should not be the cause of any miscalculation.
The only thing that could happen is, that the api calls fail and deliver “unavailable” for a minute or two.
Am i missing something here?

Thanks!

PS: i did “calibrate the meter sensors” from time to time. Then they show the correct values, but as time goes by the values start to drift away again.

I have a similar issue. I’m reading a REST sensor (Tigo) giving me the total solar energy produced so far and feed this into a monthly utility meter sensor.
The utility meter sensor was working correctly for a long time, but now it shows about 1/10th of the correct value. I’m not yet exactly sure when it started happening (we had next to no sun in December and January), but it’s been a while now.
The original REST sensor is set to “total” and doesn’t show any weird behaviour like small decreases, but it is unavailable every now and then. It works correctly in the Energy dashboard.
I don’t have the time for a proper bug report right now, but it sure looks iffy, especially the fact it worked correctly before.