diff --git a/homeassistant/components/humidifier/__init__.py b/homeassistant/components/humidifier/__init__.py index ef1620b3922..976dad03a45 100644 --- a/homeassistant/components/humidifier/__init__.py +++ b/homeassistant/components/humidifier/__init__.py @@ -143,13 +143,12 @@ class HumidifierEntity(ToggleEntity): @property def capability_attributes(self) -> dict[str, Any]: """Return capability attributes.""" - supported_features = self.supported_features or 0 data: dict[str, int | list[str] | None] = { ATTR_MIN_HUMIDITY: self.min_humidity, ATTR_MAX_HUMIDITY: self.max_humidity, } - if supported_features & HumidifierEntityFeature.MODES: + if self.supported_features & HumidifierEntityFeature.MODES: data[ATTR_AVAILABLE_MODES] = self.available_modes return data @@ -167,13 +166,12 @@ class HumidifierEntity(ToggleEntity): @property def state_attributes(self) -> dict[str, Any]: """Return the optional state attributes.""" - supported_features = self.supported_features or 0 data: dict[str, int | str | None] = {} if self.target_humidity is not None: data[ATTR_HUMIDITY] = self.target_humidity - if supported_features & HumidifierEntityFeature.MODES: + if self.supported_features & HumidifierEntityFeature.MODES: data[ATTR_MODE] = self.mode return data diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index 0e17d5c5339..120a1128597 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -1000,15 +1000,14 @@ class MediaPlayerEntity(Entity): @property def capability_attributes(self) -> dict[str, Any]: """Return capability attributes.""" - supported_features = self.supported_features or 0 data: dict[str, Any] = {} - if supported_features & MediaPlayerEntityFeature.SELECT_SOURCE and ( + if self.supported_features & MediaPlayerEntityFeature.SELECT_SOURCE and ( source_list := self.source_list ): data[ATTR_INPUT_SOURCE_LIST] = source_list - if supported_features & MediaPlayerEntityFeature.SELECT_SOUND_MODE and ( + if self.supported_features & MediaPlayerEntityFeature.SELECT_SOUND_MODE and ( sound_mode_list := self.sound_mode_list ): data[ATTR_SOUND_MODE_LIST] = sound_mode_list diff --git a/homeassistant/components/siren/__init__.py b/homeassistant/components/siren/__init__.py index faf8caf8ed0..0bc16d03770 100644 --- a/homeassistant/components/siren/__init__.py +++ b/homeassistant/components/siren/__init__.py @@ -64,9 +64,8 @@ def process_turn_on_params( Filters out unsupported params and validates the rest. """ - supported_features = siren.supported_features or 0 - if not supported_features & SirenEntityFeature.TONES: + if not siren.supported_features & SirenEntityFeature.TONES: params.pop(ATTR_TONE, None) elif (tone := params.get(ATTR_TONE)) is not None: # Raise an exception if the specified tone isn't available @@ -92,9 +91,9 @@ def process_turn_on_params( key for key, value in siren.available_tones.items() if value == tone ) - if not supported_features & SirenEntityFeature.DURATION: + if not siren.supported_features & SirenEntityFeature.DURATION: params.pop(ATTR_DURATION, None) - if not supported_features & SirenEntityFeature.VOLUME_SET: + if not siren.supported_features & SirenEntityFeature.VOLUME_SET: params.pop(ATTR_VOLUME_LEVEL, None) return params @@ -169,10 +168,8 @@ class SirenEntity(ToggleEntity): @property def capability_attributes(self) -> dict[str, Any] | None: """Return capability attributes.""" - supported_features = self.supported_features or 0 - if ( - supported_features & SirenEntityFeature.TONES + self.supported_features & SirenEntityFeature.TONES and self.available_tones is not None ): return {ATTR_AVAILABLE_TONES: self.available_tones} diff --git a/homeassistant/components/water_heater/__init__.py b/homeassistant/components/water_heater/__init__.py index 187c643638b..4396c66cf22 100644 --- a/homeassistant/components/water_heater/__init__.py +++ b/homeassistant/components/water_heater/__init__.py @@ -191,8 +191,6 @@ class WaterHeaterEntity(Entity): @property def capability_attributes(self) -> Mapping[str, Any]: """Return capability attributes.""" - supported_features = self.supported_features or 0 - data: dict[str, Any] = { ATTR_MIN_TEMP: show_temp( self.hass, self.min_temp, self.temperature_unit, self.precision @@ -202,7 +200,7 @@ class WaterHeaterEntity(Entity): ), } - if supported_features & WaterHeaterEntityFeature.OPERATION_MODE: + if self.supported_features & WaterHeaterEntityFeature.OPERATION_MODE: data[ATTR_OPERATION_LIST] = self.operation_list return data @@ -238,12 +236,10 @@ class WaterHeaterEntity(Entity): ), } - supported_features = self.supported_features or 0 - - if supported_features & WaterHeaterEntityFeature.OPERATION_MODE: + if self.supported_features & WaterHeaterEntityFeature.OPERATION_MODE: data[ATTR_OPERATION_MODE] = self.current_operation - if supported_features & WaterHeaterEntityFeature.AWAY_MODE: + if self.supported_features & WaterHeaterEntityFeature.AWAY_MODE: is_away = self.is_away_mode_on data[ATTR_AWAY_MODE] = STATE_ON if is_away else STATE_OFF