I’m a big fan of Xiaomi products… Recently I bought the Xiaomi Robot vacuum.
This vacuum can be controlled via openhab using the miio binding.
The miio binding utilises the Mi IO protocol/encryption to communicate with the devices.
This is not using the cloud, it is communicating directly to the devices.
Token
To have a working binding, a little difficult step needs to be done to retrieve the vacuum token.
The easiest way to obtain tokens is to browse through log files of the Mi Home app version 5.4.49 for Android. 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. After downgrading use a file browser to navigate to directory SmartHome/logs/plug_DeviceManager
, then open the most recent file and search for the token. When finished, use Google Play to get the most recent version back.
3 March 2020: You can also use the experimental version of the binding to get the tokens in an easy way see this post
The binding is is mainly supporting the first version of the rockrobo vacuum, but is also (mostly) usable for newer models as well. Main functionality, like getting the status, switching it on & off etc are working.
Sending custom commands
To send custom commands, enable the cmd channel in paperUI (using the ‘show more’ in the channel list as it is a channel marked as advanced) and link a String item to the channel.
You can than send the command to the created string item. It will send the command to the Xiaomi device and update the channel with the response.
Commands for the vacuum are described here https://github.com/marcelrv/XiaomiRobotVacuumProtocol
Note that the binding takes care of parts of the increasing the id and the 'making a json message, e.g to send {'method': 'set_custom_mode', 'params': [40],'id': 17694}
to the device, send set_custom_mode [40]
to the cmd channel.
Item files
Example item files and channels for each device are now in the readme file
Note, unfortunately the maps that are displayed in the app are not directly coming from the vacuum, instead they are coming from the Xiaomi cloud. Much more discovery is needed to find out exactly how to connect to the Xiaomi cloud and get this details.
note that direct cleaning map display is possible using dustcloud with hacked firmware
3 march 2020: You can now get the map with the experimental version that has the cloud connectivity. See this post
Known issues
- Yeelights dimming will not trigger on/off. It purely reports what the device is returning as value.
If you have issues, please include your firmware version (can be seen in mihome app) and the log. Depending on the issue this may be the debug or the trace log.
log:set debug org.openhab.binding.miio
log:display org.openhab.binding.miio
If the binding works for you let us know as well
New / Unsupported devices
If your device is reported as unsupported, you can experiment with using the definition of similar devices. In that case, (manually) add it as a miio:basic device, try to find similar model and override the modelId with the one from the similar device (see binding readme for all devices).
If you find a file that works well for your device, please share your findings (preferably make a new issue on github with the details of the device and which modelId it works with so it can be added)
Note: for discussion around Air purifiers check topic : Xiaomi Mi Air Purifier (Xiaomi Mi IO)