Xiaomi Mi Air Purifier (Xiaomi Mi IO)

Hi @marcel_verpaalen

regarding product database, there is few mistake,
with zhimi.airmonitor.v1, usb_state should be string or number

and cgllc.airmonitor.b1 is also wrong, currently only available raw_command is “get_air_data” and “info”
and return value is:

Please kindly have a look and see will this info can help you upate on databse

{'co2e': 1070, 'humidity': 36.79999923706055, 'pm25': 80.30000305175781, 'temperature': 24.600000381469727, 'temperature_unit': 'c', 'tvoc': 4.798298358917236, 'tvoc_unit': 'mg_m3'}

I discover while if I keep polling by “get_air_data”, sometimes will halt, no value return, than poll info will make it resume

Does anyone know why miio keep having item discovery in PaperUI Inbox, the popup items is already add manually by input at xiaomi.things,
Is there anywhere that I have made mistake?

Thing miio:vacuum:012345678 "Mi Robot Vacuum" @ "LivingR" [host="192.168.1.2", model="rockrobo.vacuum.v1", refreshInterval=30.0, deviceId="012345678 ", token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]
Thing miio:basic:012345678 "YeelightS-Kitchen" @ "Terrace" [host="192.168.1.3", model="yeelink.light.strip1",refreshInterval=30.0, deviceId="012345678 ", token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]

This is also a problem for me. Some device shows up in the Inbox every time, even I have added all my Xiaomi devices as things (I think this has nothing to do with things files, because I’m using PaperUI to manage my Things and the problem is there…).

@rkrisi @hamwong Bindings (not just miio) supporting autodiscovery will scan for devices even it configured through text files.
That is the reason for the “Ignore” button in PaperUI. Just hit them for all devices where you have text files configured.

You may try to search the forum for disable discovery if ignoring them won’t work.
To my knowledge the binding itself is not really controlling how this piece is working, it is part of the OH framework.

Like @zsbagyura i own a Mija Smart humidifier with the model String “deerma.humidifier.mjjsq”. I can already control the device via python/miiocli. How can i contribute in order to get the device supported by the miio binding?

I wish to share my experience. My boyfriend is practicing smoking in the house, but I can’t stand the smell of it. Air fresheners couldn’t solve this issue for me. So then I decided to try air purifier - and you know what? It works! If someone here looking an air purifier for similar purposes, check this article - I personally fine with Blueair Blue Pure. This device have only one disadvantage: when you begin using it, it leaves some chemical smell at the start, but later it will be stabilized.

Hi Marcel, thanks for response, reasons for ask here is because other binding don’t have this issue, like yeelight, wemo, orvibo, they all just show once and once things added to OH, it won’t show up again, that’s the place I am curious.

as currently I put all miio and mihome things into thing file,and I remember long time ago with one of the version, I add devices by paperUI and don’t have inbox issue, I am wonder does this issue cause by my config issue

Should not be, but in the past we did see some issues indeed that way. For sure it does not like if the modelid is missing, that is sure creating problems.

My personal way is I add the things in the paperUI, but the items/channels I do with textfile config.
That limits the amounts of clicks & typo’s and still have the advantages of discovery and easy modifying of settings

Hi,

I have zhimi.airpurifier.mb3 (Mi Air Purifier 3/3H). Any chance to add support for this device? As I understood Xiaomi made some changes in protocol. Python-miio implementation:
https://github.com/rytilahti/python-miio/pull/585

I’ve made a PR to a similar device you have, if you wish I can add your device to the database and build a jar so you can check it

Hi @skvalex
sure, I would love to have a test on it, please share the jar with me once available

@hamwong Here it is: https://drive.google.com/open?id=1nnhjuG1kWei7RdLn3CI7pUBoxEdDQd-p

Can you also check the following command:

