Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions miio/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,12 @@ def sound_volume(self) -> int:
return self.send("get_sound_volume")[0]

def set_sound_volume(self, vol: int):
"""Set sound volume."""
raise NotImplementedError("unknown command&parameters")
"""Set sound volume [0-100]."""
return self.send("change_sound_volume", [vol])

def test_sound_volume(self):
"""Test current sound volume."""
return self.send("test_sound_volume")

def serial_number(self):
"""Get serial number."""
Expand Down
13 changes: 10 additions & 3 deletions miio/vacuum_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,16 @@ def cleaning_history(vac: miio.Vacuum):


@cli.command()
@pass_dev
def sound(vac: miio.Vacuum):
"""Query sound settings."""
@click.argument('volume', type=int, required=False)
@click.option('--test', 'test_mode', is_flag=True, help="play a test tune")
@pass_dev
def sound(vac: miio.Vacuum, volume: int, test_mode: bool):
"""Query and change sound settings."""
if volume is not None:
click.echo("Setting sound volume to %s" % volume)
vac.set_sound_volume(volume)
if test_mode:
vac.test_sound_volume()
click.echo("Current sound: %s" % vac.sound_info())
click.echo("Current volume: %s" % vac.sound_volume())
click.echo("Install progress: %s" % vac.sound_install_progress())
Expand Down