diff --git a/custom_components/localtuya/climate.py b/custom_components/localtuya/climate.py index 1785bcf2a..95281827b 100644 --- a/custom_components/localtuya/climate.py +++ b/custom_components/localtuya/climate.py @@ -21,9 +21,7 @@ PRESET_ECO, PRESET_HOME, PRESET_NONE, - SUPPORT_PRESET_MODE, - SUPPORT_TARGET_TEMPERATURE, - SUPPORT_TARGET_TEMPERATURE_RANGE, + ClimateEntityFeature, ) from homeassistant.const import ( ATTR_TEMPERATURE, @@ -31,8 +29,7 @@ PRECISION_HALVES, PRECISION_TENTHS, PRECISION_WHOLE, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfTemperature, ) from .common import LocalTuyaEntity, async_setup_entry @@ -196,11 +193,11 @@ def supported_features(self): """Flag supported features.""" supported_features = 0 if self.has_config(CONF_TARGET_TEMPERATURE_DP): - supported_features = supported_features | SUPPORT_TARGET_TEMPERATURE + supported_features = supported_features | ClimateEntityFeature.TARGET_TEMPERATURE if self.has_config(CONF_MAX_TEMP_DP): - supported_features = supported_features | SUPPORT_TARGET_TEMPERATURE_RANGE + supported_features = supported_features | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE if self.has_config(CONF_PRESET_DP) or self.has_config(CONF_ECO_DP): - supported_features = supported_features | SUPPORT_PRESET_MODE + supported_features = supported_features | ClimateEntityFeature.PRESET_MODE return supported_features @property @@ -220,8 +217,8 @@ def temperature_unit(self): self._config.get(CONF_TEMPERATURE_UNIT, DEFAULT_TEMPERATURE_UNIT) == TEMPERATURE_FAHRENHEIT ): - return TEMP_FAHRENHEIT - return TEMP_CELSIUS + return UnitOfTemperature.FAHRENHEIT + return UnitOfTemperature.CELSIUS @property def hvac_mode(self): @@ -349,7 +346,7 @@ def min_temp(self): if self.has_config(CONF_MIN_TEMP_DP): return self.dps_conf(CONF_MIN_TEMP_DP) # DEFAULT_MIN_TEMP is in C - if self.temperature_unit == TEMP_FAHRENHEIT: + if self.temperature_unit == UnitOfTemperature.FAHRENHEIT: return DEFAULT_MIN_TEMP * 1.8 + 32 else: return DEFAULT_MIN_TEMP @@ -360,7 +357,7 @@ def max_temp(self): if self.has_config(CONF_MAX_TEMP_DP): return self.dps_conf(CONF_MAX_TEMP_DP) # DEFAULT_MAX_TEMP is in C - if self.temperature_unit == TEMP_FAHRENHEIT: + if self.temperature_unit == UnitOfTemperature.FAHRENHEIT: return DEFAULT_MAX_TEMP * 1.8 + 32 else: return DEFAULT_MAX_TEMP diff --git a/custom_components/localtuya/cover.py b/custom_components/localtuya/cover.py index b45669ca6..700dc3f13 100644 --- a/custom_components/localtuya/cover.py +++ b/custom_components/localtuya/cover.py @@ -8,11 +8,7 @@ from homeassistant.components.cover import ( ATTR_POSITION, DOMAIN, - SUPPORT_CLOSE, - SUPPORT_OPEN, - SUPPORT_SET_POSITION, - SUPPORT_STOP, - CoverEntity, + CoverEntity, CoverEntityFeature, ) from .common import LocalTuyaEntity, async_setup_entry @@ -80,9 +76,9 @@ def __init__(self, device, config_entry, switchid, **kwargs): @property def supported_features(self): """Flag supported features.""" - supported_features = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP + supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP if self._config[CONF_POSITIONING_MODE] != COVER_MODE_NONE: - supported_features = supported_features | SUPPORT_SET_POSITION + supported_features = supported_features | CoverEntityFeature.SET_POSITION return supported_features @property diff --git a/custom_components/localtuya/fan.py b/custom_components/localtuya/fan.py index 32c32899c..5e1a3c9c9 100644 --- a/custom_components/localtuya/fan.py +++ b/custom_components/localtuya/fan.py @@ -9,10 +9,7 @@ DIRECTION_FORWARD, DIRECTION_REVERSE, DOMAIN, - SUPPORT_DIRECTION, - SUPPORT_OSCILLATE, - SUPPORT_SET_SPEED, - FanEntity, + FanEntity, FanEntityFeature, ) from homeassistant.util.percentage import ( int_states_in_range, @@ -194,13 +191,13 @@ def supported_features(self) -> int: features = 0 if self.has_config(CONF_FAN_OSCILLATING_CONTROL): - features |= SUPPORT_OSCILLATE + features |= FanEntityFeature.OSCILLATE if self.has_config(CONF_FAN_SPEED_CONTROL): - features |= SUPPORT_SET_SPEED + features |= FanEntityFeature.SET_SPEED if self.has_config(CONF_FAN_DIRECTION): - features |= SUPPORT_DIRECTION + features |= FanEntityFeature.DIRECTION return features diff --git a/custom_components/localtuya/vacuum.py b/custom_components/localtuya/vacuum.py index 7bf4ed636..11e7a61ec 100644 --- a/custom_components/localtuya/vacuum.py +++ b/custom_components/localtuya/vacuum.py @@ -11,16 +11,7 @@ STATE_IDLE, STATE_PAUSED, STATE_RETURNING, - SUPPORT_BATTERY, - SUPPORT_FAN_SPEED, - SUPPORT_LOCATE, - SUPPORT_PAUSE, - SUPPORT_RETURN_HOME, - SUPPORT_START, - SUPPORT_STATE, - SUPPORT_STATUS, - SUPPORT_STOP, - StateVacuumEntity, + StateVacuumEntity, VacuumEntityFeature, ) from .common import LocalTuyaEntity, async_setup_entry @@ -123,21 +114,21 @@ def __init__(self, device, config_entry, switchid, **kwargs): def supported_features(self): """Flag supported features.""" supported_features = ( - SUPPORT_START - | SUPPORT_PAUSE - | SUPPORT_STOP - | SUPPORT_STATUS - | SUPPORT_STATE + VacuumEntityFeature.START + | VacuumEntityFeature.PAUSE + | VacuumEntityFeature.STOP + | VacuumEntityFeature.STATUS + | VacuumEntityFeature.STATE ) if self.has_config(CONF_RETURN_MODE): - supported_features = supported_features | SUPPORT_RETURN_HOME + supported_features = supported_features | VacuumEntityFeature.RETURN_HOME if self.has_config(CONF_FAN_SPEED_DP): - supported_features = supported_features | SUPPORT_FAN_SPEED + supported_features = supported_features | VacuumEntityFeature.FAN_SPEED if self.has_config(CONF_BATTERY_DP): - supported_features = supported_features | SUPPORT_BATTERY + supported_features = supported_features | VacuumEntityFeature.BATTERY if self.has_config(CONF_LOCATE_DP): - supported_features = supported_features | SUPPORT_LOCATE + supported_features = supported_features | VacuumEntityFeature.LOCATE return supported_features diff --git a/hacs.json b/hacs.json index 0496f6ff1..8f3f74b4f 100644 --- a/hacs.json +++ b/hacs.json @@ -1,4 +1,4 @@ { "name": "Local Tuya", - "homeassistant": "0.116.0" + "homeassistant": "2024.1.0" }