Procházet zdrojové kódy

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 před 6 roky
rodič
revize
1a543ec33b
1 změnil soubory, kde provedl 3 přidání a 0 odebrání
  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)