1 """Class for Braava devices."""
7 from .entity
import SUPPORT_IROBOT, IRobotVacuum
9 _LOGGER = logging.getLogger(__name__)
11 ATTR_DETECTED_PAD =
"detected_pad"
12 ATTR_LID_CLOSED =
"lid_closed"
13 ATTR_TANK_PRESENT =
"tank_present"
14 ATTR_TANK_LEVEL =
"tank_level"
15 ATTR_PAD_WETNESS =
"spray_amount"
20 MOP_STANDARD =
"Standard"
22 MOP_EXTENDED =
"Extended"
23 BRAAVA_MOP_BEHAVIORS = [MOP_STANDARD, MOP_DEEP, MOP_EXTENDED]
24 BRAAVA_SPRAY_AMOUNT = [1, 2, 3]
27 SUPPORT_BRAAVA = SUPPORT_IROBOT | VacuumEntityFeature.FAN_SPEED
33 _attr_supported_features = SUPPORT_BRAAVA
36 """Initialize the Roomba handler."""
42 for behavior
in BRAAVA_MOP_BEHAVIORS
43 for spray
in BRAAVA_SPRAY_AMOUNT
48 """Return the fan speed of the vacuum cleaner."""
52 if rank_overlap == OVERLAP_STANDARD:
53 behavior = MOP_STANDARD
54 elif rank_overlap == OVERLAP_DEEP:
56 elif rank_overlap == OVERLAP_EXTENDED:
57 behavior = MOP_EXTENDED
60 pad_wetness_value = pad_wetness.get(
"disposable")
61 return f
"{behavior}-{pad_wetness_value}"
66 split = fan_speed.split(
"-", 1)
69 if behavior.capitalize()
in BRAAVA_MOP_BEHAVIORS:
70 behavior = behavior.capitalize()
73 "Fan speed error: expected {behavior}-{spray_amount}, got '%s'",
78 _LOGGER.error(
"Spray amount error: expected integer, got '%s'", split[1])
80 if behavior
not in BRAAVA_MOP_BEHAVIORS:
82 "Mop behavior error: expected one of %s, got '%s'",
83 str(BRAAVA_MOP_BEHAVIORS),
87 if spray
not in BRAAVA_SPRAY_AMOUNT:
89 "Spray amount error: expected one of %s, got '%d'",
90 str(BRAAVA_SPRAY_AMOUNT),
96 if behavior == MOP_STANDARD:
97 overlap = OVERLAP_STANDARD
98 elif behavior == MOP_DEEP:
99 overlap = OVERLAP_DEEP
101 overlap = OVERLAP_EXTENDED
102 await self.
hasshass.async_add_executor_job(
103 self.
vacuumvacuum.set_preference,
"rankOverlap", overlap
105 await self.
hasshass.async_add_executor_job(
106 self.
vacuumvacuum.set_preference,
108 {
"disposable": spray,
"reusable": spray},
113 """Return the state attributes of the device."""
114 state_attrs = super().extra_state_attributes
118 detected_pad = state.get(
"detectedPad")
119 mop_ready = state.get(
"mopReady", {})
120 lid_closed = mop_ready.get(
"lidClosed")
121 tank_present = mop_ready.get(
"tankPresent")
122 tank_level = state.get(
"tankLvl")
123 state_attrs[ATTR_DETECTED_PAD] = detected_pad
124 state_attrs[ATTR_LID_CLOSED] = lid_closed
125 state_attrs[ATTR_TANK_PRESENT] = tank_present
126 state_attrs[ATTR_TANK_LEVEL] = tank_level
def __init__(self, roomba, blid)
def async_set_fan_speed(self, fan_speed, **kwargs)
def extra_state_attributes(self)
web.Response get(self, web.Request request, str config_key)