Xiaomi Mi Air Purifier (Xiaomi Mi IO)

It should be water level in %. 0% is equal to empty tank.

well I had a value over 100 after I filled it max… that made me think its not percent :-S
I will try again

Hello to all contributors from this fantastic forum. I’m thinking to buy the following humidifier https://www.youtube.com/watch?v=oIlfdMMO0gc&feature=share that seems an evolution of the previous model that didn’t have a display. Now, is this model supported by the actual bindings available on the latest version of OH?
Thanks in advance and any comment or answer is more than welcome.

I keep getting this error in my log:
2020-05-17 07:30:57.435 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler MiIoBasicHandler tried updating the thing status although the handler was already disposed.

And my 2S air purifier is always seen as offline.
I configured the 2S from a discovery on Paper UI. But I noticed the the Device ID on discovery is different from what is in my mi home. When I change the device id to that of my mi home, it gives an error
I cannot figure out the problem

Hi! First, thanks for a great binding, bought myself an Air Purifier 2H and the binding works in making general control of the machine. One question though, I sometimes set the machine to manual and increase the speed a bit when no one is home and would of course like to automate that. However, when I try to set the speed, the only thing that happens is that I get

[io.internal.handler.MiIoBasicHandler] - Locating action for channel motorspeed: 70
but the speed never changes.

Is it possible to change the fan speed from OpenHAB?

br
/edward

@John_Galt that probaly means the channel details for that is not correct.
Does it show the speed level when you are not updating it?

Do you have any idea if python-miio has this possibility? (if yes, we can easy see what is send).
Otherwise we would need to try to log what the app is sending which is somewhat cumbersome.

Hi!
thanks for your answer. What I can see is that a slider, if setup in a sitemap, will follow the speed of the fan but when I change it will just revert to the set value, so to answer your question, I can see the speed but not alter it.

Been trying to setup python-miio but have an eleven month old daughter next to me who disagrees. will try in the coming days but if that doesn’t work, whats the next step? Capture traffic on the phone?

Hi again!
Finally got it working and can verify that the speed setting works with python-miio, how can I see what is sent?

Found one more thing, not sure if it is of interest or not but when I finally figured out how to use pyton-miio, I saw that the purifier I have is said to be : Model: zhimi.airpurifier.mc2
Apart from that, all I can see then is that I can set a speed from 1-10, not a direct fan speed. Any more info you need, just tell me and I shall seek.

great.

I think you can run python-miio with debug, than you can see what it is sending as command.
For OH, did you override the model in the config? What did you put in?

Hi Marcel!

Once I posted all below I suddenly realised that there is one setting in python-mioo for speed, and a number for fanspeed, and then I also saw the channel “Favorite level” which i assume is the one I was looking for… so by just answering your questions I answered mine since I then assume that there is no way to set the exact fanspeed.

Thanks for prompt answers and all help


Lets see here, I’ll give you as much as I can figure out, hope some will help :slight_smile:
PaperUI says the following:

Xiaomi Mi Device xxxxxxxx (xxxxxxxxx) zhimi-airpurifier-mc2_miioxxxxxxxxx
Unsupported Xiaomi Mi Device

In my things-file i have:

Thing miio:basic:purifier “Purifier” [ host=“xxx.xxx.xxx.xxx”, deviceId=“xxxxxxxx”,token=“xxxxxxxxxxxxxxxxxxxxxxxxx”, model=“zhimi.airpurifier.mc1” ]

and that seems to work apart from setting the speed.

My speed-settings in OH goes from around 300 at the lowest to approx 2200 as the highest value.

Finally, if I set the speed manuallt from python-miio:

