Skip to content

Commit

Permalink
vacuum: add check value to set_volume
Browse files Browse the repository at this point in the history
  • Loading branch information
st7105 committed May 17, 2023
1 parent d527098 commit 65a3783
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions miio/integrations/dreame/vacuum/dreamevacuum_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ def status(self) -> DreameVacuumStatus:
MANUAL_DISTANCE_MAX = 300
MANUAL_DISTANCE_MIN = -300

VOLUME_MIN = 0
VOLUME_MAX = 100

@command()
def start(self) -> None:
"""Start cleaning."""
Expand Down Expand Up @@ -593,6 +596,20 @@ def set_fan_speed(self, speed: int):
click.echo(f"Setting fanspeed to {fanspeed.name}")
return self.set_property("cleaning_mode", fanspeed.value)

@command(click.argument("volume", type=int))
def set_volume(self, volume: int):
"""Set volume.
:param int volume: Volume to set
"""
if volume < self.VOLUME_MIN or volume > self.VOLUME_MAX:
raise ValueError(
"Given volume is invalid, should be [%s, %s], was: %s"
% (self.VOLUME_MIN, self.VOLUME_MAX, volume)
)
click.echo(f"Setting volume to {volume}")
return self.set_property("volume", volume)

@command()
def fan_speed_presets(self) -> Dict[str, int]:
"""Return available fan speed presets."""
Expand Down

0 comments on commit 65a3783

Please sign in to comment.