Quellcode durchsuchen

Supported features: ensure enums are always used

HA 2024.1 has deprecated the use of old constants, but even 0 (which
does not have a constant, nor an enum value to assign) is caught up in
this.

Workaround this by casting 0 to the enum type.

Issue #1484
Jason Rumney vor 2 Jahren
Ursprung
Commit
519a72c1a5

+ 1 - 1
custom_components/tuya_local/climate.py

@@ -93,7 +93,7 @@ class TuyaLocalClimate(TuyaLocalEntity, ClimateEntity):
         self._maxtemp_dps = dps_map.pop("max_temperature", None)
 
         self._init_end(dps_map)
-        self._support_flags = 0
+        self._support_flags = ClimateEntityFeature(0)
 
         if self._aux_heat_dps:
             self._support_flags |= ClimateEntityFeature.AUX_HEAT

+ 1 - 1
custom_components/tuya_local/cover.py

@@ -47,7 +47,7 @@ class TuyaLocalCover(TuyaLocalEntity, CoverEntity):
         self._open_dp = dps_map.pop("open", None)
         self._init_end(dps_map)
 
-        self._support_flags = 0
+        self._support_flags = CoverEntityFeature(0)
         if self._position_dp:
             self._support_flags |= CoverEntityFeature.SET_POSITION
         if self._control_dp:

+ 1 - 1
custom_components/tuya_local/fan.py

@@ -44,7 +44,7 @@ class TuyaLocalFan(TuyaLocalEntity, FanEntity):
         self._direction_dps = dps_map.pop("direction", None)
         self._init_end(dps_map)
 
-        self._support_flags = 0
+        self._support_flags = FanEntityFeature(0)
         if self._preset_dps:
             self._support_flags |= FanEntityFeature.PRESET_MODE
         if self._speed_dps:

+ 1 - 1
custom_components/tuya_local/humidifier.py

@@ -50,7 +50,7 @@ class TuyaLocalHumidifier(TuyaLocalEntity, HumidifierEntity):
         self._switch_dp = dps_map.pop("switch", None)
         self._init_end(dps_map)
 
-        self._support_flags = 0
+        self._support_flags = HumidifierEntityFeature(0)
         if self._mode_dp:
             self._support_flags |= HumidifierEntityFeature.MODES
 

+ 0 - 1
custom_components/tuya_local/lawn_mower.py

@@ -43,7 +43,6 @@ class TuyaLocalLawnMower(TuyaLocalEntity, LawnMowerEntity):
         self._command_dp = dps_map.pop("command", None)
         self._init_end(dps_map)
 
-        self._attr_supported_features = 0
         if self._command_dp:
             available_commands = self._command_dp.values(self._device)
             if SERVICE_START_MOWING in available_commands:

+ 1 - 1
custom_components/tuya_local/light.py

@@ -93,7 +93,7 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
         if self.effect_list:
             return LightEntityFeature.EFFECT
         else:
-            return 0
+            return LightEntityFeature(0)
 
     @property
     def color_mode(self):

+ 0 - 1
custom_components/tuya_local/remote.py

@@ -110,7 +110,6 @@ class TuyaLocalRemote(TuyaLocalEntity, RemoteEntity):
         self._delay_dp = dps_map.pop("delay", None)
         self._type_dp = dps_map.pop("code_type", None)
         self._init_end(dps_map)
-        self._attr_supported_features = 0
         if self._receive_dp:
             self._attr_supported_features |= (
                 RemoteEntityFeature.LEARN_COMMAND | RemoteEntityFeature.DELETE_COMMAND

+ 1 - 1
custom_components/tuya_local/siren.py

@@ -44,7 +44,7 @@ class TuyaLocalSiren(TuyaLocalEntity, SirenEntity):
         self._init_end(dps_map)
         # All control of features is through the turn_on service, so we need to
         # support that, even if the siren does not support direct control
-        support = 0
+        support = SirenEntityFeature(0)
         if self._tone_dp:
             support |= (
                 SirenEntityFeature.TONES

+ 1 - 1
custom_components/tuya_local/water_heater.py

@@ -63,7 +63,7 @@ class TuyaLocalWaterHeater(TuyaLocalEntity, WaterHeaterEntity):
         self._operation_mode_dps = dps_map.pop(ATTR_OPERATION_MODE, None)
         self._away_mode_dps = dps_map.pop(ATTR_AWAY_MODE, None)
         self._init_end(dps_map)
-        self._support_flags = 0
+        self._support_flags = WaterHeaterEntityFeature(0)
 
         if self._operation_mode_dps:
             self._support_flags |= WaterHeaterEntityFeature.OPERATION_MODE