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

Add a new state class for odometer #272

Merged
merged 2 commits into from
Apr 13, 2024
Merged

Conversation

maeklund86
Copy link
Contributor

Defining a state class for odometer allows for long-term statistics. Fixes the issue #213

Total: "The state represents a total amount that can both increase and decrease, e.g. a net energy meter."

Examples:

The sensor's value never resets, e.g. a lifetime total energy consumption or production: state_class total, last_reset not set or set to None

https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes

@dvx76
Copy link
Member

dvx76 commented Apr 13, 2024

LGTM. Thanks for your contribution!

@dvx76 dvx76 merged commit b736ce9 into skodaconnect:main Apr 13, 2024
@EDelsman
Copy link

I'm not sure this change from total_increasing tot total is right. State class total would allow for odometer rollback which should not happen, as an odometer is meant to always increase. State class total_increasing is for totals that cannot decrease. It assumes that a lower value is the result of a replacement of the counter for a new one that started at 0. Imo that is a better fit for an odometer than total, which assumes you can undo distance traveled.

@maeklund86
Copy link
Contributor Author

The documentation stated a pretty clear example:
"The sensor's value never resets, e.g. a lifetime total energy consumption or production: state_class total, last_reset not set or set to None"

"It's recommended to use state class total without last_reset whenever possible, state class total_increasing or total with last_reset should only be used when state class total without last_reset does not work for the sensor."

On the other hand:
"The sensor's value may reset to 0, and its value can only increase: state class total_increasing. Examples: energy consumption aligned with a billing cycle, e.g. monthly, an energy meter resetting to 0 every time it's disconnected"

https://developers.home-assistant.io/docs/core/entity/sensor/#entities-representing-a-total-amount

@maeklund86
Copy link
Contributor Author

I think it doesn't matter all that much in this case, as it should never decrease anyhow.

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

Successfully merging this pull request may close these issues.

3 participants