diff --git a/README.md b/README.md index 7597f43a8..a9bdfa5d0 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,22 @@ $ 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. + +The token does not change by configuring wifi. All subsequent commands must be sent to +the IP that the robot obtains via DHCP from your router. + +*Note, that this only works on devices from which you have obtained a token beforehand and therefore rules out e.g. vacuums with firmware 3.3.9_003077 or higher.* Any ideas for extracting the token on newer devices without using the official app and extracting them from the database are appreciated! + ### Setting the fanspeed ``` diff --git a/miio/vacuum.py b/miio/vacuum.py index bd6843596..8abafd9ef 100644 --- a/miio/vacuum.py +++ b/miio/vacuum.py @@ -202,6 +202,11 @@ 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.""" + params = {"ssid": ssid, "passwd": password, "uid": uid} + return self.send("miIO.config_router", params)[0] + def raw_command(self, cmd, params): """Send a raw command to the robot.""" return self.send(cmd, params) diff --git a/miio/vacuum_cli.py b/miio/vacuum_cli.py index e623e1f4f..d73515192 100644 --- a/miio/vacuum_cli.py +++ b/miio/vacuum_cli.py @@ -417,6 +417,17 @@ 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)