diff --git a/homeassistant/components/mqtt/alarm_control_panel.py b/homeassistant/components/mqtt/alarm_control_panel.py index cca4e58658c..da45de4e190 100644 --- a/homeassistant/components/mqtt/alarm_control_panel.py +++ b/homeassistant/components/mqtt/alarm_control_panel.py @@ -8,14 +8,7 @@ import re import voluptuous as vol import homeassistant.components.alarm_control_panel as alarm -from homeassistant.components.alarm_control_panel.const import ( - SUPPORT_ALARM_ARM_AWAY, - SUPPORT_ALARM_ARM_CUSTOM_BYPASS, - SUPPORT_ALARM_ARM_HOME, - SUPPORT_ALARM_ARM_NIGHT, - SUPPORT_ALARM_ARM_VACATION, - SUPPORT_ALARM_TRIGGER, -) +from homeassistant.components.alarm_control_panel import AlarmControlPanelEntityFeature from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_CODE, @@ -228,12 +221,12 @@ class MqttAlarm(MqttEntity, alarm.AlarmControlPanelEntity): def supported_features(self) -> int: """Return the list of supported features.""" return ( - SUPPORT_ALARM_ARM_HOME - | SUPPORT_ALARM_ARM_AWAY - | SUPPORT_ALARM_ARM_NIGHT - | SUPPORT_ALARM_ARM_VACATION - | SUPPORT_ALARM_ARM_CUSTOM_BYPASS - | SUPPORT_ALARM_TRIGGER + AlarmControlPanelEntityFeature.ARM_HOME + | AlarmControlPanelEntityFeature.ARM_AWAY + | AlarmControlPanelEntityFeature.ARM_NIGHT + | AlarmControlPanelEntityFeature.ARM_VACATION + | AlarmControlPanelEntityFeature.ARM_CUSTOM_BYPASS + | AlarmControlPanelEntityFeature.TRIGGER ) @property diff --git a/homeassistant/components/mqtt/climate.py b/homeassistant/components/mqtt/climate.py index 94320cc5def..5c53380bb71 100644 --- a/homeassistant/components/mqtt/climate.py +++ b/homeassistant/components/mqtt/climate.py @@ -10,6 +10,7 @@ from homeassistant.components import climate from homeassistant.components.climate import ( PLATFORM_SCHEMA as CLIMATE_PLATFORM_SCHEMA, ClimateEntity, + ClimateEntityFeature, ) from homeassistant.components.climate.const import ( ATTR_HVAC_MODE, @@ -30,12 +31,6 @@ from homeassistant.components.climate.const import ( HVAC_MODE_OFF, PRESET_AWAY, PRESET_NONE, - SUPPORT_AUX_HEAT, - SUPPORT_FAN_MODE, - SUPPORT_PRESET_MODE, - SUPPORT_SWING_MODE, - SUPPORT_TARGET_TEMPERATURE, - SUPPORT_TARGET_TEMPERATURE_RANGE, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( @@ -1040,27 +1035,27 @@ class MqttClimate(MqttEntity, ClimateEntity): if (self._topic[CONF_TEMP_STATE_TOPIC] is not None) or ( self._topic[CONF_TEMP_COMMAND_TOPIC] is not None ): - support |= SUPPORT_TARGET_TEMPERATURE + support |= ClimateEntityFeature.TARGET_TEMPERATURE if (self._topic[CONF_TEMP_LOW_STATE_TOPIC] is not None) or ( self._topic[CONF_TEMP_LOW_COMMAND_TOPIC] is not None ): - support |= SUPPORT_TARGET_TEMPERATURE_RANGE + support |= ClimateEntityFeature.TARGET_TEMPERATURE_RANGE if (self._topic[CONF_TEMP_HIGH_STATE_TOPIC] is not None) or ( self._topic[CONF_TEMP_HIGH_COMMAND_TOPIC] is not None ): - support |= SUPPORT_TARGET_TEMPERATURE_RANGE + support |= ClimateEntityFeature.TARGET_TEMPERATURE_RANGE if (self._topic[CONF_FAN_MODE_STATE_TOPIC] is not None) or ( self._topic[CONF_FAN_MODE_COMMAND_TOPIC] is not None ): - support |= SUPPORT_FAN_MODE + support |= ClimateEntityFeature.FAN_MODE if (self._topic[CONF_SWING_MODE_STATE_TOPIC] is not None) or ( self._topic[CONF_SWING_MODE_COMMAND_TOPIC] is not None ): - support |= SUPPORT_SWING_MODE + support |= ClimateEntityFeature.SWING_MODE # AWAY and HOLD mode topics and templates are deprecated, support will be removed with release 2022.9 if ( @@ -1070,12 +1065,12 @@ class MqttClimate(MqttEntity, ClimateEntity): or (self._topic[CONF_HOLD_STATE_TOPIC] is not None) or (self._topic[CONF_HOLD_COMMAND_TOPIC] is not None) ): - support |= SUPPORT_PRESET_MODE + support |= ClimateEntityFeature.PRESET_MODE if (self._topic[CONF_AUX_STATE_TOPIC] is not None) or ( self._topic[CONF_AUX_COMMAND_TOPIC] is not None ): - support |= SUPPORT_AUX_HEAT + support |= ClimateEntityFeature.AUX_HEAT return support diff --git a/homeassistant/components/mqtt/cover.py b/homeassistant/components/mqtt/cover.py index 282e57fea9e..76f984f1bc9 100644 --- a/homeassistant/components/mqtt/cover.py +++ b/homeassistant/components/mqtt/cover.py @@ -12,15 +12,8 @@ from homeassistant.components.cover import ( ATTR_POSITION, ATTR_TILT_POSITION, DEVICE_CLASSES_SCHEMA, - SUPPORT_CLOSE, - SUPPORT_CLOSE_TILT, - SUPPORT_OPEN, - SUPPORT_OPEN_TILT, - SUPPORT_SET_POSITION, - SUPPORT_SET_TILT_POSITION, - SUPPORT_STOP, - SUPPORT_STOP_TILT, CoverEntity, + CoverEntityFeature, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( @@ -102,10 +95,10 @@ DEFAULT_TILT_OPEN_POSITION = 100 DEFAULT_TILT_OPTIMISTIC = False TILT_FEATURES = ( - SUPPORT_OPEN_TILT - | SUPPORT_CLOSE_TILT - | SUPPORT_STOP_TILT - | SUPPORT_SET_TILT_POSITION + CoverEntityFeature.OPEN_TILT + | CoverEntityFeature.CLOSE_TILT + | CoverEntityFeature.STOP_TILT + | CoverEntityFeature.SET_TILT_POSITION ) MQTT_COVER_ATTRIBUTES_BLOCKED = frozenset( @@ -519,14 +512,14 @@ class MqttCover(MqttEntity, CoverEntity): supported_features = 0 if self._config.get(CONF_COMMAND_TOPIC) is not None: if self._config.get(CONF_PAYLOAD_OPEN) is not None: - supported_features |= SUPPORT_OPEN + supported_features |= CoverEntityFeature.OPEN if self._config.get(CONF_PAYLOAD_CLOSE) is not None: - supported_features |= SUPPORT_CLOSE + supported_features |= CoverEntityFeature.CLOSE if self._config.get(CONF_PAYLOAD_STOP) is not None: - supported_features |= SUPPORT_STOP + supported_features |= CoverEntityFeature.STOP if self._config.get(CONF_SET_POSITION_TOPIC) is not None: - supported_features |= SUPPORT_SET_POSITION + supported_features |= CoverEntityFeature.SET_POSITION if self._config.get(CONF_TILT_COMMAND_TOPIC) is not None: supported_features |= TILT_FEATURES diff --git a/homeassistant/components/mqtt/fan.py b/homeassistant/components/mqtt/fan.py index 89ea7dbdd4b..ff2eab7a68f 100644 --- a/homeassistant/components/mqtt/fan.py +++ b/homeassistant/components/mqtt/fan.py @@ -12,10 +12,8 @@ from homeassistant.components.fan import ( ATTR_OSCILLATING, ATTR_PERCENTAGE, ATTR_PRESET_MODE, - SUPPORT_OSCILLATE, - SUPPORT_PRESET_MODE, - SUPPORT_SET_SPEED, FanEntity, + FanEntityFeature, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( @@ -326,12 +324,12 @@ class MqttFan(MqttEntity, FanEntity): self._supported_features = 0 self._supported_features |= ( self._topic[CONF_OSCILLATION_COMMAND_TOPIC] is not None - and SUPPORT_OSCILLATE + and FanEntityFeature.OSCILLATE ) if self._feature_percentage: - self._supported_features |= SUPPORT_SET_SPEED + self._supported_features |= FanEntityFeature.SET_SPEED if self._feature_preset_mode: - self._supported_features |= SUPPORT_PRESET_MODE + self._supported_features |= FanEntityFeature.PRESET_MODE for key, tpl in self._command_templates.items(): self._command_templates[key] = MqttCommandTemplate( diff --git a/homeassistant/components/mqtt/humidifier.py b/homeassistant/components/mqtt/humidifier.py index 99674051521..f5a8b372532 100644 --- a/homeassistant/components/mqtt/humidifier.py +++ b/homeassistant/components/mqtt/humidifier.py @@ -12,9 +12,9 @@ from homeassistant.components.humidifier import ( ATTR_MODE, DEFAULT_MAX_HUMIDITY, DEFAULT_MIN_HUMIDITY, - SUPPORT_MODES, HumidifierDeviceClass, HumidifierEntity, + HumidifierEntityFeature, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( @@ -250,7 +250,7 @@ class MqttHumidifier(MqttEntity, HumidifierEntity): else: self._available_modes = [] if self._available_modes: - self._attr_supported_features = SUPPORT_MODES + self._attr_supported_features = HumidifierEntityFeature.MODES else: self._attr_supported_features = 0 diff --git a/homeassistant/components/mqtt/lock.py b/homeassistant/components/mqtt/lock.py index 1dd73175b3b..66efe9fece7 100644 --- a/homeassistant/components/mqtt/lock.py +++ b/homeassistant/components/mqtt/lock.py @@ -6,7 +6,7 @@ import functools import voluptuous as vol from homeassistant.components import lock -from homeassistant.components.lock import SUPPORT_OPEN, LockEntity +from homeassistant.components.lock import LockEntity, LockEntityFeature from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_NAME, CONF_OPTIMISTIC, CONF_VALUE_TEMPLATE from homeassistant.core import HomeAssistant, callback @@ -176,7 +176,7 @@ class MqttLock(MqttEntity, LockEntity): @property def supported_features(self): """Flag supported features.""" - return SUPPORT_OPEN if CONF_PAYLOAD_OPEN in self._config else 0 + return LockEntityFeature.OPEN if CONF_PAYLOAD_OPEN in self._config else 0 async def async_lock(self, **kwargs): """Lock the device.