home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
4.13k stars 2.81k forks source link

Statistics graph may show weird accuracy for recently added sensor (probably if a state has not changed since creation) #18982

Open ildar170975 opened 11 months ago

ildar170975 commented 11 months ago

Checklist

Describe the issue you are experiencing

There is a sensor with some history (hours_to_show: 1):

изображение

At ~09:15 for this sensor I added state_class: measurement. Then restarted HA, it started at 09:22.

Now it is ~10:21 (< 1 hour). Here is a statistics graph for this sensor with 5minute period:

изображение

Here is with hour period:

изображение

Upper & lower bounds look very weird. Guess it happened because there was < 1 hour since HA started. But even at ~10:30 the card looks the same.

Note: no accuracy settings were defined for this sensor:

изображение

Describe the behavior you expected

Accuracy should be not so weird)))

Steps to reproduce the issue

as above

What version of Home Assistant Core has the issue?

2023.12.0

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Chrome 119.0.6045.200

Which operating system are you using to run this browser?

Win10x64

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

ildar170975 commented 11 months ago

Now it is 20:11, >10 hours passed since the sensor was "assigned to LTS". Still it is shown as:

изображение

Not sure - but this could probably happen to any sensor which does not change it's value since a creation.

изображение

mbo18 commented 11 months ago

Same issue here. It is only on battery sensor from ZHA here

RobertoCravallo commented 10 months ago

Same here. It is mostly sensors with a "%" (I believe mostly ZHA sensors for me also) value. Yesterday I set the precision to "100,00" and after a while, all was good. Set them back to "100" last night and today the values are all screwy again...

It only happens in the pop-up overview. If I select to show "month", the strange effect is not shown, but the expected behavior.

IdAW – Home Assistant 2024-01-14 09-41-30

IdAW – Home Assistant 2024-01-14 09-41-45

Ernst79 commented 10 months ago

It's not only sensors with % as unit of measurement. I see the same with a xiaomi-ble temperature sensor with °C. It was just added, so temperature hasn't changed from 27.2° yet.

image

A similar issue was reported for the Passive BLE monitor integration (custom component), mostly for battery sensors that stay at 100%.

image

I first tried to fix it in the integration code itself, but whatever kind of rounding I applied in the code of the integration, it didn't change anything in the behavior. After that, I found this issue. So, I guess it is a frontend issue.

ildar170975 commented 10 months ago

It's not only sensors with % as unit of measurement.

Not related to a particular UoM, the 1st post was about a voltage.

github-actions[bot] commented 7 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

karwosts commented 7 months ago

I looked at this once but it seemed the rounding errors were coming from core, as the statistics datapoints returned to the frontend I would see something like: {mean: 9.9999999999999999, min: 10, max: 10} Must be just some floating point rounding error.

Chart.js auto axis scaling doesn't really seem to know what to do in that case and it blows up the scale to try to show the difference.

ildar170975 commented 7 months ago

Thanks for a feedback. Shall I open an issue in a core?

oliv3r commented 5 months ago

I think we can close this issue, as this is actually an issue in core it seems, as I see this rounding errors in the database itself; so the frontend seems to do just what the database has stored.

ildar170975 commented 5 months ago

... and probably we should create an issue in core.

oliv3r commented 5 months ago

... and probably we should create an issue in core.

You don't think https://github.com/home-assistant/core/issues/118509 covers it?

ildar170975 commented 5 months ago

Missed https://github.com/home-assistant/core/issues/118509. Not still sure that THIS frontend issue should be closed; let developers decide.

github-actions[bot] commented 2 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

ildar170975 commented 2 months ago

Up