mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Use shorthand attributes in xiaomi_miio vacuum (#70848)
This commit is contained in:
parent
e6b8843423
commit
052c3fcb6a
@ -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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user