Explorar o código

Block againt None in swing_mode

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 %!s(int64=6) %!d(string=hai) anos
pai
achega
1a543ec33b
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      custom_components/tuya_local/heater/climate.py

+ 3 - 0
custom_components/tuya_local/heater/climate.py

@@ -210,6 +210,9 @@ class GoldairHeater(ClimateDevice):
     def swing_mode(self):
         """Return the power level."""
         dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_POWER_MODE])
+        if dps_mode == None:
+            return None
+
         if dps_mode == ATTR_POWER_MODE_USER:
             dps_mode = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_POWER_LEVEL])
         return TuyaLocalDevice.get_key_for_value(POWER_LEVEL_TO_DPS_LEVEL, dps_mode)