Преглед изворни кода

climate: avoid raising ValueError for unavailable hvac_mode.

When hvac_mode is unavailable, just report it as such without raising an error.
The error is only needed to gather info on actual unhandled values.

Issue #502

Same for hvac_action - Issue #616
Jason Rumney пре 2 година
родитељ
комит
7d72d4ddbb
1 измењених фајлова са 2 додато и 2 уклоњено
  1. 2 2
      custom_components/tuya_local/climate.py

+ 2 - 2
custom_components/tuya_local/climate.py

@@ -285,7 +285,7 @@ class TuyaLocalClimate(TuyaLocalEntity, ClimateEntity):
             return None
             return None
         action = self._hvac_action_dps.get_value(self._device)
         action = self._hvac_action_dps.get_value(self._device)
         try:
         try:
-            return HVACAction(action)
+            return HVACAction(action) if action else None
         except ValueError:
         except ValueError:
             _LOGGER.warning(f"_Unrecognised HVAC Action {action} ignored")
             _LOGGER.warning(f"_Unrecognised HVAC Action {action} ignored")
             return None
             return None
@@ -297,7 +297,7 @@ class TuyaLocalClimate(TuyaLocalEntity, ClimateEntity):
             return HVACMode.AUTO
             return HVACMode.AUTO
         hvac_mode = self._hvac_mode_dps.get_value(self._device)
         hvac_mode = self._hvac_mode_dps.get_value(self._device)
         try:
         try:
-            return HVACMode(hvac_mode)
+            return HVACMode(hvac_mode) if hvac_mode else None
         except ValueError:
         except ValueError:
             _LOGGER.warning(f"Unrecognised HVAC Mode of {hvac_mode} ignored")
             _LOGGER.warning(f"Unrecognised HVAC Mode of {hvac_mode} ignored")
             return None
             return None