Accounting for index units

Hello,
since @pierre-gilles is off during the end-of-year holidays, I’m creating this thread as a reminder.

After several tests, I confirm that the units of the features for the MQTT indexes are not taken into account in the energy monitoring calculation.
Even when I set Wh or kWh (knowing that my indexes are in Wh), the calculation result remains identical in both cases:
IMG_8777IMG_8776
From what I see with my other devices that report energy consumption in kWh, the results are correct.

I think the handling of units should be reviewed.

Indeed, I see the same thing with an MQTT device.

I also tried, to get the correct unit, setting « kWh » for energy and « MWh » for consumption, but that doesn’t work either.

I’ll go ahead and open a PR to add Wh as accessible in `switch.energy

1 Like

Pull requests made :

@mutmut, I’ve created a branch common to all the changes, including these, so you can test. You just need to update the same image, I built it with the same name: docker pull terdious/gladys:dev-energy-calculate

1 Like

It works perfectly for me on an HPJR index test: my meter readings are in Wh and I get good results for the consumption and cost calculations.
imageimage
And if I go back to 2025, I have some weird things for November:
image
January, February and December are OK for the days and the values (checked against my detailed actual consumption).

image
image
According to the logs, I had a counter reset and then 800 kWh arrived :thinking:
What caused this reset?
I didn’t stop or restart Gladys during the calculation for that period, only on 2025-03-28 for tests with the task logs.

1 Like

That’s indeed strange. And it’s a very round number, and the indication of a negative value/reset is at 12:00 (important as info?). Could you check by adding a curve next to this feature’s energy to compare? A three-month view should be telling in this case, but indeed it looks like a reset to 0 or at least a negative value…

The best would be a small DB query on the corresponding date (November 11) to see if it really matches? And how do we handle the values before that…

image
My index doesn’t move in November, which is normal since the first red Tempo day was 29/12/25.

I’ll look at the tutorial by @pierre-gilles to extract the data from the db for each of my Tempo indexes.

EDIT :
I just retrieved the values from 11/11/25 to check what happened and I have an erroneous value that was recorded (800 kWh too much) so the visual is correct :frowning:
image
Is there a way to change/delete this value?