-
-
Notifications
You must be signed in to change notification settings - Fork 561
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
Conversation
miio/vacuum_cli.py
Outdated
@click.argument('uid', type=int, required=False) | ||
@pass_dev | ||
def configure_wifi(vac: miio.Vacuum, ssid: str, | ||
password: str, uid: int): |
There was a problem hiding this comment.
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
miio/vacuum.py
Outdated
@@ -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] |
There was a problem hiding this comment.
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 '}'
miio/vacuum_cli.py
Outdated
@click.argument('uid', type=int, required=False) | ||
@pass_dev | ||
def configure_wifi(vac: miio.Vacuum, ssid: str, | ||
password: str, uid: int): |
There was a problem hiding this comment.
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
miio/vacuum.py
Outdated
@@ -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] |
There was a problem hiding this comment.
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 '}'
Did your vacuum indeed function proper. miIO.config_router{“tz”:“Europe/Brussels”,“gmt_offset”:0,“ssid”:“WInternal”,“passwd”:“xxx”} Also, would be good to understand if you can disconnect the Xiaomi cloud (meaning the vacuum no longer needs internet) |
Yes, my vaccum works properly. I never got it to work with the original app. Hence, my robot is running on stock firmware. So, I cannot test on recent firmware unless there is a way to upload a new one without the app. I have completely blocked the robot's internet access in my router to prevent it from talking home. I think that is why it takes a couple of minutes before it responds to commands on the configured wifi network. After connecting my laptop to the robots default wifi, changing wifi settings through this patch and waiting a couple of minutes, I can control the robot with miio and an alternative smartphone app within my LAN. Edit: It also takes a few minutes before it responds after it has been completely powered off with internet access blocked. |
They probably added the timezone setting for the What remains unclear to me what will be used a a token when @infinitydev could you fix those issues as reported by hound? |
The token does not change when configuring wifi. I added a paragraph to the README for clarification. The workflow for configuring my stock robot boiled down to:
|
Ok, thanks! I read at some point that the newer firmware releases will disable obtaining the token with a handshake, leaving this method usable only for earlier versions. I adjusted the README to inform potential users about this caveat. |
I'll merge this now, and add the ability to define a timezone in another PR. Thanks for the PR! 👍 |
This will allow passing the timezone to vacuums running newer firmware versions, as mentioned in PR #105
This will allow passing the timezone to vacuums running newer firmware versions, as mentioned in PR #105
* Add the ability to define a timezone for configure_wifi This will allow passing the timezone to vacuums running newer firmware versions, as mentioned in PR #105 * add pytz to requirements
These changes allow you to configure the wifi of the Xiaomi vacuum cleaner without needing the Mi Home smartphone app.
It is now effectively possible to use python-miio with the robot in your home wifi network without a Xiaomi account and their app.
Reference:
https://github.com/OpenMiHome/mihome-binary-protocol/blob/master/doc/PROTOCOL.md#payloads
The document mentions that the 'id' field must be a Unix timestamp. This seems to be nonsense. Works perfectly fine with the sequential id. I assumed that it might be used to set the clock of the rebot, but it is not. (It uses NTP.)
I am not sure what the 'uid' field is. Probably the Xiaomi account id that allows them to connect your robot to your account. This should be pretty useless if you don't set the robot up with their app. Hence, I made it an optional parameter.