miio protocol call <DEVICE_IP> get_prop [\"battery\",\"pm25\",\"co2e\",\"tvoc\",\"tvoc_unit\",\"humidity\",\"temperature\",\"temperature_unit\"]

I have download your jar, but haven’t got time to test it yet, by the way, the command you provide won’t work, only 2 valid command is “get_air_data” and “info” , miio only work with get_air_data, info won’t work

miio protocol call 192.168.0.2 get_air_data
 INFO  Attempting to call get_air_data on 192.168.0.2

 INFO  Device found, making call

 INFO  Got result:
{
  "co2e": 9999,
  "humidity": 38.400001525878906,
  "pm25": 79.30000305175781,
  "temperature": 27.299999237060547,
  "temperature_unit": "c",
  "tvoc": 9.99899959564209,
  "tvoc_unit": "mg_m3"
}

P.S. above co2e and tvoc is valid as airmonitor b1 is sensitive to alcohol, this value was affected by Whisky.

But have you checked it explicitly?

miio protocol call 192.168.0.2 get_prop [\"battery\",\"pm25\",\"co2e\",\"tvoc\",\"tvoc_unit\",\"humidity\",\"temperature\",\"temperature_unit\"]

What’s the output from this command? It should be something like this:

INFO  Attempting to call get_prop on 192.168.0.2

 INFO  Device found, making call

 INFO  Got result:
{
  "battery": 100,
  "co2e": 9999,
  "humidity": 38.4,
  "pm25": 79.3,
  "temperature": 27.3,
  "temperature_unit": "c",
  "tvoc": 9.9,
  "tvoc_unit": "mg_m3"
}

it won’t work, this device won’t response any command, only valid command would be

{"method":"miIO.info","params":[],"id":1} +3ms
  thing:miio:213003020 -> (4) {"method":"miIO.info","params":[],"id":101}

<- Message: `{"partner_id":"","id":201,"code":0,"message":"ok","result":{"hw_ver":"Linux","fw_ver":"3.4.4_0087","ap":{"ssid":"xxxxxxx","bssid":"xx:xx:xx:xx:xx:xx"},"netif":{"localIp":"192.168.0.1","mask":"255.255.255.0","gw":"192.168.0.2"},"model":"cgllc.airmonitor.b1","mac":"xx:xx:xx:xx:xx:xx","token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","life":675932}}` +18ms

 {"method":"get_air_data","params":[],"id":202}
 <- Message: `{"result":{"co2e":998,"humidity":36.200000762939453,"pm25":53.599998474121094,"temperature":27.5,"temperature_unit":"c","tvoc":3.0665998458862305,"tvoc_unit":"mg_m3"},"id":202}` +643ms
 INFO  Got result:
{
  "co2e": 998,
  "humidity": 36.20000076293945,
  "pm25": 53.599998474121094,
  "temperature": 27.5,
  "temperature_unit": "c",
  "tvoc": 3.0665998458862305,
  "tvoc_unit": "mg_m3"
}

device won’t response any other command at all, there is 2 reason, 1, miio stop update before this device release, 2, this device is new type devices and thrid-party, they may limit the reponse, command “get_air_data” is from someone who capture packet from ios to device

 miio protocol call 192.168.0.2 get_prop
 INFO  Attempting to call info on 192.168.0.2

 INFO  Device found, making call

 ERROR  Encountered an error while controlling device

Error was:
Call to device timed out

You forgot to add argument. It hangs for me too if there’s no argument or if it’s formatted incorrectly. So please check the exact command from my previous post.

Also, you may check

get_value

method. It doesn’t hang if no argument provided.

as I said before, it won’t response,

  thing:miio:213003020 -> (5) {"method":"get_prop","params":["co2e","humidity"],"id":2} +8ms
  miio:packet -> <Buffer 21 31 00 60 00 00 00 00 0c b2 2b 0c 5e 05 25 89 7c 0c ec 08 1d 3f 2d e7 8b 33 17 1c e0 6e 89 2f> +9ms
  thing:miio:213003020 -> (4) {"method":"get_prop","params":["co2e","humidity"],"id":102} +2s
  miio:packet -> <Buffer 21 31 00 60 00 00 00 00 0c b2 2b 0c 5e 05 25 8b 95 29 21 77 e4 e4 79 09 48 d6 3d 3d 77 e0 e0 68> +2s
  thing:miio:213003020 -> (3) {"method":"get_prop","params":["co2e","humidity"],"id":202} +2s
  miio:packet -> <Buffer 21 31 00 60 00 00 00 00 0c b2 2b 0c 5e 05 25 8d c4 59 e3 c1 b1 88 ab a6 de 4f 99 68 61 9c 46 d1> +2s
  thing:miio:213003020 -> (2) {"method":"get_prop","params":["co2e","humidity"],"id":302} +2s
  miio:packet -> <Buffer 21 31 00 60 00 00 00 00 0c b2 2b 0c 5e 05 25 8f 0e 0c de 90 b0 76 af d4 75 b4 46 f3 47 e4 00 ce> +2s
  thing:miio:213003020 -> (1) {"method":"get_prop","params":["co2e","humidity"],"id":402} +2s
  miio:packet -> <Buffer 21 31 00 60 00 00 00 00 0c b2 2b 0c 5e 05 25 91 31 bf aa 06 0b 8b e4 d4 e0 be b9 cc 1b c7 17 23> +2s
  thing:miio:213003020 -> (0) {"method":"get_prop","params":["co2e","humidity"],"id":502} +2s
  miio:packet -> <Buffer 21 31 00 60 00 00 00 00 0c b2 2b 0c 5e 05 25 93 6a 99 ab ed 76 9e 80 37 4d 44 9f 58 1f e7 81 9f> +2s
 ERROR  Encountered an error while controlling device

Error was:
Call to device timed out

but I was surprise that there is another way to retrieve value and it works
  thing:miio:213003020 -> (5) {"method":"get_value","params":["co2e","humidity","pm25","temperature","temperature_unit","tvoc","tvoc_unit"],"id":2} +8ms
  thing:miio:213003020 <- Message: `{"result":{"co2e":1352,"humidity":41.100000000000001,"pm25":8.3000000000000007,"temperature":24.899999999999999,"temperature_unit":"c","tvoc":5.3120000000000003,"tvoc_unit":"mg_m3"},"id":2}` +527ms
 INFO  Got result:
{
  "co2e": 1352,
  "humidity": 41.1,
  "pm25": 8.3,
  "temperature": 24.9,
  "temperature_unit": "c",
  "tvoc": 5.312,
  "tvoc_unit": "mg_m3"
}

but other than that I don’t found anyway to get valid value except battery, but looks it have to read with all other value, if I only retrieve battery or with only 1-2 value like pm25 and tvoc only, I only get time out, after few more attempts like usb_state, refuse to response anymore and I need to do hard reset on device, I need to get home to perform that.

That’s very strange/interesting indeed. Than your device appears to have a different command to pull the info from the device. “method”:“get_value” vs the commonly used “method”:“get_prop”

Then we should use get_value to get data on our devices. I’ll do the changes and build a jar.

But I have a question to @marcel_verpaalen about implementation: I think it’s better to add another property to “deviceMapping” section, e.g. “propertyMethod” where specify what command to use to refresh properties in sendRefreshProperties:

{
  "deviceMapping": {
    "id": [ ... ],
    "propertyMethod": "get_value",
    "channels": [ ... ]
  }
}

If propertyMethod not set, then use get_prop.

Also, I see there’s hardcoded MAX_PROPERTIES set to 5. I think it also should be configurable in database as it seems some devices work fine with more properties sent at time.