1
1
"""Support for Weback Vacuum Robots."""
2
+
2
3
import logging
3
4
4
- import homeassistant .helpers .config_validation as cv
5
- import voluptuous as vol
6
5
from homeassistant .components .vacuum import (
7
6
STATE_CLEANING ,
8
7
STATE_DOCKED ,
13
12
StateVacuumEntity ,
14
13
VacuumEntityFeature ,
15
14
)
16
- from homeassistant .helpers import entity_platform
17
15
from homeassistant .helpers .icon import icon_for_battery_level
18
16
19
17
from . import DOMAIN , VacDevice
@@ -118,8 +116,9 @@ def state(self):
118
116
_LOGGER .debug ("Vacuum: state(from mapping)=%s" , state_mapping )
119
117
return state_mapping
120
118
except KeyError :
121
- _LOGGER .error (
122
- "Found an unsupported state, state_code: %s" , self .device .current_mode
119
+ _LOGGER .exception (
120
+ "Found an unsupported state, state_code: %s" ,
121
+ self .device .current_mode ,
123
122
)
124
123
return None
125
124
@@ -137,7 +136,8 @@ def battery_icon(self):
137
136
self .is_charging ,
138
137
)
139
138
return icon_for_battery_level (
140
- battery_level = self .battery_level , charging = self .is_charging
139
+ battery_level = self .battery_level ,
140
+ charging = self .is_charging ,
141
141
)
142
142
143
143
@property
@@ -158,18 +158,23 @@ def fan_speed(self):
158
158
159
159
@property
160
160
def fan_speed_list (self ):
161
- """Get the list of available fan speed or /water level steps of the vacuum cleaner."""
161
+ """
162
+ Get the list of available fan speed or
163
+ water level steps of the vacuum cleaner
164
+ """
162
165
# Check if robot is in Vacuum/Mop mode
163
166
if self .device .vacuum_or_mop == 1 :
164
167
# Vacuum mode
165
168
_LOGGER .debug (
166
- "Vacuum: (vacuum mode) fan_speed_list=%s" , self .device .fan_speed_list
169
+ "Vacuum: (vacuum mode) fan_speed_list=%s" ,
170
+ self .device .fan_speed_list ,
167
171
)
168
172
return self .device .fan_speed_list
169
173
if self .device .vacuum_or_mop == 2 :
170
174
# Mop mode
171
175
_LOGGER .debug (
172
- "Vacuum: (mop mode) fan_speed_list=%s" , self .device .mop_level_list
176
+ "Vacuum: (mop mode) fan_speed_list=%s" ,
177
+ self .device .mop_level_list ,
173
178
)
174
179
return self .device .mop_level_list
175
180
# No Mop / No Fan
@@ -202,10 +207,7 @@ def is_charging(self):
202
207
def extra_state_attributes (self ) -> dict :
203
208
"""Return the device-specific state attributes of this vacuum."""
204
209
205
- if self .device .vacuum_or_mop == 1 :
206
- mode = "vacuum"
207
- else :
208
- mode = "mop"
210
+ mode = "vacuum" if self .device .vacuum_or_mop == 1 else "mop"
209
211
210
212
extra_value = {
211
213
"robot_mode" : mode ,
@@ -247,7 +249,8 @@ def on_error(self, error):
247
249
self ._error = error
248
250
_LOGGER .debug ("Vacuum: on_error=%s" , self ._error )
249
251
self .hass .bus .fire (
250
- "weback_vacuum" , {"entity_id" : self .entity_id , "error" : error }
252
+ "weback_vacuum" ,
253
+ {"entity_id" : self .entity_id , "error" : error },
251
254
)
252
255
self .schedule_update_ha_state (False )
253
256
@@ -284,7 +287,6 @@ async def async_locate(self, **kwargs) -> None:
284
287
"""Locate the vacuum cleaner."""
285
288
_LOGGER .debug ("Vacuum: locate" )
286
289
await self .device .locate ()
287
- return
288
290
289
291
async def async_set_fan_speed (self , fan_speed , ** kwargs ):
290
292
"""Set fan speed"""
0 commit comments