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

Update statistics chart to respect entity display precision, fix precision bug in history chart #18334

Merged
merged 3 commits into from
Oct 23, 2023

Conversation

karwosts
Copy link
Contributor

Proposed change

Allow statistics chart graph tooltip to get a display precision from an entity's settings. Previously seems hardcoded to two decimal places.

Also fixes a bug in history-graph use of display precision where the wrong dataset index is used when an entity has multiple datasets (like a climate entity).

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

)
: undefined
getNumberFormatOptions(
undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we pass the state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this, but looking at what getNumberFormatOptions does with the state, I'm not sure it made sense to use it.

The only thing it seems to check is if the current state is an integer. Should the current state of an entity affect how all its historical states are rendered?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, unless we assume the state was always an integer, which I dont think we can do.
More the step that might be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you could combine the current step attribute, and the historical state value, merge them into a HassEntity, and pass that to the function.

@bramkragten bramkragten merged commit 6cae11f into home-assistant:dev Oct 23, 2023
@karwosts karwosts deleted the stats-display-precision branch October 23, 2023 14:05
@github-actions github-actions bot locked and limited conversation to collaborators Oct 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entity details graph using less accuracy as entity itself
2 participants