Explorar o código

feat(fan): allow fans to conditionally have preset mode.

Rather than just the preset_mode existing, check that it has modes as well.
This allows a config to conditionally enable presets, leaving none defined
if the model does not support them, reducing the number of config files
needed to cover variants of devices.

PR #4899
Jason Rumney hai 2 meses
pai
achega
d3b3556b76
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      custom_components/tuya_local/fan.py

+ 1 - 1
custom_components/tuya_local/fan.py

@@ -50,7 +50,7 @@ class TuyaLocalFan(TuyaLocalEntity, FanEntity):
         self._init_end(dps_map)
         self._init_end(dps_map)
 
 
         self._support_flags = FanEntityFeature(0)
         self._support_flags = FanEntityFeature(0)
-        if self._preset_dps:
+        if self._preset_dps and self._preset_dps.values(device):
             self._support_flags |= FanEntityFeature.PRESET_MODE
             self._support_flags |= FanEntityFeature.PRESET_MODE
         if self._speed_dps:
         if self._speed_dps:
             self._support_flags |= FanEntityFeature.SET_SPEED
             self._support_flags |= FanEntityFeature.SET_SPEED