Skip to content

Commit cd9bcae

Browse files
authored
Update distribution card on gas unit changes
Refactor gas source display precision check and update unit of measurement comparison.
1 parent b322c17 commit cd9bcae

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/panels/lovelace/cards/energy/hui-energy-distribution-card.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,15 @@ class HuiEnergyDistrubutionCard
123123
}
124124
if (
125125
this._data &&
126-
energySourcesByType(this._data.prefs).gas?.some(
127-
(source) =>
128-
this.hass.entities[source.stat_energy_from]?.display_precision !==
129-
oldHass.entities[source.stat_energy_from]?.display_precision
130-
)
126+
energySourcesByType(this._data.prefs).gas?.some((source) => {
127+
const statId = source.stat_energy_from;
128+
return (
129+
this.hass.entities[statId]?.display_precision !==
130+
oldHass.entities[statId]?.display_precision ||
131+
this.hass.states[statId]?.attributes.unit_of_measurement !==
132+
oldHass.states[statId]?.attributes.unit_of_measurement
133+
);
134+
})
131135
) {
132136
return true;
133137
}
@@ -463,8 +467,8 @@ class HuiEnergyDistrubutionCard
463467
this.hass,
464468
gasUsage,
465469
this._data.gasUnit,
466-
undefined,
467-
gasDisplayPrecision
470+
undefined,
471+
gasDisplayPrecision
468472
)}
469473
</div>
470474
<svg width="80" height="30">

0 commit comments

Comments
 (0)