Fix unit conversion for gas cost sensor (#99708)

pull/99741/head
Erik Montnemery 2023-09-06 10:35:04 +02:00 committed by Bram Kragten
parent f9ee18352d
commit 7b7fd35af2
1 changed files with 4 additions and 5 deletions

View File

@ -377,11 +377,10 @@ class EnergyCostSensor(SensorEntity):
if energy_price_unit is None:
converted_energy_price = energy_price
else:
if self._adapter.source_type == "grid":
converter: Callable[
[float, str, str], float
] = unit_conversion.EnergyConverter.convert
elif self._adapter.source_type in ("gas", "water"):
converter: Callable[[float, str, str], float]
if energy_unit in VALID_ENERGY_UNITS:
converter = unit_conversion.EnergyConverter.convert
else:
converter = unit_conversion.VolumeConverter.convert
converted_energy_price = converter(