~/.local/bin$ ./miiocli -d airpurifier --ip xxx.xxx.xxx.xxx --token xxxxxxxxxxxxxxxxxxxxxxxxx set_favorite_level 1
INFO:miio.cli:Debug mode active
Setting favorite level to 1
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b’’
DEBUG:miio.miioprotocol:Got a response: Container:
data = Container:
data = b’’ (total 0)
value = b’’ (total 0)
offset1 = 32
offset2 = 32
length = 0
header = Container:
data = b"!1\x00 \x00\x00\x00\x00\x12\xa8’\xcc\x00\x00i\x88" (total 16)
value = Container:
length = 32
unknown = 0
device_id = unhexlify(‘xxxxxxxx’)
ts = 1970-01-01 07:30:16
offset1 = 0
offset2 = 16
length = 16
checksum = b’\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00’ (total 16)
DEBUG:miio.miioprotocol:Discovered xxxxxxxx with ts: 1970-01-01 07:30:16, token: b’00000000000000000000000000000000’
DEBUG:miio.miioprotocol:xxx.xxx.xxx.xxx:54321 >>: {‘id’: 1, ‘method’: ‘set_level_favorite’, ‘params’: [1]}
DEBUG:miio.miioprotocol:xxx.xxx.xxx.xxx:54321 (ts: 1970-01-01 07:30:18, id: 1) << {‘result’: [‘ok’], ‘id’: 1}

Thats is as far as I have gotten so far, rest of commands seems to work

I quickly looked, but are you sure the motor level can be set in an exact way in the mihome app.
I only saw the favorite level setting, which indeed is also available as channel in openhab.

If you don’t mind, pls make an issue in openhab github to add zhimi.airpurifier.mc2 with the same dbfile as zhimi.airpurifier.mc2 than with the next update I’ll not forget to add. That way it wont show as unsupported…

Sorry, was probably a bit unclear here.
When I first looked at the binding I had the wrong assumption that the channel motorspeed was what showed the fans-speed as well as set it. First after me testing with python-mioo I realised that favorite-level is what set the speed. Reason I did not connect them is that on my app it, the mode favorite is called manual and set with a slider, haven’t tested how many different levels it has.

So, to summarize, my assumptions were wrong, that caused my question. Will give it a more thorough test any day now when I know more and if I find all to work with the mc1 settings then I’ll make an issue on github.

Thanks once again for your prompt answers and effort with this binding.

Hi
can someone explain to me how i correctly add a Mi Air Purifier 2S to my text based things file?
The example only shows miio:basic:light and i´ve got no idea what i need to write instead of light
Can someone please write a short list of examples for the text based things file?
I´m willing to add these to the bindings manual.

kind regards
Michael

you can write anything instead of ‘light’…If you do automatic discovery it defaults to the deviceId, but that is not mandatory. Suggest to take a look at the docs, or a few post ups is also an example

I had a look at the docs but the example doesn´t make it clear that light is just a placeholder for a name i choose.
So it´s just the unique name i´m giving the Thing.
Thanks.

Hello @all
I need to switch over my Air Purifier 2S to new WiFi network. How can I do it in the easiest way?
I don’t have any application installed, actually I forgot how I had connected it to my network.
If I reset my device to be discovered from the app, will existing token change to a new one? Or it is hardcoded in the device?

Thanks in advance for any help.

if you reconnect it to a network the token will be reset to a new token.

Digging in my computer I found the tool I used to retrieve token year ago: miio. Here is tutorial.
I was able to get the token, but after configuring Purifier thing in OH I get the following errors in the log:

2020-06-20 11:59:17.221 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Periodic update for 'miio:basic:airpurifier' (miio:basic)
2020-06-20 11:59:17.223 [DEBUG] [internal.handler.MiIoAbstractHandler] - Ping Mi device XXXXXXX at 192.168.20.15
2020-06-20 11:59:17.224 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping XXXXXXX (192.168.20.15)
2020-06-20 11:59:17.226 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Starting Mi IO MessageSenderThread
2020-06-20 11:59:32.236 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Communication error for Mi device at 192.168.20.15: Receive timed out

However I can ping this device using regular ping tool. Does it mean the token I configured is bad? Or something else?
The device is in a different subnet, can it be a problem for the binding?

I moved the device back to main subnet and the binding can ping the device, but it looks like now there is a problem with the token:

2020-06-20 12:44:59.950 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Send command '{"id":18,"method":"miIO.info","params":[]}'  -> 192.168.10.15 (Device: XXXXX) gave error Given final block not properly padded. Such issues can arise if a bad key is used during decryption.

I am pretty sure it worked before, but I also did FW upgrade in the app. Could it broke something?

I gave up and used Mi Home v5.4.49 to retrieve the token. I also added secondary interface to reach 192.168.20.x from OH machine and now the binding can ping the device even it is in different subnet.
Wasted 4h trying to get this working, but the good thing is it works now and I am not going to change anything in the near future (I hope).