Skip to content

Commit

Permalink
Merge pull request #212 from techillin/patch-3
Browse files Browse the repository at this point in the history
Number formatting when using `precision` options
  • Loading branch information
benct authored Dec 17, 2021
2 parents ad8c639 + e88c607 commit 1c6ce79
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handleClick, secondsToDuration } from 'custom-card-helpers';
import { handleClick, secondsToDuration, formatNumber } from 'custom-card-helpers';
import { checkEntity, entityName, entityStateDisplay, entityStyles, entityUnit, entityValue } from './entity';
import { getEntityIds, hasConfigOrEntitiesChanged, hasGenericSecondaryInfo, isObject, hideUnavailable } from './util';
import { style } from './styles';
Expand Down Expand Up @@ -153,7 +153,7 @@ class MultipleEntityRow extends LitElement {
if (config.format.startsWith('precision')) {
const unit = entityUnit(stateObj, config);
const precision = parseInt(config.format.slice(-1), 10);
return `${parseFloat(value).toFixed(precision)}${unit ? ` ${unit}` : ''}`;
return `${formatNumber(parseFloat(value).toFixed(precision))}${unit ? ` ${unit}` : ''}`;
}
return value;
}
Expand Down

0 comments on commit 1c6ce79

Please sign in to comment.