Skip to content

Commit

Permalink
Add ability to change the volume (#162)
Browse files Browse the repository at this point in the history
mirobo sound shows current settings
mirobo sound <volume> changes volume, where volume is 0-100
passing --test will give a test voice from the vacuum for testing sound levels

Fixes #159
  • Loading branch information
rytilahti committed Jan 20, 2018
1 parent f5f4bbe commit c7d9a67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
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

0 comments on commit c7d9a67

Please sign in to comment.