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