Format entity & sensor card with manual units; fix param comment typo (#14090)

This commit is contained in:
Josh McCarty 2022-10-17 02:15:37 -07:00 committed by GitHub
parent 0972cb4583
commit a475b06d49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -34,7 +34,7 @@ export const numberFormatToLocale = (
* Formats a number based on the user's preference with thousands separator(s) and decimal character for better legibility.
*
* @param num The number to format
* @param locale The user-selected language and number format, from `hass.locale`
* @param localeOptions The user-selected language and formatting, from `hass.locale`
* @param options Intl.NumberFormatOptions to use
*/
export const formatNumber = (

View File

@ -146,7 +146,7 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {
stateObj.attributes[this._config.attribute!]
)
: this.hass.localize("state.default.unknown")
: isNumericState(stateObj)
: isNumericState(stateObj) || this._config.unit
? formatNumber(stateObj.state, this.hass.locale)
: computeStateDisplay(
this.hass.localize,