Improve Vacuum Entity (#35554)

This commit is contained in:
Xiaonan Shen 2020-05-25 17:56:12 -07:00 committed by GitHub
parent e61280095e
commit 7e67b6b568
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 86 deletions

View file

@ -126,31 +126,21 @@ class DemoVacuum(VacuumEntity):
@property
def status(self):
"""Return the status of the vacuum."""
if self.supported_features & SUPPORT_STATUS == 0:
return
return self._status
@property
def fan_speed(self):
"""Return the status of the vacuum."""
if self.supported_features & SUPPORT_FAN_SPEED == 0:
return
return self._fan_speed
@property
def fan_speed_list(self):
"""Return the status of the vacuum."""
assert self.supported_features & SUPPORT_FAN_SPEED != 0
return FAN_SPEEDS
@property
def battery_level(self):
"""Return the status of the vacuum."""
if self.supported_features & SUPPORT_BATTERY == 0:
return
return max(0, min(100, self._battery_level))
@property
@ -289,24 +279,16 @@ class StateDemoVacuum(StateVacuumEntity):
@property
def battery_level(self):
"""Return the current battery level of the vacuum."""
if self.supported_features & SUPPORT_BATTERY == 0:
return
return max(0, min(100, self._battery_level))
@property
def fan_speed(self):
"""Return the current fan speed of the vacuum."""
if self.supported_features & SUPPORT_FAN_SPEED == 0:
return
return self._fan_speed
@property
def fan_speed_list(self):
"""Return the list of supported fan speeds."""
if self.supported_features & SUPPORT_FAN_SPEED == 0:
return
return FAN_SPEEDS
@property