Xiaomi Mi Air Purifier (Xiaomi Mi IO)

Hi guys,
Found on https://www.openhab.org/addons/bindings/miio/ that you`ve added AirPurifier
[zhimi.airpurifier.ma4] big thanks for that, however can not find out how to make it works. Mine OH operate 2.5.0 binding and link mentioned above state there is some “latest” binding more fresh than 2.5
What is version name and how to update mine?

Hi @skvalex

battery works, previous I use test machine for this binding so I didn’t use VSC to edit items file, there was typo mistake at battery, I just upgrade my operating OH to 2.5 yesterday and it works perfectly.

Thanks for the binding

if your miio installed by PaperUI, uninstall it first, then put the downloaded jar file into

\\OH-IP\openHAB-share\openhab2-addons or /usr/share/openhab2/addons/

glad to hear that it works for you!

Hi there, I’m trying to get this working with my Air Purifier 3, but it looks like even with the latest jar in this thread the responses I get from the Air Purifier are all errors. This is what I’ve got installed:

openhab> bundle:list -s | grep miio
284 │ Active │  80 │ 3.0.0.201912271314      │ org.openhab.binding.miio

…and for sure my token and IP are good, as the info command returns valid data from the Air Purifier 3:

10:59:11.377 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for 076D11CE type: MIIO_INFO, result: {"life":41435,"uid":1593612649,"model":"zhimi.airpurifier.ma4","token":"edited","fw_ver":"2.0.5","mcu_fw_ver":"0022","miio_ver":"0.0.5","hw_ver":"esp32","mmfree":66132,"mac":"edited","wifi_fw_ver":"v3.1.4-56-g8ffb04960","ap":{"ssid":"edited","bssid":"edited","rssi":-39,"primary":6},"netif":{"localIp":"192.168.200.191","mask":"255.255.255.0","gw":"192.168.200.1"}}, fullresponse: {"id":4268,"result":{"life":41435,"uid":1593612649,"model":"zhimi.airpurifier.ma4","token":"edited","fw_ver":"2.0.5","mcu_fw_ver":"0022","miio_ver":"0.0.5","hw_ver":"esp32","mmfree":66132,"mac":"edited","wifi_fw_ver":"v3.1.4-56-g8ffb04960","ap":{"ssid":"casagrande","bssid":"edited","rssi":-39,"primary":6},"netif":{"localIp":"192.168.200.191","mask":"255.255.255.0","gw":"192.168.200.1"}}}

… but getting status info or sending commands is returning always errors like these:

11:11:10.156 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":4370,"method":"get_prop","params":["motor1_speed","filter1_life","favorite_level","temp_dec","purify_volume"]} -> 192.168.200.191 (Device: 076D11CE token: EDITED Queue: 2)
11:11:10.156 [DEBUG] [rnal.transport.MiIoAsyncCommunication] - Sending Ping 076D11CE (192.168.200.191)
11:11:10.356 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Received response for 076D11CE type: GET_PROPERTY, result: null, fullresponse: {"id":4368,"error":{"code":-5001,"message":"command error"}}
11:11:10.356 [DEBUG] [.internal.handler.MiIoAbstractHandler] - Error received: {"code":-5001,"message":"command error"}

is there anything else I have to do to get the zhimi.airpurifier.ma4 supported? It looks like it is still using the old Miio API, altough the docs for the latest version of the binding say it is supported (new Miiot API?)
Thank you!

Looks like it’s using MioT protocol which isn’t supported by the binding yet

Indeed it looks like that.Dunno if in older firmware it was responding to miio commands. (I’m normally only adding things to the database if someone reports it is working)

There is no support for the new miot protocol.
I had a look at it but this will not be a very simple task to implement. Also I don’t have a device that knows this making development & test close to impossible.

Maybe someone with such a device can make a PR for such a protocol. Using some of the code from the basic handler and replacing the database part with the online files from the miiot specification.
There is actually a chance that with creating a well formatted database file with the current binding it works. (there is a pr in progress that allows you to use local database files, then you can easily experiment)

In the mean time you might be able to control it to some extend using the command channel and send the commands.

well, it looks like there’s some development (in python) that actually supports miot here:
https://github.com/rytilahti/python-miio/pull/585
as @604435 already posted in this topic. I have to say I cloned their repository and have not been able to make it work (as of yet). Looks like any new Mi devices will follow suit using the new miot protocol, so hopefully someone with better programming skills than me will make the PR with the needed support for the binding soon… anyone? :slight_smile:

1 Like

I have a Mi Air Purifier 3H which shows with a zhimi.airpurifier.mb3 model id. After adding the token I can see basic device info but the thing listing is showing unsupported Xiaomi Mi Device and I can only see power, execute command and test command bindings. Do I need to do anything special to get this to work? Any help would be great - thanks.

@butterchops indeed Mi Air Purifier 3H is unsupported and may require some more significant development to get (proper) supported. The protocol this device implements is not the miio, but instead miot.

You are able to control it with the binding by sending custom commands (communication protocol & encryption is working). If you read back in this topic there is some more around this type. Also check the PR for the python-miio binding

If you have the commands that are working, please share them here, than we can evaluate whether that can be done with the current miio:basic handler

Marcel, thank you for binding.
But need your help if possible.
Bought Xiaomi Smartmi Zhimi Air Humidifier 2 - and it was found as Unsupported Xiaomi device with device mode string zhimi.humidifier.cb1
As I got from manual, this kind of mode (.cb1) isn’t support by binding.
So humidifier was added again as Xiaomi Mi Basic Device with string zhimi.humidifier.ca1
It helps, channels present now and works well.
Except temperature - it still “-NaN”.
Could you please advise where I can check more for start getting temperature data?
Thank you.

1 Like

Hi Mikhail,

I think you should start by sniffing protocol calls from Mi Home app. If you have Android, then the easiest way is to install Vevs mod apk (google for “xiaomi home vevs”) and see what Mi Home actually sends and receives from the device. Don’t forget to grant permission to external storage to the app. Logs are gonna be in /sdcard/vevs/logs named like “127921934.txt”. Share the logs, so we can create correct database file for your device. But make sure to keep devices.txt to yourself as it contains tokens, device ids and mac addresses.

3 Likes

@Mikhail as @skvalex indicates one of the best ways is indeed to use the Vevs mod apk.
The alternative is to decompile the mihome addin for your device and see what commands are specified in there. Depending on your (programming / java) skills the 1st or the 2nd option is easier.

2 Likes

Thank you for your replies.
Yes, sure, I know Vevs app and used it for getting token id.
But unfortunately I’m not familiar with Android system.
@skvalex, could you please advice where can find logs if app installed on device memory, not sdcard?
For now I took temp & humidity data from separate sensor.

@Mikhail In Android /sdcard refers to internal memory. If folder does not exist, you may need to create it using any file manager: /sdcard/vevs/logs or via command line: mkdir -p /sdcard/vevs/logs/. After that, force stop Mi Home app or reboot device.

Screenshot from Solid Explorer

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: