Skip to content

Commit

Permalink
Use correct locale field on entity value formatting (#149, #162, #212)
Browse files Browse the repository at this point in the history
  • Loading branch information
benct committed Dec 18, 2021
1 parent 2ddfcf4 commit f74c5e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const entityStateDisplay = (hass, stateObj, config) => {
}
if (config.format.startsWith('precision')) {
const precision = parseInt(config.format.slice(-1), 10);
const formatted = formatNumber(parseFloat(value), hass.language, {
const formatted = formatNumber(parseFloat(value), hass.locale, {
minimumFractionDigits: precision,
maximumFractionDigits: precision,
});
Expand All @@ -55,12 +55,12 @@ export const entityStateDisplay = (hass, stateObj, config) => {
}

if (config.attribute) {
return `${isNaN(value) ? value : formatNumber(value, hass.language)}${unit ? ` ${unit}` : ''}`;
return `${isNaN(value) ? value : formatNumber(value, hass.locale)}${unit ? ` ${unit}` : ''}`;
}

const modifiedStateObj = { ...stateObj, attributes: { ...stateObj.attributes, unit_of_measurement: unit } };

return computeStateDisplay(hass.localize, modifiedStateObj, hass.language);
return computeStateDisplay(hass.localize, modifiedStateObj, hass.locale);
};

export const entityStyles = (config) =>
Expand Down

0 comments on commit f74c5e3

Please sign in to comment.