Skip to content

Commit b5ea004

Browse files
committed
Use display_precision for entity precision
Replace dp with display_precision when reading precision from hass.entities, matching the EntityRegistryDisplayEntry type used by the frontend.
1 parent 9e6f42b commit b5ea004

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ export class HuiEnergySourcesTableCard
109109
name?: string
110110
) {
111111
const displayPrecision =
112-
type === "gas" ? this.hass.entities[statId]?.dp : undefined;
112+
type === "gas"
113+
? this.hass.entities[statId]?.display_precision
114+
: undefined;
113115

114116
const formatOptions =
115117
displayPrecision !== undefined
@@ -118,7 +120,7 @@ export class HuiEnergySourcesTableCard
118120
maximumFractionDigits: displayPrecision,
119121
}
120122
: undefined;
121-
123+
122124
return html`<tr
123125
class="mdc-data-table__row ${classMap({
124126
clickable: !isExternalStatistic(statId),
@@ -340,7 +342,10 @@ export class HuiEnergySourcesTableCard
340342
: allTypes;
341343

342344
const gasDisplayPrecisions = types.gas
343-
?.map((source) => this.hass.entities[source.stat_energy_from]?.dp)
345+
?.map(
346+
(source) =>
347+
this.hass.entities[source.stat_energy_from]?.display_precision
348+
)
344349
.filter((precision): precision is number => precision !== undefined);
345350

346351
const gasDisplayPrecision = gasDisplayPrecisions?.length
@@ -354,7 +359,7 @@ export class HuiEnergySourcesTableCard
354359
maximumFractionDigits: gasDisplayPrecision,
355360
}
356361
: undefined;
357-
362+
358363
const computedStyles = getComputedStyle(this);
359364

360365
// Check if any source has cost configuration

0 commit comments

Comments
 (0)