-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Wrong values when total increasing sensor unavailable #128
Comments
Same here, "day" view shows total energy from beginning to that day and not delta energy of that day only. My PV generator is also unavailable during night. In the native HA energy dashboard, it works correctly. |
Anything that can be done on the current project side? I've spent some time researching and it seems that no good solution exists, event defining template-sensor that preserves previous value doesn't work in all cases. |
@flixlix @udivankin I think I may have found a cause, but I don't really have time (or skills, at the moment, to even know how to setup a component in a way I can change the code) to test if there is a viable solution. But looking at src/energy/index.ts line 160, the comment there states
I think that if we check if the sensor is total_increasing, and if so, instead of a zero copy the first retrieved data point to the start, the statistics should get calculated correctly. So something like if (stat.length && new Date(stat[0].start) > startMinHour) {
if (stat.sensor_type == 'total_increasing') { // <-- add this if check
// Modified code to add a data point with correct statistics
stat.unshift({
...stat[0],
start: startMinHour.toISOString(),
end: startMinHour.toISOString(),
sum: stat[0].sum, // <-- use first available data point instead of 0
state: stat[0].state, // <-- use first available data point instead of 0
});
} else {
// The original code of line 161 - 169 to add a zero dat point
stat.unshift({
...stat[0],
start: startMinHour.toISOString(),
end: startMinHour.toISOString(),
sum: 0,
state: 0,
});
}
} I hope this helps you to fix this more quickly; or at the very least as a reminder for myself if I ever have time to try and code something myself. |
I can confirm this bug. Any success available? How can I define the helper as a workaround? |
same here :( |
Describe the bug
I have two PV inverters that report the total yield in their lifetime, but one goes offline when the voltage is too low. So at midnight, this sensor is always unavailable.
When I add this to the energy flow card, it assumes that the missing value is 0:
Expected behavior
When the value of a total increasing sensor is missing, use the last known value instead of zero.
Alternative solution
I could try to define a helper that will keep the last known value but that will only work from this moment onwards and for my several years of historical data.
Please make sure all of this applies and check the checkboxes, by writing "X" inside of them.
I understand that this is a channel for reporting bugs, not a support forum (If you need help configuring the card, go to: Discussions).
I have the latest version of the card installed.
I have cleared my browser cache after installing, updating and configuring the card.
The text was updated successfully, but these errors were encountered: