Use shorthand attributes in xiaomi_miio vacuum (#70848)

This commit is contained in:
epenet 2022-04-27 09:57:18 +02:00 committed by GitHub
parent e6b8843423
commit 052c3fcb6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -227,12 +227,12 @@ class MiroboVacuum(
return self._state
@property
def battery_level(self):
def battery_level(self) -> int:
"""Return the battery level of the vacuum cleaner."""
return self.coordinator.data.status.battery
@property
def fan_speed(self):
def fan_speed(self) -> str:
"""Return the fan speed of the vacuum cleaner."""
speed = self.coordinator.data.status.fanspeed
if speed in self.coordinator.data.fan_speeds_reverse:
@ -240,16 +240,14 @@ class MiroboVacuum(
_LOGGER.debug("Unable to find reverse for %s", speed)
return speed
return str(speed)
@property
def fan_speed_list(self):
def fan_speed_list(self) -> list[str]:
"""Get the list of available fan speed steps of the vacuum cleaner."""
return (
list(self.coordinator.data.fan_speeds)
if self.coordinator.data.fan_speeds
else []
)
if speed_list := self.coordinator.data.fan_speeds:
return list(speed_list)
return []
@property
def timers(self):
@ -276,11 +274,6 @@ class MiroboVacuum(
attrs[ATTR_TIMERS] = self.timers
return attrs
@property
def supported_features(self):
"""Flag vacuum cleaner robot features that are supported."""
return self._attr_supported_features
async def _try_command(self, mask_error, func, *args, **kwargs):
"""Call a vacuum command handling error messages."""
try: