Xiaomi Mi Air Purifier (Xiaomi Mi IO)

Got it with thanks. As I see in log - device returns correct data. App shows temp well.
For making something else I change servers - from US to China (impossible to connect), from China to Russia (connected, but same result in OH).

Anyhow, thanks for your time, seems it’s feature of .cb1 version.

log file

2020-02-02 22:36:27 -> {“id”:2705,“method”:“get_prop”,“params”:[“power”,“mode”,“temperature”,“buzzer”,“led_b”,“child_lock”,“humidity”,“depth”,“dry”,“fahrenheit”]}
2020-02-02 22:36:27 <- {“code”:-5,“message”:“internal exception occurred from device”}
2020-02-02 22:37:41 -> {“id”:2706,“method”:“get_prop”,“params”:[“power”,“mode”,“temperature”,“buzzer”,“led_b”,“child_lock”,“humidity”,“depth”,“dry”,“fahrenheit”]}
2020-02-02 22:37:41 <- {“code”:0,“message”:“ok”,“result”:[“on”,“high”,24.9,“off”,0,“off”,31,125,“on”,76.8],“id”:2706}
2020-02-02 22:47:40 -> {“id”:7731,“method”:“get_prop”,“params”:[“power”,“mode”,“temperature”,“buzzer”,“led_b”,“child_lock”,“humidity”,“depth”,“dry”,“fahrenheit”]}
2020-02-02 22:47:40 <- {“code”:0,“id”:7731,“result”:[“on”,“high”,24.200000,“off”,0,“off”,33,125,“on”,75.600000]}
2020-02-02 22:47:44 -> {“id”:7732,“method”:“set_mode”,“params”:[“auto”]}
2020-02-02 22:47:44 <- {“code”:0,“id”:7732,“result”:[“ok”]}
2020-02-02 22:47:49 -> {“id”:7734,“method”:“set_mode”,“params”:[“silent”]}
2020-02-02 22:47:49 <- {“code”:0,“id”:7734,“result”:[“ok”]}
2020-02-02 22:47:49 -> {“id”:7733,“method”:“set_mode”,“params”:[“silent”]}
2020-02-02 22:47:49 <- {“code”:0,“id”:7733,“result”:[“ok”]}
2020-02-02 22:47:49 -> {“id”:7735,“method”:“set_mode”,“params”:[“medium”]}
2020-02-02 22:47:49 <- {“code”:0,“id”:7735,“result”:[“ok”]}
2020-02-02 22:47:54 -> {“id”:7736,“method”:“set_power”,“params”:[“off”]}
2020-02-02 22:47:54 <- {“code”:0,“id”:7736,“result”:[“ok”]}
2020-02-02 22:47:59 -> {“id”:7737,“method”:“set_power”,“params”:[“on”]}
2020-02-02 22:47:59 <- {“code”:0,“id”:7737,“result”:[“ok”]}
2020-02-02 22:48:02 -> {“id”:7738,“method”:“set_mode”,“params”:[“high”]}
2020-02-02 22:48:02 <- {“code”:0,“id”:7738,“result”:[“ok”]}
2020-02-02 22:54:04 -> {“id”:7524,“method”:“get_prop”,“params”:[“power”,“mode”,“temperature”,“buzzer”,“led_b”,“child_lock”,“humidity”,“depth”,“dry”,“fahrenheit”]}
2020-02-02 22:54:04 <- {“code”:0,“id”:7524,“result”:[“on”,“high”,24,“off”,0,“off”,32,125,“on”,75.100000]}
2020-02-02 22:55:41 -> {“id”:103,“method”:“get_prop”,“params”:[“power”,“mode”,“temperature”,“buzzer”,“led_b”,“child_lock”,“humidity”,“depth”,“dry”,“fahrenheit”]}
2020-02-02 22:55:41 <- {“code”:-2,“error”:{“code”:-2,“message”:“device offline”},“id”:103,“message”:“device offline”,“otlocalts”:1580673342067117}
2020-02-02 22:59:31 -> {“id”:104,“method”:“get_prop”,“params”:[“power”,“mode”,“temperature”,“buzzer”,“led_b”,“child_lock”,“humidity”,“depth”,“dry”,“fahrenheit”]}
2020-02-02 22:59:31 <- {“code”:0,“message”:“ok”,“result”:[“on”,“high”,23.7,“off”,0,“off”,32,103,“on”,74.7],“id”:104}
2020-02-02 23:00:08 -> {“id”:5202,“method”:“get_prop”,“params”:[“power”,“mode”,“temperature”,“buzzer”,“led_b”,“child_lock”,“humidity”,“depth”,“dry”,“fahrenheit”]}
2020-02-02 23:00:08 <- {“code”:0,“message”:“ok”,“result”:[“on”,“high”,23.7,“off”,0,“off”,32,103,“on”,74.7],“id”:5202}

@Mikhail I have added database file for your device and built a .jar. Put it to your openhab addons folder: https://www.openhab.org/docs/installation/linux.html#file-locations

Download: https://drive.google.com/file/d/10GXsW8SIuL6lw5YqjjG06iNNiwoku9yQ/view?usp=sharing

1 Like

@Mikhail please let us know if that .jar worked for you, so I could add the database file to my PR. When it gets accepted, it won’t be needed to use the .jar

1 Like

@skvalex sorry for keep you waiting, I will be able to check today evening only. Will report as soon as possible!

@skvalex I found possibility to check it earlier so you don’t wait. Below that I did and what I get. Please consider - I am noob in OH and Linux.

Placed your .jar file to the /usr/share/openhab2/addons

Followed your link about file locations, read guide where was written that installation through package repository is recommended.

Ok, click deeper read the package-repository-installation guide.

Command: wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add - sudo apt-get install apt-transport-https
System report:
OK

Command: echo 'deb https://dl.bintray.com/openhab/apt-repo2 stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list
System report:

Command: sudo apt-get update
System report:
Hit:1 http://archive.raspberrypi.org/debian buster InRelease
*Ign:2 https://dl.bintray.com/openhab/apt-repo2 stable InRelease *
*Hit:3 http://raspbian.raspberrypi.org/raspbian buster InRelease *
Get:4 https://dl.bintray.com/openhab/apt-repo2 stable Release [6,051 B]
*Fetched 6,051 B in 2s (3,772 B/s) *
Reading package lists… Done

Command: sudo apt-get install openhab2-addons
System report:
Reading package lists… Done
*Building dependency tree *
Reading state information… Done
The following packages were automatically installed and are no longer required:

  • rpi.gpio-common triggerhappy*
    Use ‘sudo apt autoremove’ to remove them.
    The following NEW packages will be installed:
  • openhab2-addons*
    0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
    Need to get 190 MB of archives.
    After this operation, 191 MB of additional disk space will be used.
    Get:1 https://dl.bintray.com/openhab/apt-repo2 stable/main armhf openhab2-addons all 2.5.1-2 [190 MB]
    *Fetched 190 MB in 1min 2s (3,050 kB/s) *
    Selecting previously unselected package openhab2-addons.
    (Reading database … 47794 files and directories currently installed.)
    Preparing to unpack …/openhab2-addons_2.5.1-2_all.deb …
    Unpacking openhab2-addons (2.5.1-2) …
    Setting up openhab2-addons (2.5.1-2) …
    Updating FireMotD available updates count …

After that system stopped answering: ……:8080 shows 404 error, ssh not responses. After reloading device (by unplug power) system become available again, but happened few things:

  • lost HABPanel form start page, although it showed as installed at Add-ons->UI (but isn’t present at Configuration->Services->UI)

  • lost MQTT broker Mosquitto connection

  • Humidifier still doesn’t show temperature

Seems, I made something wrong. :man_facepalming:

Some update - HAPanel appears after clearance the cache

1 Like

@Mikhail I forget to say, that you need to uninstall Xiaomi Mi IO Binding thru Paper UI before putting .jar to addons folder. You don’t need to do anything else.

1 Like

Hey guys,
could anybody help me with my 2S? Tried generating new tokens but it’s still the same :confused:

Thanks!

Is there any way to add zhimi.airpurifier.mc2 (2H) or edit the ones already added so I can pull the filter data out? It only has power and experimental commands as an unsupported device. It should be the same as 2S minus the display.

Hi Denzel,
Pls read https://www.openhab.org/addons/bindings/miio/#thing-configuration

First remove your current device, and (manually) add it back as a miio:basic device and override the model with the details of the 2S. Than you can see if that responds back the values you are looking for. If the required channels are not available you may try other models. to see if that has the

Hi Alex,

tried the jar on my zhimi.airpurifier.mb3 but nothing changed… I see just a “Life” parameter read from the device (a 5 digit number).

His changes are also already in the regular/latest official binding.

The current official binding also now allows you to easily try new database for as you can have them locally on your oh install (no need for jar to add a new device)

In your case, suggest to share the debug log so we can understand the device responses better and advice a solution.

OK, I removed the device, turned on logging and then re-discovered. Also tried an “on/off” command after I added the token.

Thanks

Your device is indeed using a different protocol than the binding is currently supporting. It is so called "miot’ instead of miio.

You can try the following send this to the command channel and see if it is responding to it. (replace the MYDID with your deviceID … you may need to fiddle bit to get the correct string to be send (the #OFF /#ON) are not to be send…

set_properties [{"did":"MYDID","piid":2,"siid":2,"value":true}] #ON
set_properties [{"did":"MYDID","piid":2,"siid":2,"value":false}] #OFF

and e.g.
get_properties [{"did":"MYDID","siid": 3, "piid": 6}]

Don’t exactly know what is expected as myID 1823426819 10212739 or 270608185 (I expect the last one)
Let me know your results, maybe I can make some changes so we can support these miot devices in the future.

Otherwise, you may be able to log some of the communication with the vevs version of the mihome app (as mentioned in one of the above topics). Or python-miio today added support for your device… try there with debug on and see what it is sending… we can always send the same with the command channel

it appears python-miio is sending the command like this… (instead of the device id the property)
So you may want to give that command a try as well.
Note, these commands are to be send to the command channel for your device in openhab (use show more in paperUI to see that channel and enable it)

get_properties[{"did": "power", "siid": 2, "piid": 2}, {"did": "fan_level", "siid": 2, "piid": 4}, {"did": "mode", "siid": 2, "piid": 5}, {"did": "humidity", "siid": 3, "piid": 7}, {"did": "temperature", "siid": 3, "piid": 8}, {"did": "aqi", "siid": 3, "piid": 6}, {"did": "filter_life_remaining", "siid": 4, "piid": 3}, {"did": "filter_hours_used", "siid": 4, "piid": 5}, {"did": "buzzer", "siid": 5, "piid": 1}, {"did": "buzzer_volume", "siid": 5, "piid": 2}, {"did": "led_brightness", "siid": 6, "piid": 1}, {"did": "led", "siid": 6, "piid": 6}, {"did": "child_lock", "siid": 7, "piid": 1}, {"did": "favorite_level", "siid": 10, "piid": 10}, {"did": "favorite_rpm", "siid": 10, "piid": 7}]

So, I tried the first set and it seemed to work.
It turned the appliance ON and OFF (using the last myID, indeed).
On the get command I received the following (this is the log entry):

miio_generic_10212739_actions_commands changed from get_properties [{“did”:“270608185”,“siid”: 3, “piid”: 6}] to {“id”:17,“result”:[{“did”:“270608185”,“siid”:3,“piid”:6,“code”:0,“value”:9}]}

The “value”: 9 seems to match the PM2.5 value.
For piid 7 I seem to get the value of humidity.
For piid 8 I got the temperature (Celsius).

The long get properties command doesn’t seem to work as such. I got a malformed command or something. Was I supposed to replace something in it?

So, the first set of commands seem to lead to some results.

Thanks

cool. Can you try one of the single get commands but putting something else in the did section
Just to understand if it is the long list of gets that is causing the issue or if it is the did part

Funny, it seems it doesn’t matter. I tried other IDs and it still returned the value. Here are two log entries:

miio_generic_10212739_actions_commands changed from get_properties [{“did”:“207608000”,“siid”: 3, “piid”: 6}] to {“id”:591,“result”:[{“did”:“207608000”,“siid”:3,“piid”:6,“code”:0,“value”:19}]}

miio_generic_10212739_actions_commands changed from get_properties [{“did”:“000000”,“siid”: 3, “piid”: 6}] to {“id”:593,“result”:[{“did”:“000000”,“siid”:3,“piid”:6,“code”:0,“value”:21}]}

It even worked with the text you sent (“get_properties [{“did”:“MYDID”,“siid”: 3, “piid”: 6}]”)

I was expecting this a bit looking at the code in python miio. I first thought it was a bug, but they use it to more conveniently recognize the parameter.

I added miot support (your device) to my wishlist. (that is not any promise that support will be there anytime soon :slight_smile: ) Suggest for now to create rules for the most relevant commands so you can control your device

Thanks a lot for your efforts!
I guess this protocol will be used going forward…
If you need any more help troubleshooting or testing, let me know.