Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make vacuum robot wifi settings configurable via CLI #105

Merged
merged 4 commits into from
Oct 29, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace after '{'
line too long (99 > 79 characters)
whitespace before '}'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace after '{'
line too long (99 > 79 characters)
whitespace before '}'


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):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent

"""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