From fc1899987aae9edf1f91100bf4f22766732bc835 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 29 Dec 2021 15:35:51 +0100 Subject: [PATCH] Fix incorrect unit of measurement access in Tuya (#62989) --- homeassistant/components/tuya/sensor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index d6870d4b9bb..07393b636e8 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -727,15 +727,15 @@ class TuyaSensorEntity(TuyaEntity, SensorEntity): # We cannot have a device class, if the UOM isn't set or the # device class cannot be found in the validation mapping. if ( - self.unit_of_measurement is None + self.native_unit_of_measurement is None or self.device_class not in DEVICE_CLASS_UNITS ): self._attr_device_class = None return uoms = DEVICE_CLASS_UNITS[self.device_class] - self._uom = uoms.get(self.unit_of_measurement) or uoms.get( - self.unit_of_measurement.lower() + self._uom = uoms.get(self.native_unit_of_measurement) or uoms.get( + self.native_unit_of_measurement.lower() ) # Unknown unit of measurement, device class should not be used.