Use shorthand attributes in sharkiq vacuum (#70844)
This commit is contained in:
parent
3901b5c8e8
commit
0425f8bc4e
1 changed files with 7 additions and 28 deletions
|
@ -66,6 +66,7 @@ async def async_setup_entry(
|
|||
class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuumEntity):
|
||||
"""Shark IQ vacuum entity."""
|
||||
|
||||
_attr_fan_speed_list = list(FAN_SPEEDS_MAP)
|
||||
_attr_supported_features = (
|
||||
VacuumEntityFeature.BATTERY
|
||||
| VacuumEntityFeature.FAN_SPEED
|
||||
|
@ -84,6 +85,9 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
|||
"""Create a new SharkVacuumEntity."""
|
||||
super().__init__(coordinator)
|
||||
self.sharkiq = sharkiq
|
||||
self._attr_name = sharkiq.name
|
||||
self._attr_unique_id = sharkiq.serial_number
|
||||
self._serial_number = sharkiq.serial_number
|
||||
|
||||
def clean_spot(self, **kwargs):
|
||||
"""Clean a spot. Not yet implemented."""
|
||||
|
@ -96,17 +100,7 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
|||
@property
|
||||
def is_online(self) -> bool:
|
||||
"""Tell us if the device is online."""
|
||||
return self.coordinator.device_is_online(self.sharkiq.serial_number)
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Device name."""
|
||||
return self.sharkiq.name
|
||||
|
||||
@property
|
||||
def serial_number(self) -> str:
|
||||
"""Vacuum API serial number (DSN)."""
|
||||
return self.sharkiq.serial_number
|
||||
return self.coordinator.device_is_online(self._serial_number)
|
||||
|
||||
@property
|
||||
def model(self) -> str:
|
||||
|
@ -119,7 +113,7 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
|||
def device_info(self) -> DeviceInfo:
|
||||
"""Device info dictionary."""
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.serial_number)},
|
||||
identifiers={(DOMAIN, self._serial_number)},
|
||||
manufacturer=SHARK,
|
||||
model=self.model,
|
||||
name=self.name,
|
||||
|
@ -128,11 +122,6 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
|||
),
|
||||
)
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Flag vacuum cleaner robot features that are supported."""
|
||||
return self._attr_supported_features
|
||||
|
||||
@property
|
||||
def error_code(self) -> int | None:
|
||||
"""Return the last observed error code (or None)."""
|
||||
|
@ -169,11 +158,6 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
|||
return STATE_DOCKED
|
||||
return self.operating_mode
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return the unique id of the vacuum cleaner."""
|
||||
return self.serial_number
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Determine if the sensor is available based on API results."""
|
||||
|
@ -181,7 +165,7 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
|||
return self.coordinator.last_update_success and self.is_online
|
||||
|
||||
@property
|
||||
def battery_level(self):
|
||||
def battery_level(self) -> int | None:
|
||||
"""Get the current battery level."""
|
||||
return self.sharkiq.get_property_value(Properties.BATTERY_CAPACITY)
|
||||
|
||||
|
@ -226,11 +210,6 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
|||
)
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
@property
|
||||
def fan_speed_list(self):
|
||||
"""Get the list of available fan speed steps of the vacuum cleaner."""
|
||||
return list(FAN_SPEEDS_MAP)
|
||||
|
||||
# Various attributes we want to expose
|
||||
@property
|
||||
def recharge_resume(self) -> bool | None:
|
||||
|
|
Loading…
Add table
Reference in a new issue