mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use faster contains check in vacuum (#106437)
This commit is contained in:
parent
b08268da31
commit
e801413c73
@ -281,7 +281,7 @@ class _BaseVacuum(Entity, cached_properties=BASE_CACHED_PROPERTIES_WITH_ATTR_):
|
|||||||
@property
|
@property
|
||||||
def capability_attributes(self) -> Mapping[str, Any] | None:
|
def capability_attributes(self) -> Mapping[str, Any] | None:
|
||||||
"""Return capability attributes."""
|
"""Return capability attributes."""
|
||||||
if self.supported_features & VacuumEntityFeature.FAN_SPEED:
|
if VacuumEntityFeature.FAN_SPEED in self.supported_features:
|
||||||
return {ATTR_FAN_SPEED_LIST: self.fan_speed_list}
|
return {ATTR_FAN_SPEED_LIST: self.fan_speed_list}
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -289,12 +289,13 @@ class _BaseVacuum(Entity, cached_properties=BASE_CACHED_PROPERTIES_WITH_ATTR_):
|
|||||||
def state_attributes(self) -> dict[str, Any]:
|
def state_attributes(self) -> dict[str, Any]:
|
||||||
"""Return the state attributes of the vacuum cleaner."""
|
"""Return the state attributes of the vacuum cleaner."""
|
||||||
data: dict[str, Any] = {}
|
data: dict[str, Any] = {}
|
||||||
|
supported_features = self.supported_features
|
||||||
|
|
||||||
if self.supported_features & VacuumEntityFeature.BATTERY:
|
if VacuumEntityFeature.BATTERY in supported_features:
|
||||||
data[ATTR_BATTERY_LEVEL] = self.battery_level
|
data[ATTR_BATTERY_LEVEL] = self.battery_level
|
||||||
data[ATTR_BATTERY_ICON] = self.battery_icon
|
data[ATTR_BATTERY_ICON] = self.battery_icon
|
||||||
|
|
||||||
if self.supported_features & VacuumEntityFeature.FAN_SPEED:
|
if VacuumEntityFeature.FAN_SPEED in supported_features:
|
||||||
data[ATTR_FAN_SPEED] = self.fan_speed
|
data[ATTR_FAN_SPEED] = self.fan_speed
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@ -470,7 +471,7 @@ class VacuumEntity(
|
|||||||
"""Return the state attributes of the vacuum cleaner."""
|
"""Return the state attributes of the vacuum cleaner."""
|
||||||
data = super().state_attributes
|
data = super().state_attributes
|
||||||
|
|
||||||
if self.supported_features & VacuumEntityFeature.STATUS:
|
if VacuumEntityFeature.STATUS in self.supported_features:
|
||||||
data[ATTR_STATUS] = self.status
|
data[ATTR_STATUS] = self.status
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user