Xiaomi Mi Air Purifier (Xiaomi Mi IO)

hi Marcel,

I’m getting an error with the FilterUsedTime channel for a 3H purifier, and the filterlife channel for a 2S purifier.

If I include that channel the items file seems to load without error, but when trying to access the group for that purifier with the app or a webbrowser, it won’t load the group when that channel is included.

I don’t think this problem existed when I first set up these purifiers.

Any ideas?

thanks.

1 Like

He guys, I am trying to integrate my Xiaomi Air Purifiers into openHAB and was able to do so for my 2S version, whereas my new Pro H seems not to work.
I tried it with zhimi.airpurifier.v7, zhimi.airpurifier.v6 and also zhimi.airpurifier.mc1.
The binding identifies the purifier as “unsupported” device with the ID zhimi.airpurifier.vb2.
I also tried to use the unsupported device methodology of a “switch” which then tries to identify the available channels, whereas all of them showed a command error.
Did anyone successfully integrate a Pro H variant yet?

@chris this is a so-called miot device, hence the ‘switch’ did not provide much.
I made a file for you to try to use locally. Can you share a log after you try, so we can understand which channels work (see binding readme for more info on how/where to use this file etc)
zhimi.airpurifier.vb2-miot.json (23.5 KB)

There are also 2 actions that I dunno what is they do, maybe you can try as well.

`action{"did":"button-toggle","siid":8,"aiid":1,"in":[]}`
`action{"did":"button-toggle-mode","siid":8,"aiid":2,"in":[]}`

Thanks a lot Marcel!
Quick one, I tried to identify the location of the database folder, whereas somehow I cannot find it on my drives. During binding restart, the DEBUG log shows me only /database/zhimi.airourifier.m1.json for instance and tokens supposedly are saved in /var/lib/openhab/miio.
I tried the var/lib directory but it does not include any db files, any hint?

you need to find your config folder (where are also the thing files, items etc).
Normally this would also have a ‘misc’ folder. In the misc folder, create a folder miio yourself. (so the folder is [your OH config folder]/misc/miio)
In that newly created folder you drop the json file.

You may need to restart the binding in order for it to pick up the location correctly.

1 Like

Perfect, had to create the misc folder as well but it seems that the binding found the db file.
Getting attached errors in the debug log though when trying a simple power on/off switch.

what version of OH you are running? Looks like the version < OH3.0 right?
In that case, indeed that file may not work as it was not yet able to create the channels.

The solution would be to upgrade to OH3 or add a ‘channelType’ to each channel. There is a good chance that if you add a channel type with the same name as the channel it already exists. (e.g. for aqi channel, you would add a line "channelType": "aqi",

I am running OH3, latest release.
With channel type you mean adjust the json?

-edit: All the Pro H channels should have unique IDs though. Should I try to re-create the Thing?
-edit2: After re-creating, following error message and I get not really any channels displayed as well:

Well - I’ll have to show my ignorance and ask what a “miot” device is?

ok, I made progress.
I adjusted your json file (attached), by removing the 2.5 in the channel area.
zhimi.airpurifier.vb2-miot.json (23.5 KB)

I am now able to add the thing and control on/off, will try other channels alter.

It is the ‘new’ communication method of Xiaomi devices.
Where the most existing devices have like get_properties and set_power, set_temperature etc so different commands for each feature, the miot devices instead identify the commands with numeric id’s.

These miot id’s can be found online, e.g. for your device it is here http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-vb2:1

somewhere in the future I aim to have in the unsupported driver a switch to automatcially create db files for miot devices, similar as there is now for the ‘legacy communication’ devices

I see, the problem is indeed that the . in the channel name is the issue. Did not notice that before

1 Like

Got it working for most standard and useful channels now: power, mode, LED, Humidity, LED light brightness, AQI state, Average AQI, AQI and Temperature

Will test the more obscure channels once I got a bit more time.

So is this not using ZigBee anymore then? Or is this “new communications” just between the hub and “user” rather than the hub and the device? I’m just trying to understand if this makes any difference because -:

ZigBee doesn’t use such names - attributes always have numbers, so I guess this is only relating to the “user” side if someone was interfacing to the hub, and not if someone is interfacing to the device via ZigBee?

Dunno if zigbee is re-using this, maybe indeed, that would make sense and simplify for Xiaomi.
However, what I was refering to was the communication from your phone to the device or cloud.

btw, when you are trying your channels, there is a good chance the channels with "siid": 1 in it will not work. At least many devices have these in the spec, but don’t actually respond to them.

Marcel,
I am upgrading my OH to version 3 and now using Build #2154.
Today Mi Air Purifier 3 “zhimi.airpurifier.ma4” was discovered, but after adding it as a thing no channels added and log shows this error:

2021-01-20 15:42:23.280 [WARN ] [io.internal.handler.MiIoBasicHandler] - Error creating channel structure
java.lang.IllegalArgumentException: ID segment ‘ZHIMI_AIRPURIFIER_MA4_pm2.5-density’ contains invalid characters. Each segment of the ID must match the pattern [\w-]*.

at org.openhab.core.common.AbstractUID.validateSegment(AbstractUID.java:98) ~[bundleFile:?]
at org.openhab.core.common.AbstractUID.<init>(AbstractUID.java:76) ~[bundleFile:?]
at org.openhab.core.common.AbstractUID.<init>(AbstractUID.java:59) ~[bundleFile:?]
at org.openhab.core.thing.UID.<init>(UID.java:57) ~[bundleFile:?]
at org.openhab.core.thing.type.ChannelTypeUID.<init>(ChannelTypeUID.java:52) ~[bundleFile:?]

at org.openhab.binding.miio.internal.basic.BasicChannelTypeProvider.addChannelType(BasicChannelTypeProvider.java:64) ~[bundleFile:?]
at org.openhab.binding.miio.internal.handler.MiIoBasicHandler.buildChannelStructure(MiIoBasicHandler.java:425) [bundleFile:?]
at org.openhab.binding.miio.internal.handler.MiIoBasicHandler.checkChannelStructure(MiIoBasicHandler.java:371) [bundleFile:?]
at org.openhab.binding.miio.internal.handler.MiIoBasicHandler.updateData(MiIoBasicHandler.java:301) [bundleFile:?]
at org.openhab.binding.miio.internal.handler.MiIoAbstractHandler.lambda$2(MiIoAbstractHandler.java:154) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]s

At same time it’s working now on OH 2.5.11 (I have it on another RPI)

Any help would be appreciated.
Thanks,
Igor

any infos if zhimi.airpurifier.mb4 (Mi Air Purifier 3C) will be supportet in the next release?

@ip-ua that bug has recently been fixed. I don’t know the build numbers, but if you pull the latest I expect this is resolved. Alternatively, you could just download the json file for your device from github and save it in the conf/misc/miio folder (see readme for details)

As you say it was working before, maybe the restriction on channel names is new in OH3. Anyway, the issue relates to the hyphen in the channel name, removing that is solving the issue.

@mpuff
it is not in, but if you are willing to test it, I can add it

1 Like

of course I can test it

See here the PR. If you can please test the json file for your device and share a debug log of the refresh and feedback the results (which channels work, which not) . See the binding readme oh how to add the json file to your system.