Skip to content
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

Hey, I'm dealing with similar problems #10

Open
kdeyev opened this issue Aug 21, 2023 · 1 comment
Open

Hey, I'm dealing with similar problems #10

kdeyev opened this issue Aug 21, 2023 · 1 comment

Comments

@kdeyev
Copy link

kdeyev commented Aug 21, 2023

Hi,

I'm developing a HASS integration that imports water meter readings and I deal with similar problems.
I've tried to use the ha-historical-sensor and I have some questions about the usage.

I see that the code example suggests not setting the _attr_state_class and the _state. The sensor works with Energy Dashboard (but shows a warning message here and there). But I see some other sensor usage is limited.

Is it anyhow possible to overcome setting the _attr_state_class and _state to None?

@ldotlopez
Copy link
Owner

Hi, author here.

  • By setting the _state attr you are telling HA that you have a current state, which is not true if your are importing data from the past. You may think that the last state (now-X hours) may be the current _state but it's not, in X hours you will import new data and that point may have a different value. Also messes graphs with inconsistent data points.
  • Setting _attr_state_class causes HA to calculate statistics data which is not what you want since your are working with historical data and not present data. Statistical data will be incorrect, if any is calculated. Historical sensors have helper functions to deal with statistics

I have a pending PR with some valuable info: #9
Also, check this issue and following discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants