Xiaomi Mi Air Purifier (Xiaomi Mi IO)

Is there a way to connect to the devices without the Mi Gateway.
My air purifier is registered in my WIFI network. The smartphone app can connect directly to and I do not have the gateway (hardware gateway)

The app does only work when connected to tjhe internet and I would like to control my purifier directly from openhab in the local network.

I also installed the nodescript ( npm install -g miio)
all I get when i try to discover is:

ERROR Unsupported mode

best regards

Trigan :slight_smile:

It depends per device. If the device ā€˜speaksā€™ the miio protocol than you have high chance it can be controlled with the miio binding. If it is e.g. a wifi or zigbee device you may not control it without gateway

i can confirm this behaviour. Problem is a json misformat (which is not displayed in your dump).

"mmfree":27224,,"otu_stat" there are two , between otu_stat and mmfree. I think this string comes directly from the device, so maybe it has something to do with a missing configuration element or a newer (buggy) firmware

@marcel_verpaalen any chance you can fix this by checking / repairing the returned string first?

First of all, I would like to applogise. Iā€™ve created post and Iā€™ve been block by administration (itā€™s probably standard routine), then iā€™ve lost interest in this forum because block was remaind more then 3 daysā€¦ iā€™ve already fixed it in my local repository but iā€™m not proud of it. Fix is working, but itā€™s in very bad taste (ā€œsmelly codeā€). Iā€™ve added something like this, before parsing json:

jsonFromXiaomi = jsonFromXiaomi.replecaAll(",,", ",");

The truth is that iā€™ve no idea how to fix it better. Probably iā€™ve should send bug report to xiaomi, because it their fault (filter is sending bad data) but iā€™m too busy to do that.

The strange thing is: it stopped delivering wrong json after setting a name to the device in openhab paper uiā€¦ so either this is a strange coincidence, or the api returns something based on the request.

TBH: i wouldā€™ve fixed it the same way, easy but dirty workaround. clean(er) solution would be a json pattern replacement or using a ā€œmalformed json repair libraryā€

Well can you upload your compiled build? dont have a working development enviroment and maybe this helps the other people looking for a solution who are not as lucky as i am. :slight_smile:

Items:

Number XAIR_humidity                    "Humidity [%d %%]"                      <humidity>      (gPersChng)                     {channel="miio:basic:043A6817:humidity"}
Number XAIR_temp                        "Temperature [%2.1f Ā°C]"                <temperature>   (gPersChng)                     {channel="miio:basic:043A6817:temperature"}
String XAIR_mode                        "Mode Air Purifier"                                     (gPersChng)                     {channel="miio:basic:043A6817:mode"}
Switch XAIR_power                       "Power Air Purfier"                     <switch>        (gPersChng)                     {channel="miio:basic:043A6817:power"}
Number XAIR_airquality                  "PPM 2.5 [%d]"                          <chart>         (gPersChng)                     {channel="miio:basic:043A6817:aqi"}
Number XAIR_avgairquality               "AVG PPM 2.5"                           <chart>         (gPersChng)                     {channel="miio:basic:043A6817:averageaqi"}
Switch XAIR_autodetect                  "Air Autodetect"                                        (gPersChng)                     {channel="miio:basic:043A6817:act_det"}
Number XAIR_filterlife                  "Filter Remaining Life Time [%d %%]"    <pie>           (gPersChng)                     {channel="miio:basic:043A6817:filterlife"}
Number XAIR_filtermaxlife               "Filter Max Life Time [%d hours]"       <time>          (gPersChng)                     {channel="miio:basic:043A6817:filtermaxlife"}
Number XAIR_filterhours                 "Filter Hours [%d hours]"               <time>          (gPersChng)                     {channel="miio:basic:043A6817:filterhours"}
Number XAIR_usedhours                   "Used Hours [%d hours]"                 <time>          (gPersChng)                     {channel="miio:basic:043A6817:usedhours"}
Number XAIR_motorspeed                  "Motor [%d rpm]"                        <flow>          (gPersChng)                     {channel="miio:basic:043A6817:motorspeed"}
Number XAIR_favlevel                    "Manual Level Speed"                    <wind>          (gPersChng)                     {channel="miio:basic:043A6817:favoritelevel"}
Number XAIR_purifiedvol                 "Purified air volume [%d m3]"           <smoke>         (gPersChng)                     {channel="miio:basic:043A6817:purifyvolume"}
String XAIR_commandchannel              "Manual Command Channel XIAOMI"                                                         {channel="miio:basic:043A6817:actions#commands"}
Switch XAIR_led                         "Led [%s]"                              <slider>                                        {channel="miio:basic:043A6817:led"}
Switch XAIR_buzzer                      "Buzzer [%s]"                           <soundvolume>                                   {channel="miio:basic:043A6817:buzzer"}
Switch XAIR_childlock                   "Child lock [%s]"                       <lock>                                          {channel="miio:basic:043A6817:childlock"}

Sitemap:

Text label="Air Purifier"{
	Switch item=XAIR_mode label="Modus []" icon="fan" mappings=[auto=Auto, silent=Silent, favorite=Manual, idle=Off]
	Switch item=XAIR_power
	Text item=XAIR_humidity
	Text item=XAIR_temp
	Text item=XAIR_airquality
	Text item=XAIR_avgairquality
	//Text item=XAIR_autodetect
	Text item=XAIR_filterlife
	Text item=XAIR_filtermaxlife
	Text item=XAIR_filterhours
	Text item=XAIR_usedhours
	Text item=XAIR_motorspeed
	Text item=XAIR_purifiedvol
	Setpoint item=XAIR_favlevel minValue=1 maxValue=16 step=1
	Switch item=XAIR_led
	Switch item=XAIR_buzzer
	Switch item=XAIR_childlock
}

My remarks:

filterhours channels show nothing

Alltogether it work very very nice :wink:
Thank you !

2 Likes

@wojciech.fred,
Indeed if this comes from the device, I think the json is flawed, this is probably specific to a firmware version.
Iā€™m om holidays right now, but will implement such a hack/fix asap

Of course:

This is the latest version from marcelrv repository from xiaomi-miio branch with my ā€œsmellyā€ patch.
Down below is actual patch:
Dropbox - xiaomi_air_broken_json_fix.patch - Simplify your life (iā€™ll delete it as soon as possible, because i dont want to get bad reputation)

Iā€™m fiddling with the binding with the humidifier zhimi.humidifier.v1. I got it up and running - power on/off is runnning like a charm. Since itā€™s yet an unsupported device, I would like to try out the command channel you mention in your post. However, I donā€™t really understand how to use it. A short example would be great. Thanks a lot in advance!

Hallo @Chris69,
Yesterday evening I pushed a new release with humidifier support.
Pls delete your thing, update the binding than discovery again.
If things went well, you should have your humidifier as basic device

Thanks for you quick reply. I did what you said the humidifier was discovered as a basic device. However, no channels (besides the ones under ā€œShow moreā€) are shown.

Hallo @Chris69,

Give it a minute or 2 to get fully synced and updated. Than you may want to use F5 to refresh paperUI, as it not always picks up the thing changes well. With a little luck than the new channels are visible.

If not, PM me pls a log of the initiation (debug log, see xiaomi thread, first post on how) of the initiation of your thing.
(e.g in paperUI change the location of the thing, that will trigger it)

Thx for this Binding it works very well :slight_smile:
I have the same ā€žproblemā€œ the filterhours Channel show 0.

Is there fix for that?

@derhelge I donā€™t know if the humidifier actually has that property.(I don;t have the device, so the supported channels is an educated guess)

Do you see it in the mi home app? If not, probaly it is not available, than I just need to remove the channel.
(you can see in the debug log if the property receives a value in the communication)

Pls let me know the result ( please let me know the exact model string you see in your config as these properties are different per model)

@marcel_verpaalen
I canā€™t see Filterhours in the MI App, the only thing the app show me is the remaining days on the Filter.

I also received my humidifier yesterday and already added it to openhab. Works like charm!
The humidifier shows a aqi channel which is not used. The Mode channel works with ā€œsilent, medium and highā€ and the sethumidity channel with ā€œ40,50,60,70,80ā€, but is just shows these values and does not set the new one to the chosen value. I also have to find out, which channel is used if thereā€™s no water left in it.

niceā€¦ let me know if you find the commands, that they can be added to the db for the device

I think the error is in the ā€œ/database/zhimi.humidifier.v1.jsonā€ where the Command for setHumidity is ā€œset_led_bā€ instead of ā€œset_limit_humā€.:


			{
				"property": "limit_hum",
				"friendlyName": "Humidity Set",
				"channel": "setHumidity",
				"type": "Number",
				"refresh": true,
				"ChannelGroup": "Status",
				"actions": [
					{
						"command": "set_led_b",
						"parameterType": "NUMBER"
					}
				]
},

yes, seems obvious :slight_smile:
Can you see what it accepts (on off or a number)

it should accept a number (30, 40, 50, 60, 70, 80)