Formats number state with selected language in compute_state_display#7516
Merged
bramkragten merged 5 commits intohome-assistant:devfrom Oct 30, 2020
Merged
Conversation
bramkragten
reviewed
Oct 29, 2020
bramkragten
approved these changes
Oct 30, 2020
Merged
|
This was a nice fix. I'm not going to pretend that i understand the code that does the magic. I just wanted to point out that this doesn't apply to the climate entities showing setpoint and current temperatures in the Lovelace UI, those values are still using the "." separator, while everything else in my setup seems to be using the "," separator which is correct for my language. |
Member
|
Please don't comment on merged PR's, please create a new issue for this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
This updates the
computeStateDisplayfunction to format numbers using the browser'sIntl.NumberFormatfeature based on the selected language in Home Assistant. This results in language-specific thousands separator and decimal characters when displaying a state that is valid number.Type of change
Example configuration
Add an integration that creates entities that use a number state value with a unit of measurement. The Coronavirus integration is a quick and easy way to test this. When rendered in lovelace, more info dialogs, or anywhere the
computeStateDisplayis used, the value should use language-specific comma separators and decimal characters.Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: