mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Fix incorrect unit of measurement access in Tuya (#62989)
This commit is contained in:
parent
12a57ad925
commit
fc1899987a
@ -727,15 +727,15 @@ class TuyaSensorEntity(TuyaEntity, SensorEntity):
|
|||||||
# We cannot have a device class, if the UOM isn't set or the
|
# We cannot have a device class, if the UOM isn't set or the
|
||||||
# device class cannot be found in the validation mapping.
|
# device class cannot be found in the validation mapping.
|
||||||
if (
|
if (
|
||||||
self.unit_of_measurement is None
|
self.native_unit_of_measurement is None
|
||||||
or self.device_class not in DEVICE_CLASS_UNITS
|
or self.device_class not in DEVICE_CLASS_UNITS
|
||||||
):
|
):
|
||||||
self._attr_device_class = None
|
self._attr_device_class = None
|
||||||
return
|
return
|
||||||
|
|
||||||
uoms = DEVICE_CLASS_UNITS[self.device_class]
|
uoms = DEVICE_CLASS_UNITS[self.device_class]
|
||||||
self._uom = uoms.get(self.unit_of_measurement) or uoms.get(
|
self._uom = uoms.get(self.native_unit_of_measurement) or uoms.get(
|
||||||
self.unit_of_measurement.lower()
|
self.native_unit_of_measurement.lower()
|
||||||
)
|
)
|
||||||
|
|
||||||
# Unknown unit of measurement, device class should not be used.
|
# Unknown unit of measurement, device class should not be used.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user