Python miio token
Bases: miio. Bases: object. Bases: enum. Return favorite level, which is used if the mode is favorite. Environment illuminance level in lux . Sensor value is updated only when device is turned on. Positive response chuangmi. Negative response chuangmi.
Bases: construct. Example values: 29, e0b23e0be. Base class for all device implementations. This is the main class providing the basic protocol handling for devices using the miIO protocol. This class should not be initialized directly but a device-specific class inheriting it should be used instead of it.
Get miIO protocol information from the device. This includes information about connected wlan network, and hardware and software versions. Send a raw command to the device. This is mostly useful when trying out commands which are not implemented by a given device instance.
Container of miIO device information. Hardware properties such as device model, MAC address, memory information, and hardware and software information is contained here. Create a corresponding Device implementation for a given info and address.The easiest way to install the package is to use pip: pip3 install python-miio. Using virtualenv is recommended. Please make sure you have libffi and openssl headers installed, you can do this on Debian-based systems like Rasperry Pi with.
Depending on your installation, the setuptools version may be too old for some dependencies so before reporting an issue please try to update the setuptools package with. In case you get an error similar like ImportError: No module named 'packaging' during the installation, you need to upgrade pip and setuptools:. Devices already connected on the same network where the command-line tool is run are automatically detected when mirobo discover is invoked.
To be able to communicate with devices their IP address and a device-specific encryption token must be known. If the returned a token is with characters other than 0 s or f s, it is likely a valid token which can be used directly for communication.
If not, the token needs to be extracted from the Mi Home Application, see Tokens from Mi Home logs for information how to do this. For some devices e. This does not work starting from firmware version 3.
Some devices also do not announce themselves via mDNS e. See Discovery by a handshake for more information about the topic. The devices supporting miIO protocol answer to a broadcasted handshake packet, which also sometime contain the required token. Executing mirobo discover with --handshake 1 option will send a broadcast handshake. Devices supporting the protocol will response with a message potentially containing a valid token.
This method can also be useful for devices not yet connected to any network. In those cases the device trying to do the discovery has to connect to the network advertised by the corresponding device e. Tokens full of 0 s or f s as above are either already paired with the mobile app or will not yield a token through this method. In those cases the procedure shown in Tokens from Mi Home logs has to be used. The easiest way to obtain tokens is to browse through log files of the Mi Home app version 5.
It seems that version was released with debug messages turned on by mistake. An APK file with the old version can be easily found using one of the popular web search engines. When finished, use Google Play to get the most recent version back. Extracting tokens from a Mi Home backup is the preferred way to obtain tokens if they cannot be looked up in the Mi Home app version 5.
For this to work the devices have to be added to the app beforehand before the database or backup is extracted. The first step to do this is to extract a backup or database from the Mi Home app. The procedure is briefly described below, but you may find the following links also useful:.
Start by installing the newest version of the Mi Home app from Google Play and setting up your account. S or china servers are OK, but the european server is not supported by the old app. Then, set up your Xiaomi device with the Mi Home app.GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Already on GitHub? Sign in to your account. In versions 5. They change something in application.
An investigation is required. Could you check if there's another field which could have the token? Maybe they have done the same or similar as with the iphone app and encrypted it? There is content of miio2. I've installed 5. I've analysed the decompiled code and it seems that the token is no longer being kept locally, but instead it's being downloaded from the server on app opening. This can be observed when opening app after forcefully closing it. Previously, the device would show up immediately in the UI.
Now it takes a moment, probably the app waits for the server response containing a list of devices, which contain tokens amongst other information. For few past days I've been playing around the communication between MiHome app and xiaomi servers. I've captured the traffic using the mitmproxy. The whole communication is using SSL so there's some setup required for the capture to work. In addition to SSL, after the authentication most of the data in requests and responses is additionally encrypted and then encoded in base I already know what encryption algorithm is in use and I've been able to decrypt most of the communication there are still some bits and pieces I'm not sure about.
I can confirm that the token is being received from the server it was even in earlier versions. It seems that tapping into the app's communication may be the only way to retrieve the tokens with versions 5. The issue is that setting up the mitmproxy may to too much for most miio users. I'm thinking about simulating the app in the library: a cli command that would ask a user about the email and password for mi account used in the app and the library would use them to authenticate to xiaomi servers and request the devices list associated with the account.
Interesting findings, and it's very unfortunate that it's being made more difficult to obtain those tokens. I'm wondering whether this change is done in the device specific communication part or in the main app. Can one downgrade the main app and regain the access, or will it be necessary to have an old version of the vacuum plugin available? The problem with such a cli tool would be that it needs to be updated regularly assuming they want to block that way depending on how they are blocking it.
I'm not completely against it though. The change is at the main app level. Downgrades are possible now, but I wonder if they can somehow block it. For example they could make newer versions of plugins compatible only with newer app versions and disable access to older plugin versions for new installations.
Regarding accessing the Xiaomi servers from the library, if the request could be made indistinguishable from those made by the app, then to block it Xiaomi would need to change something in the protocol, which in turn would require a new app version and immediate cut off of all their clients until they upgrade.
But I partially share your concern, that's why I haven't yet disclosed the details of the protocol. Thanks for the link. I've been looking for some information regarding the communication between the device and the servers.At no time should the Roborock be brought into a WiFi before flashing.
Also the Xaomi Mi app should never be used. Everything should remain offline. At the end I will bring the Roborock into my WiFi after flashing. In my case this is a separate WiFi for Smart Home devices, which only allows traffic that is explicitly enabled by the firewall.
Of course the vacuum cleaner robot will not be allowed to connect to the internet. I used an old laptop. This problem is a known problem. Since we later have to access Roborock via a browser, I decided to install Ubuntu Desktop. Alternatively the image can be burned onto a DVD.
[APP] Xiaomi Mi Home (supports Yeelights and Mi Home WiFi devices)
After a few minutes the writing to the USB stick is finished and we can install it on the laptop. Simply insert the USB stick into the laptop. Depending on the model, either a key must be pressed directly after switching on to open the boot menu e. If you have done everything correctly and start from the USB stick, the setup of Ubuntu starts. This is largely self-explanatory, so I will not go into details here. In my case, I used a laptop that already had Windows 7 installed and chose a parallel installation to Windows 7.
When the installation is finished, the system reboots and Ubuntu Desktop appears. Now set up a WiFi connection for an Internet connection. Click on the arrow in the upper right corner, click on the WiFi entry and select the WiFi to connect to and enter the WiFi key. A command line appears. To update Ubuntu, first enter the following commands:.
Download the latest Valetudo files. Download the file:. This is usually the router in home networks. Now we have to connect the laptop to the WiFi of the Roborock.
After a few seconds the LED next to the button will start flashing blue. You have to connect to it. Now we have to disable the firewall. Otherwise Roborock will not be able to download the image. Furthermore, the Roborock should stand in the dock and be charged. Now establish a connection with the Roborock to get the token to the connection:. Now the Roborock is flashed with the custom firmware. This will take a few minutes. The Roborock will let you know when it is ready. The WiFi connection can now be set up here in the setting dialog.
Maybe some of you got one of those fancy vacuum robots while they where on sale? First of all, I used mirobo to control the robot via wifi. I use pimatic rules to control the robot. It will wait for everyone to leave the house and start cleaning, charge again until the battery is full and then shutdown the charger, resulting in a clean home and no energy wasted.
Note your IP and Token. Also block internet access to the robot once discovered. Thanks for sharing! I suppose the charging switch is an add-on Smartplug or alike?! You have done an excellent job. I have now installed Python 3. Can someone help me with this? I cant find a solution via Google. Update: On my 2nd Raspberry with Stretch it works fine but im not able to get the Token. So you have to Root you Cleaner with custom Firmware.
Hey its me agian.
I have now a little problem with the Script from georg90the script works fine in the console but if pimatic runs it as cron. Is it a curl command? You can do curl -s to suppress the message.Login or Sign Up. Forums Shop Downloads. Robot Vacuum Plugin. Posts Latest Activity. Page of 1. Filtered by:.
Previous template Next. Anybody have a plugin for Xiaomi Mi Robot vacuum, been looking across multiple platforms and it seems rather difficult to automate via 3rd party software. Tags: None. January 9th,AM. Originally posted by deanrparry View Post. Comment Post Cancel. January 11th,AM. Jon00 Data Scraper will allow me to grab the data for now. January 11th,PM. January 23rd,PM.
Any pointers? January 24th,AM. Originally posted by rmiles View Post. Actually I wrote a blog post about it shortly after. January 31st,AM. I can control it easy enough it is the status feedback without datascraping i was interested in.
January 31st,PM. Originally posted by panda View Post. I was able to accomplish this by SSH to the location where I hosted the Vacuum Python library using Plink for Windows and then using a script to grab the results and grab the status.
I didn't have to end up using a Data Scraper. I'm moving on to a Linux system and I will probably do the same with Curl and Grep.Toggle navigation. Categories Discussions Activity Sign In. For more information about Homey, visit the Official Homey website.
This forum is now read-only for archive purposes. Closed Official. Stevos Member. November Phuturist I checked the documentation and my MI Purifier 2 meets all the " requirements " to run the different device modes I guess this is what you meant? It's the last three modes low, med, high that don't work. De purifier just doesn't respond when setting it to one of these three modes.Python Tutorial For Beginners - 3 - Tokens In Python
Phuturist Member. Stevos said:. Jerryvdv Member. November edited November Will test tonight Just installed the Mi Home app, I'm unable to add the ceiling light under 'yeelight', which makes sense I suppose. However, is there a different way to add it as the list indicates it could potentially be possible?
Phuturist call me an idiot but where do I enter these command lines? Cmd in windows? Is there an app I must run somewhere? I'll give it a try. It all sounds gibberish to me right now but I'm eager to learn.
Phuturist Tried to install the library within node.