Fix sensors without unit attribute in Shelly integration (#39629)
This commit is contained in:
1 parent
8fd9f56d21
commit
ad3e520e09
1 file changed
+2
-4
@@ -72,8 +72,6 @@ class ShellySensor(ShellyBlockEntity, Entity):
|
|||||||
unit = TEMP_CELSIUS
|
unit = TEMP_CELSIUS
|
||||||
else:
|
else:
|
||||||
unit = TEMP_FAHRENHEIT
|
unit = TEMP_FAHRENHEIT
|
||||||
elif self.info[aioshelly.BLOCK_VALUE_TYPE] == aioshelly.BLOCK_VALUE_TYPE_ENERGY:
|
|
||||||
unit = ENERGY_KILO_WATT_HOUR
|
|
||||||
|
|
||||||
self._unit = unit
|
self._unit = unit
|
||||||
self._device_class = device_class
|
self._device_class = device_class
|
||||||
@@ -104,9 +102,9 @@ class ShellySensor(ShellyBlockEntity, Entity):
|
|||||||
]:
|
]:
|
||||||
return round(value, 1)
|
return round(value, 1)
|
||||||
# Energy unit change from Wmin or Wh to kWh
|
# Energy unit change from Wmin or Wh to kWh
|
||||||
if self.info[aioshelly.BLOCK_VALUE_UNIT] == "Wmin":
|
if self.info.get(aioshelly.BLOCK_VALUE_UNIT) == "Wmin":
|
||||||
return round(value / 60 / 1000, 2)
|
return round(value / 60 / 1000, 2)
|
||||||
if self.info[aioshelly.BLOCK_VALUE_UNIT] == "Wh":
|
if self.info.get(aioshelly.BLOCK_VALUE_UNIT) == "Wh":
|
||||||
return round(value / 1000, 2)
|
return round(value / 1000, 2)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user