Skip to content

Commit

Permalink
make vacuum robot wifi settings configurable via CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
infinitydev committed Oct 28, 2017
1 parent e9d55e3 commit cacf862
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ $ mirobo home
Requesting return to home: 0
```

### Configure wifi settings (WPA2)

```
$ mirobo configure_wifi "My SSID" "My Wifi password"
Configuring wifi to SSID: My SSID
OK
```

It may take a few minutes before the robot responds to commands after it connected to the
wifi network, especially if you block its internet access.

### Setting the fanspeed

```
Expand Down
4 changes: 4 additions & 0 deletions miio/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ def set_timezone(self, new_zone):
"""Set the timezone."""
return self.send("set_timezone", [new_zone])[0] == 'ok'

def configure_wifi(self, ssid, password, uid=0):
"""Configure the wifi settings."""
return self.send("miIO.config_router", { "ssid": ssid, "passwd": password, "uid": uid })[0]

def raw_command(self, cmd, params):
"""Send a raw command to the robot."""
return self.send(cmd, params)
12 changes: 12 additions & 0 deletions miio/vacuum_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,18 @@ def timezone(vac: miio.Vacuum, tz=None):
click.echo("Timezone: %s" % vac.timezone())


@cli.command()
@click.argument('ssid', required=True)
@click.argument('password', required=True)
@click.argument('uid', type=int, required=False)
@pass_dev
def configure_wifi(vac: miio.Vacuum, ssid: str,
password: str, uid: int):
"""Configure the wifi settings."""
click.echo("Configuring wifi to SSID: %s" % ssid)
click.echo(vac.configure_wifi(ssid, password, uid))


@cli.command()
@click.argument('cmd', required=True)
@click.argument('parameters', required=False)
Expand Down

0 comments on commit cacf862

Please sign in to comment.