Use shorthand attributes in Roomba (#99831)
This commit is contained in:
parent
1fe17b5bed
commit
114b5bd1f0
4 changed files with 8 additions and 36 deletions
|
@ -27,7 +27,7 @@ async def async_setup_entry(
|
|||
class RoombaBinStatus(IRobotEntity, BinarySensorEntity):
|
||||
"""Class to hold Roomba Sensor basic info."""
|
||||
|
||||
ICON = "mdi:delete-variant"
|
||||
_attr_icon = "mdi:delete-variant"
|
||||
_attr_translation_key = "bin_full"
|
||||
|
||||
@property
|
||||
|
@ -35,11 +35,6 @@ class RoombaBinStatus(IRobotEntity, BinarySensorEntity):
|
|||
"""Return the ID of this sensor."""
|
||||
return f"bin_{self._blid}"
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon of this sensor."""
|
||||
return self.ICON
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return the state of the sensor."""
|
||||
|
|
|
@ -29,6 +29,8 @@ SUPPORT_BRAAVA = SUPPORT_IROBOT | VacuumEntityFeature.FAN_SPEED
|
|||
class BraavaJet(IRobotVacuum):
|
||||
"""Braava Jet."""
|
||||
|
||||
_attr_supported_features = SUPPORT_BRAAVA
|
||||
|
||||
def __init__(self, roomba, blid):
|
||||
"""Initialize the Roomba handler."""
|
||||
super().__init__(roomba, blid)
|
||||
|
@ -38,12 +40,7 @@ class BraavaJet(IRobotVacuum):
|
|||
for behavior in BRAAVA_MOP_BEHAVIORS:
|
||||
for spray in BRAAVA_SPRAY_AMOUNT:
|
||||
speed_list.append(f"{behavior}-{spray}")
|
||||
self._speed_list = speed_list
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag vacuum cleaner robot features that are supported."""
|
||||
return SUPPORT_BRAAVA
|
||||
self._attr_fan_speed_list = speed_list
|
||||
|
||||
@property
|
||||
def fan_speed(self):
|
||||
|
@ -62,11 +59,6 @@ class BraavaJet(IRobotVacuum):
|
|||
pad_wetness_value = pad_wetness.get("disposable")
|
||||
return f"{behavior}-{pad_wetness_value}"
|
||||
|
||||
@property
|
||||
def fan_speed_list(self):
|
||||
"""Get the list of available fan speed steps of the vacuum cleaner."""
|
||||
return self._speed_list
|
||||
|
||||
async def async_set_fan_speed(self, fan_speed, **kwargs):
|
||||
"""Set fan speed."""
|
||||
try:
|
||||
|
|
|
@ -138,17 +138,14 @@ class IRobotVacuum(IRobotEntity, StateVacuumEntity):
|
|||
"""Base class for iRobot robots."""
|
||||
|
||||
_attr_name = None
|
||||
_attr_supported_features = SUPPORT_IROBOT
|
||||
_attr_available = True # Always available, otherwise setup will fail
|
||||
|
||||
def __init__(self, roomba, blid):
|
||||
"""Initialize the iRobot handler."""
|
||||
super().__init__(roomba, blid)
|
||||
self._cap_position = self.vacuum_state.get("cap", {}).get("pose") == 1
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag vacuum cleaner robot features that are supported."""
|
||||
return SUPPORT_IROBOT
|
||||
|
||||
@property
|
||||
def battery_level(self):
|
||||
"""Return the battery level of the vacuum cleaner."""
|
||||
|
@ -159,11 +156,6 @@ class IRobotVacuum(IRobotEntity, StateVacuumEntity):
|
|||
"""Return the state of the vacuum cleaner."""
|
||||
return self._robot_state
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
return True # Always available, otherwise setup will fail
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
"""Return the state attributes of the device."""
|
||||
|
|
|
@ -42,10 +42,8 @@ class RoombaVacuum(IRobotVacuum):
|
|||
class RoombaVacuumCarpetBoost(RoombaVacuum):
|
||||
"""Roomba robot with carpet boost."""
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag vacuum cleaner robot features that are supported."""
|
||||
return SUPPORT_ROOMBA_CARPET_BOOST
|
||||
_attr_fan_speed_list = FAN_SPEEDS
|
||||
_attr_supported_features = SUPPORT_ROOMBA_CARPET_BOOST
|
||||
|
||||
@property
|
||||
def fan_speed(self):
|
||||
|
@ -62,11 +60,6 @@ class RoombaVacuumCarpetBoost(RoombaVacuum):
|
|||
fan_speed = FAN_SPEED_ECO
|
||||
return fan_speed
|
||||
|
||||
@property
|
||||
def fan_speed_list(self):
|
||||
"""Get the list of available fan speed steps of the vacuum cleaner."""
|
||||
return FAN_SPEEDS
|
||||
|
||||
async def async_set_fan_speed(self, fan_speed, **kwargs):
|
||||
"""Set fan speed."""
|
||||
if fan_speed.capitalize() in FAN_SPEEDS:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue