Просмотр исходного кода

Block againt None in tank_full_or_missing

During startup we are getting an error due to the fallback in get_key_for_value
not working as expected when value is None.
Jason Rumney 5 лет назад
Родитель
Сommit
dcf14710fa
1 измененных файлов с 7 добавлено и 4 удалено
  1. 7 4
      custom_components/tuya_local/dehumidifier/climate.py

+ 7 - 4
custom_components/tuya_local/dehumidifier/climate.py

@@ -258,10 +258,13 @@ class GoldairDehumidifier(ClimateDevice):
     @property
     def tank_full_or_missing(self):
         error = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_ERROR])
-        return (
-            TuyaLocalDevice.get_key_for_value(ERROR_CODE_TO_DPS_CODE, error)
-            == ERROR_TANK
-        )
+        if error is not None:
+            return (
+                TuyaLocalDevice.get_key_for_value(ERROR_CODE_TO_DPS_CODE, error)
+                == ERROR_TANK
+            )
+        else:
+            return None
 
     @property
     def defrosting(self):