Xiaomi Mi Air Purifier (Xiaomi Mi IO)

Tags: #<Tag:0x00007f61707fad68> #<Tag:0x00007f61707fac50> #<Tag:0x00007f61707faac0>

As part of the Xiaomi Vacuum binding development, it became clear that other Xiaomi wifi devices could be controlled by the binding as well as they share the Mi IO communication protocol.
This topic is to discuss the working of the Air Purifiers / Humidifiers

There are several types air purifiers like the airpurifier 2 and the air purifier Pro.
Internally they are identified by model names:
zhimi.airpurifier.m1 = Air Purifier 2-> mapped & tested
zhimi.airpurifier.m2 -> mapped untested
zhimi.airpurifier.v1 -> mapped untested
zhimi.airpurifier.v2 -> mapped untested
zhimi.airpurifier.v3 -> mapped untested
zhimi.airpurifier.v5 -> mapped untested
zhimi.airpurifier.v6 =Air Purifier Pro-> partial mapped untested

The binding requires several configuration parameters to be provided. If your device is found by discovery (on the same network segment), normally nothing additional needs to be provided.

If you get a configuration error or token error, please refer to the Xiaomi Robot Vacuum Binding topic for information how to obtain your token.

Command Channel
If you want to send arbitrary commands unsupported by the binding, you can use the ‘show more’ button next to the channels header in paperUI to enable the advanced channel.
You can than send arbitrary commands. parameters to be provided in square brackets.
e.g. get_props["sleep_time"] the channel will be updated with the result of the command.

How to Update
To update to the latest version uninstall the market binding, than install again.
to know the installed version, use bundle:list | grep Xiaomi in the openhab commandline

Planned improvements

  • Convert the times in seconds to hours
  • Define the right mode values for each model

Updates

  • 5 Oct Definition for all air purifiers, control the favorite level (thanks @shorty707)

Issues/ bugs/improvements
If you have issues, please include your firmware version (can be seen in mihome app) and the log. Depending on the issue this may be the debug or the trace log.

log:set debug org.openhab.binding.miio
log:display org.openhab.binding.miio
If the binding works for you let us know as well :slight_smile:

1 Like

I did only add channels to the example sitemap below I was interested in. So there are more channels for users that are interested in those.
Some channels (e.g. Run Time, Temperature) need a data conversion. @marcel_verpaalen has that already on his list :slight_smile:

Items:

///////// XIAOMI DEVICES
// AIR PURIFIER
Number XAIR_humidity 			"Humidity [%d %%]" 								{channel="miio:basic:035CAFE2:humidity"}
Number XAIR_temp 				"Temp [%2.1f °C]" 	<temperature>				{channel="miio:basic:035CAFE2:temperature"}
String XAIR_mode				"Mode Air Purifier"								{channel="miio:basic:035CAFE2:mode"}
Switch XAIR_power				"Power Air Purfier"								{channel="miio:basic:035CAFE2:power"}
Number XAIR_airquality			"PPM 2.5"										{channel="miio:basic:035CAFE2:aqi"}
Number XAIR_avgairquality		"AVG PPM 2.5"									{channel="miio:basic:035CAFE2:averageaqi"}
Switch XAIR_autodetect			"Air Autodetect" 								{channel="miio:basic:035CAFE2:act_det"}
Number XAIR_filterlife			"Filter Life Time [%d %%]"						{channel="miio:basic:035CAFE2:filterlife"}
Number XAIR_motorspeed			"RPM Motor"										{channel="miio:basic:035CAFE2:motorspeed"}
Number XAIR_runtime				"Run Time [%d sec]"								{channel="miio:basic:035CAFE2:usedhours"}
Number XAIR_favlevel			"Manual Level"									{channel="miio:basic:035CAFE2:favoritelevel"}
Number XAIR_purifiedvol			"Purified"										{channel="miio:basic:035CAFE2:purifyvolume"}
String XAIR_commandchannel		"Manual Command Channel XIAOMI"					{channel="miio:basic:035CAFE2:actions#commands"}

Sitemap:

			Text label="Xiaomi" icon="network"{
				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 label="Current Humidity [%d %%]"
					Text item=XAIR_temp label="Current Temperature"
					Text item=XAIR_airquality label="Current PPM2.5 Air Quality"
					Text item=XAIR_avgairquality label="Avg. PPM2.5 Air Quality"
					//Text item=XAIR_autodetect
					Text item=XAIR_filterlife label="Remanining Life Time Filter [%d %%]"
					Text item=XAIR_motorspeed label="RPM Motor"
					Text item=XAIR_runtime label="Total Runtime"
					Text item=XAIR_purifiedvol label="Purified Air"
					Setpoint item=XAIR_favlevel minValue=1 maxValue=16 step=1 label="Manual Speed Setting"
				}				
			}

Test it on XiaoMi air purifier 2 and PRO. Turning on/off, switching modes, led all works. But the first command always failed.

14:59:10.897 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Received response for 03197AFA type: UNKNOWN, result: null, fullresponse: {"error":"No Response"}
14:59:10.897 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Error received: "No Response"

And it seems like I never get update on the other properties, like temperature, humidity, aqi etc…

I have the Purifier 2 (M1 model) … periodic updates work

Pushed update today.
Updates:

  • removed buzzer for v6 @illxi
  • updated airpurifier v6 & m1 to use transformation for seconds to hours @shorty707
  • Fix typo in channel name filtermaxLife

nb, as the channel def is changed, you maybe need to remove you thing and add it again if the filtermaxLife channel is not working proper anymore
As usual, to update, uninstall the market place binding and re-install it

Hi,
parameter refreshing does not work for me (No Response error as some people reported earlier). Token seems to be fine, because commands (power on and off) are working fine

openhab> log:tail org.openhab.binding.miio
23:00:50.771 [DEBUG] [org.openhab.binding.miio            ] - BundleEvent [unknown:512] - org.openhab.binding.miio
23:00:50.777 [DEBUG] [org.openhab.binding.miio            ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={component.name=org.openhab.binding.miio.internal.MiIoHandlerFactory, component.id=19, service.id=122, service.bundleid=223, service.scope=bundle} - org.openhab.binding.miio
23:00:50.780 [DEBUG] [org.openhab.binding.miio            ] - BundleEvent STARTING - org.openhab.binding.miio
23:00:50.781 [DEBUG] [org.openhab.binding.miio            ] - BundleEvent STARTED - org.openhab.binding.miio
23:00:50.787 [DEBUG] [org.openhab.binding.miio            ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={component.name=org.openhab.binding.miio.internal.discovery.MiIoDiscovery, component.id=20, service.id=123, service.bundleid=223, service.scope=bundle} - org.openhab.binding.miio
23:00:50.795 [DEBUG] [iio.internal.discovery.MiIoDiscovery] - Start Xiaomi Mi IO background discovery
23:00:50.799 [DEBUG] [org.openhab.binding.miio            ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.io.transport.mdns.discovery.MDNSDiscoveryParticipant}={component.name=org.openhab.binding.miio.internal.discovery, component.id=21, service.id=125, service.bundleid=223, service.scope=bundle} - org.openhab.binding.miio
23:00:50.815 [DEBUG] [iio.internal.discovery.MiIoDiscovery] - Staring discovery receiver thread for socket on port 32860
23:00:53.796 [DEBUG] [l.discovery.MiIoDiscoveryParticipant] - mDNS zhimi-airpurifier-m1 identified as thingtype miio:basic
23:00:53.797 [DEBUG] [l.discovery.MiIoDiscoveryParticipant] - mDNS zhimi-airpurifier-m1 identified as thingtype 03A29C75
23:00:53.808 [DEBUG] [l.discovery.MiIoDiscoveryParticipant] - mDNS zhimi-airpurifier-m1 identified as thingtype miio:basic
23:00:53.808 [DEBUG] [l.discovery.MiIoDiscoveryParticipant] - mDNS zhimi-airpurifier-m1 identified as thingtype 03A29C75
23:00:53.811 [DEBUG] [l.discovery.MiIoDiscoveryParticipant] - Mi IO mDNS Discovery found miio:basic:03A29C75 with address '192.168.1.229:54321' name 'zhimi-airpurifier-m1_miio60988533'
23:00:58.440 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Initializing Mi IO device handler 'miio:basic:03A29C75' with thingType miio:basic
23:00:58.458 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Polling job scheduled to run every 30 sec. for 'miio:basic:03A29C75'
23:00:58.463 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Refreshing miio:basic:03A29C75:power
23:00:58.466 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Refreshing miio:basic:03A29C75:temperature
23:00:59.351 [DEBUG] [l.discovery.MiIoDiscoveryParticipant] - mDNS zhimi-airpurifier-m1 identified as thingtype miio:basic
23:00:59.351 [DEBUG] [l.discovery.MiIoDiscoveryParticipant] - mDNS zhimi-airpurifier-m1 identified as thingtype 03A29C75
23:00:59.352 [DEBUG] [l.discovery.MiIoDiscoveryParticipant] - Mi IO mDNS Discovery found miio:basic:03A29C75 with address '192.168.1.229:54321' name 'zhimi-airpurifier-m1_miio60988533'
23:00:59.557 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Starting Mi IO MessageSenderThread
23:01:08.458 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Periodic update for 'miio:basic:03A29C75' (miio:basic)
23:01:08.917 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Building Channel Structure for miio:basic:03A29C75 - Model: zhimi.airpurifier.m1
23:01:08.923 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Using device database: /database/zhimi.airpurifier.m1.json for device zhimi.airpurifier.m1
23:01:08.948 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:network#ssid, type: miio:ssid
23:01:08.949 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:network#bssid, type: miio:bssid
23:01:08.950 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:network#rssi, type: miio:rssi
23:01:08.950 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:network#life, type: miio:life
23:01:08.950 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:actions#commands, type: miio:commands
23:01:08.951 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:power, type: miio:power
23:01:08.952 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:mode, type: miio:mode
23:01:08.954 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:humidity, type: miio:humidity
23:01:08.955 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:aqi, type: miio:aqi
23:01:08.956 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:averageaqi, type: miio:averageaqi
23:01:08.957 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:led, type: miio:led
23:01:08.958 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:buzzer, type: miio:buzzer
23:01:08.959 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:filtermaxlife, type: miio:filtermaxlife
23:01:08.971 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:filterhours, type: miio:filterhours
23:01:08.972 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:usedhours, type: miio:usedhours
23:01:08.973 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:motorspeed, type: miio:motorspeed
23:01:08.974 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:filterlife, type: miio:filterlife
23:01:08.981 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:favoritelevel, type: miio:favoritelevel
23:01:08.981 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:temperature, type: miio:temperature
23:01:08.982 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:purifyvolume, type: miio:purifyvolume
23:01:08.983 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels miio:basic:03A29C75:childlock, type: miio:childlock
23:01:08.992 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = power, friendlyName = Power, type = Switch, channelType = power, ChannelGroup = null, channel = power, property = power, refresh = true]
23:01:08.995 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'power' for thing miio:basic:03A29C75 already exist... removing
23:01:08.997 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = mode, friendlyName = Mode, type = String, channelType = mode, ChannelGroup = actions, channel = mode, property = mode, refresh = true]
23:01:08.998 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'mode' for thing miio:basic:03A29C75 already exist... removing
23:01:08.999 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = humidity, friendlyName = Humidity, type = Number, channelType = humidity, ChannelGroup = Status, channel = humidity, property = humidity, refresh = true]
23:01:09.000 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'humidity' for thing miio:basic:03A29C75 already exist... removing
23:01:09.001 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = aqi, friendlyName = Air Quality Index, type = Number, channelType = aqi, ChannelGroup = Status, channel = aqi, property = aqi, refresh = true]
23:01:09.002 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'aqi' for thing miio:basic:03A29C75 already exist... removing
23:01:09.002 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = averageaqi, friendlyName = Average Air Quality Index, type = Number, channelType = averageaqi, ChannelGroup = Status, channel = averageaqi, property = average_aqi, refresh = true]
23:01:09.003 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'averageaqi' for thing miio:basic:03A29C75 already exist... removing
23:01:09.004 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = led, friendlyName = Led Status, type = Switch, channelType = led, ChannelGroup = actions, channel = led, property = led, refresh = true]
23:01:09.005 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'led' for thing miio:basic:03A29C75 already exist... removing
23:01:09.005 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = buzzer, friendlyName = Buzzer Status, type = Switch, channelType = buzzer, ChannelGroup = actions, channel = buzzer, property = buzzer, refresh = true]
23:01:09.006 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'buzzer' for thing miio:basic:03A29C75 already exist... removing
23:01:09.007 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = filtermaxlife, friendlyName = Filter Max Life, type = Number, channelType = filtermaxlife, ChannelGroup = Status, channel = filtermaxlife, property = f1_hour, refresh = true]
23:01:09.007 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'filtermaxlife' for thing miio:basic:03A29C75 already exist... removing
23:01:09.008 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = filterhours, friendlyName = Filter Hours used, type = Number, channelType = filterhours, ChannelGroup = Status, channel = filterhours, property = f1_hour_used, refresh = true]
23:01:09.009 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'filterhours' for thing miio:basic:03A29C75 already exist... removing
23:01:09.009 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = usedhours, friendlyName = Run Time, type = Number, channelType = usedhours, ChannelGroup = Status, channel = usedhours, property = use_time, refresh = true]
23:01:09.010 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'usedhours' for thing miio:basic:03A29C75 already exist... removing
23:01:09.010 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = motorspeed, friendlyName = Motor Speed, type = Number, channelType = motorspeed, ChannelGroup = Status, channel = motorspeed, property = motor1_speed, refresh = true]
23:01:09.011 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'motorspeed' for thing miio:basic:03A29C75 already exist... removing
23:01:09.011 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = filterlife, friendlyName = Filter  Life, type = Number, channelType = filterlife, ChannelGroup = Status, channel = filterlife, property = filter1_life, refresh = true]
23:01:09.011 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'filterlife' for thing miio:basic:03A29C75 already exist... removing
23:01:09.012 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = favoritelevel, friendlyName = Favorite Level, type = Number, channelType = favoritelevel, ChannelGroup = Status, channel = favoritelevel, property = favorite_level, refresh = true]
23:01:09.013 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'favoritelevel' for thing miio:basic:03A29C75 already exist... removing
23:01:09.013 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = temperature, friendlyName = Temperature, type = Number, channelType = temperature, ChannelGroup = Status, channel = temperature, property = temp_dec, refresh = true]
23:01:09.013 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'temperature' for thing miio:basic:03A29C75 already exist... removing
23:01:09.013 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = purifyvolume, friendlyName = Purivied Volume, type = Number, channelType = purifyvolume, ChannelGroup = Status, channel = purifyvolume, property = purify_volume, refresh = true]
23:01:09.013 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'purifyvolume' for thing miio:basic:03A29C75 already exist... removing
23:01:09.014 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - properties [ Channel = childlock, friendlyName = Child Lock, type = Switch, channelType = childlock, ChannelGroup = Status, channel = childlock, property = child_lock, refresh = true]
23:01:09.014 [INFO ] [inding.miio.handler.MiIoBasicHandler] - Channel 'childlock' for thing miio:basic:03A29C75 already exist... removing
23:01:09.014 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels added: 16
23:01:09.050 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":1,"method":"miIO.info","params":[]} -> 192.168.1.229 (Device: 03A29C75 token: 7FBD5___HIDDEN___4379CD0C5 Queue: 1)
23:01:19.481 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Communication error for Mi IO device at 192.168.1.229: Receive timed out
23:01:19.482 [DEBUG] [nal.transport.MiIoAsyncCommunication] - No response from device 03A29C75 at 192.168.1.229 for command {"id":1,"method":"miIO.info","params":[]}.
23:01:19.482 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Received response for 03A29C75 type: MIIO_INFO, result: null, fullresponse: {"error":"No Response"}
23:01:19.483 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Error received: "No Response"
23:01:40.148 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Locating action for channel power:ON
23:01:40.149 [DEBUG] [inding.miio.handler.MiIoBasicHandler] -  sending command set_power["on"]
23:01:40.149 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":2,"method":"set_power","params":["on"]} -> 192.168.1.229 (Device: 03A29C75 token: 7FBD5___HIDDEN___4379CD0C5 Queue: 1)
23:01:40.624 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Received response for 03A29C75 type: SET_POWER, result: ["ok"], fullresponse: {"result":["ok"],"id":2}
23:04:04.549 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Locating action for channel power:ON
23:04:04.550 [DEBUG] [inding.miio.handler.MiIoBasicHandler] -  sending command set_power["on"]
23:04:04.550 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":3,"method":"set_power","params":["on"]} -> 192.168.1.229 (Device: 03A29C75 token: 7FBD5___HIDDEN___4379CD0C5 Queue: 1)
23:04:04.637 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Received response for 03A29C75 type: SET_POWER, result: ["ok"], fullresponse: {"result":["ok"],"id":3}

I also noticed that there is only one query sent to device (id:1) - there are no mo tries (should be every 30 sec - see log above). I have the latest version of bindings - build today

openhab> bundle:list | grep Xiaomi 
223 | Active    |  80 | 2.2.0.201711012043     | Xiaomi Mi IO Binding

any help please?

Regards,
Adam

and TRACE:

23:29:04.562 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":1,"method":"miIO.info","params":[]} -> 192.168.1.229 (Device: 03A29C75 token: __HIDDEN___ Queue: 1)
23:29:04.562 [TRACE] [nal.transport.MiIoAsyncCommunication] - Connection 192.168.1.229:47298
23:29:04.577 [TRACE] [nal.transport.MiIoAsyncCommunication] - Message Details:Message:
Header  : 21 31 00 20 00 00 00 00 03 A2 9C 75 00 05 AC BB
checksum: 7F BD 52 C3 BC 5F DC D4 48 77 C5 B4 37 9C D0 C5
content : N/A
Header Details: Magic:21 31
Length:   32
Serial:   03 A2 9C 75
TS:1970-01-05 08:18:19 
23:29:04.577 [TRACE] [nal.transport.MiIoAsyncCommunication] - inform listener org.openhab.binding.miio.handler.MiIoBasicHandler@4c982c6b, data {} from {}
23:29:04.615 [TRACE] [nal.transport.MiIoAsyncCommunication] - Connection 192.168.1.229:47298
23:29:14.623 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Communication error for Mi IO device at 192.168.1.229: Receive timed out
23:29:14.624 [TRACE] [nal.transport.MiIoAsyncCommunication] - Reponse length <32 : 0
23:29:14.656 [TRACE] [nal.transport.MiIoAsyncCommunication] - No response from device 03A29C75 at 192.168.1.229 for command {"id":1,"method":"miIO.info","params":[]}.
Message:
Header  : 21 31 00 50 00 00 00 00 03 A2 9C 75 59 FF F7 6B
checksum: 9B 72 90 A8 E8 CF F6 60 E7 84 23 67 41 E2 31 58
content : 82 67 D4 C2 12 02 AA F3 CE 77 06 BC 6A 96 FA 5E C1 11 15 83 12 8D 72 F0 20 0F 8A 4E 3E 6F 13 BC 92 E2 49 B3 FA 8D 74 42 7F 02 1E 0A 7C 24 47 49
Header Details: Magic:21 31
Length:   80
Serial:   03 A2 9C 75
TS:2017-11-06 06:47:23
23:29:14.658 [TRACE] [nal.transport.MiIoAsyncCommunication] - Received  JSON message {"error":"No Response"}
23:29:14.661 [TRACE] [nal.transport.MiIoAsyncCommunication] - inform listener org.openhab.binding.miio.handler.MiIoBasicHandler@4c982c6b, data {} from {}
23:29:14.664 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Received response for 03A29C75 type: MIIO_INFO, result: null, fullresponse: {"error":"No Response"}
23:29:14.667 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Error received: "No Response"

@SirAd indeed it is strange.
What is also strange is that a part of the logging I would expect is missing, That is the handler initiation ( the piece where the refreshing indeed is started)
Just a quick check: In the advanced properties, there is a refresh period, can you pls check that it is > than 0.

another quick check. Can you try in the console to execute
smarthome:send aChannel REFRESH
replace the aChannel with one of the property channels of your device. This should trigger a properties refresh

Hi,
I was able to fix “No response” problem. It’s caused by incorrect value for timestamp. Variable timestamp is not initialized when HELLO message is sent, because sendPing method is using directly method sendData not sendCommand (where timestamp is set and timeDelta is calculated)

I’ve created a small fix - here is PR:

just added timeDelta calculation in sendData and few logging in debug I used to found problem

The pooling issue is still there. @marcel_verpaalen - Time interval is not zero - but when I’m changing value I’m getting 404 error . I’ve tried to send REFRESH

22:05:05.652 [TRACE] [nal.transport.MiIoAsyncCommunication] - About to send to device 03A29C75 at 192.168.1.229 for command {"id":3,"method":"miIO.info","params":[]}.
22:05:05.652 [TRACE] [nal.transport.MiIoAsyncCommunication] - Connection 192.168.1.229:44423
22:05:05.666 [TRACE] [nal.transport.MiIoAsyncCommunication] - Received datagram length 496
22:05:05.667 [TRACE] [nal.transport.MiIoAsyncCommunication] - Received stamp 453285 current stamp 1509656705 delta -1509203420
22:05:05.668 [TRACE] [nal.transport.MiIoAsyncCommunication] - Message Details:Message:
Header  : 21 31 01 F0 00 00 00 00 03 A2 9C 75 00 06 EA A5
checksum: B8 D9 FD EE 62 6A F2 E7 AB EC 6D 41 09 38 61 05
content : 15 82 C9 D9 B3 EB 73 B9 62 C0 13 D7 C9 73 74 A6 CB 8B 23 A0 16 00 8B C7 C8 3F 59 5B 32 92 AF 28 5E EF E6 A6 1D AC A4 90 BE 46 0B 0A 35 41 D9 B4 8A FA 67 B0 53 FA F2 C5 B7 79 6A 71 81 B0 44 9C 86 AF BD 96 99 A7 FB B1 F3 1B 62 4E E3 62 D3 C0 45 A7 3E 60 7C 15 05 AF D6 6C 32 81 BA BB 93 E4 67 09 5F 67 15 AC 62 D0 6B EA CC F3 0F A2 EB F7 D8 41 46 71 4B 1A 24 CE B5 92 DC 9A 57 16 57 75 D3 F0 AD 11 7B B2 06 C6 60 1C AF BF 6C B7 20 23 A1 EB A7 C6 8B A9 24 40 C9 43 5B FA 28 7E E8 50 5F 5D 55 3F 47 A6 5E C8 AB 4B 4D 3E 35 EB 05 2F 07 90 E6 A7 0B 71 A8 8C 18 6D 29 2F 7E DD DA 4C FE 40 88 E4 7B B8 0E AE 87 D4 49 DC 1B 6F FF E8 9E 53 09 DF 02 EA 0D 1A 67 95 4B 32 04 5A DC 51 B8 5D 8D C3 BF 16 28 D6 C9 83 19 9F C3 FD F0 5F 36 1B 9B 5F 97 CC 33 07 60 65 F0 52 1B AC 1C 78 98 D5 6C AD 18 59 39 38 86 BF 02 17 78 25 77 1E 6B 6A 55 90 E3 05 B1 2D 6A 60 3F D4 CE 4D 2D 0D DC 88 3D 3A 29 6F 85 67 B0 06 D4 8D 69 4E 74 BF 73 1D 86 9D BC F3 E3 8C 75 CB 03 A8 61 CA 86 C6 D4 D5 80 84 A9 74 62 BD 1C FA CE 2B 8C 45 3F 08 32 4C C5 F2 B8 F0 9E 34 14 14 CA C4 66 A5 D4 E7 45 26 B4 46 FE 11 C6 52 09 28 C6 7B 84 8F 49 FD 30 79 6C 19 BF EE 61 FE 30 E4 0E A6 17 F7 27 65 35 05 7E A0 DA 5B 8E 0B D2 73 8E AC 38 99 66 18 D0 4F E6 22 B5 90 8C 94 EC E0 22 32 B2 A0 A4 52 10 CC 8E 38 12 86 F0 D7 F5 35 CB 9D D5 39 33 EE 16 64 A7 BC D7 EB 77 8D 47 CD 7A 48 3F EC 19 4E 5E C5 B2 BF 87 7F F1 99 51 F5 30 BF DA 2D 9C 7F
Header Details: Magic:21 31
Length:   496
Serial:   03 A2 9C 75
TS:1970-01-06 06:54:45 
22:05:05.669 [TRACE] [nal.transport.MiIoAsyncCommunication] - Received response from 192.168.1.229: {"result":{"life":453285,"cfg_time":0,"token":"7fbd52c3bc5fdcd44877c5b4379cd0c5","mac":"34:CE:00:9F:64:F3","fw_ver":"1.2.4_59","hw_ver":"MC200","model":"zhimi.airpurifier.m1","wifi_fw_ver":"SD878x-14.76.36.p79-702.1.0-WM","ap":{"rssi":-32,"ssid":"sznurek2","bssid":"80:3F:5D:51:84:83"},"netif":{"localIp":"192.168.1.229","mask":"255.255.255.0","gw":"192.168.1.1"},"mmfree":27152,"ot":"otu","otu_stat":[483,458,932,0,932,406],"ott_stat":[0, 0, 0, 0]},"id":3}
22:05:05.670 [TRACE] [nal.transport.MiIoAsyncCommunication] - Received  JSON message {"result":{"life":453285,"cfg_time":0,"token":"7fbd52c3bc5fdcd44877c5b4379cd0c5","mac":"34:CE:00:9F:64:F3","fw_ver":"1.2.4_59","hw_ver":"MC200","model":"zhimi.airpurifier.m1","wifi_fw_ver":"SD878x-14.76.36.p79-702.1.0-WM","ap":{"rssi":-32,"ssid":"sznurek2","bssid":"80:3F:5D:51:84:83"},"netif":{"localIp":"192.168.1.229","mask":"255.255.255.0","gw":"192.168.1.1"},"mmfree":27152,"ot":"otu","otu_stat":[483,458,932,0,932,406],"ott_stat":[0,0,0,0]},"id":3}
22:05:05.670 [TRACE] [nal.transport.MiIoAsyncCommunication] - inform listener org.openhab.binding.miio.handler.MiIoBasicHandler@7e8e8a95, data {} from {}
22:05:05.671 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Received response for 03A29C75 type: MIIO_INFO, result: {"life":453285,"cfg_time":0,"token":"7fbd52c3bc5fdcd44877c5b4379cd0c5","mac":"34:CE:00:9F:64:F3","fw_ver":"1.2.4_59","hw_ver":"MC200","model":"zhimi.airpurifier.m1","wifi_fw_ver":"SD878x-14.76.36.p79-702.1.0-WM","ap":{"rssi":-32,"ssid":"sznurek2","bssid":"80:3F:5D:51:84:83"},"netif":{"localIp":"192.168.1.229","mask":"255.255.255.0","gw":"192.168.1.1"},"mmfree":27152,"ot":"otu","otu_stat":[483,458,932,0,932,406],"ott_stat":[0,0,0,0]}, fullresponse: {"result":{"life":453285,"cfg_time":0,"token":"7fbd52c3bc5fdcd44877c5b4379cd0c5","mac":"34:CE:00:9F:64:F3","fw_ver":"1.2.4_59","hw_ver":"MC200","model":"zhimi.airpurifier.m1","wifi_fw_ver":"SD878x-14.76.36.p79-702.1.0-WM","ap":{"rssi":-32,"ssid":"sznurek2","bssid":"80:3F:5D:51:84:83"},"netif":{"localIp":"192.168.1.229","mask":"255.255.255.0","gw":"192.168.1.1"},"mmfree":27152,"ot":"otu","otu_stat":[483,458,932,0,932,406],"ott_stat":[0,0,0,0]},"id":3}
22:05:05.673 [INFO ] [ing.miio.handler.MiIoAbstractHandler] - Mi IO model zhimi.airpurifier.m1 identified as: Mi Air Purifier 2 (mini) (zhimi.airpurifier.m1). Matches thingtype miio:basic
22:18:38.242 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Refreshing miio:basic:03A29C75:power
2 Likes

Hi,
I’ve updated OH to 2.2 latest SNAPSHOT and now items are updated:

23:41:09.347 [INFO ] [ding.miio.handler.MiIoAbstractHandler] - Mi IO model zhimi.airpurifier.m1 identified as: Mi Air Purifier 2 (mini) (zhimi.airpurifier.m1). Matches thingtype miio:basic
23:41:09.375 [INFO ] [smarthome.event.ItemStateChangedEvent] - testx1 changed from NULL to ON
23:41:09.402 [INFO ] [smarthome.event.ItemStateChangedEvent] - ZhimiAirpurifierM1_miio60988533_Temperature changed from NULL to 20.6

@SirAd Thanks, I’ve incorporated your fix!

I add Thing. It was green “online”, token OK.
I add above items and sitemap.
I changed “miio:basic:035CAFE2” to mine "miio:basic:0401F6F5"
Buttons are working great. Equipment is changing states quickly and without any problems.
I have a problem with reading temperature, humidity, PM’s, filter lifetime and other data. Fields are empty. What can be the source of the problem?

@Tribon, may i guess your oh version is 2.1 instead of 2.2 snapshot.
I think somewhere the scheduled refresh stops for that version without any indication of why.

Hence I struggle to find the cause.
You may try to send REFRESH to any of the channels, I’m curious if that will refresh the data. (As that does not depend on the scheduled refreshes)

I’m using 2.1 indeed.
How can I refresh the channel?
I’m pretty new to the community and part of the problems might come from my faults.

Edit1: After two days I can see the same lack of information coming from the air purifier. ON/OFF and modes are working great.

Edit2: After update to 2.2 I can see the data coming from Mi Air purifier. But now situation is opposite - power channel is not working. “Manual Speed Setting” is working - I can hear the beep sound coming from the purifier. Speed was adjusted after manual (by finger) changing to favorite (lowest light on the purifier).

Just a short update.
After some fiddling around I have to say that:
on 2.1 - data (temperature, humidity, PM values) are not fetched from the air purifier but start/stop buttons are working.
on 2.2 snapshot - data is fetched but start/stop buttons doesn’t work.

Short update:
on 2.2 snapshot - it’s working.

thanks for that confirmation.

Hello

I’ve got problem with addon after I’ve added the “Thing” I’ve got only one error all the time in openhab.log:

2017-11-26 22:02:18.579 [WARN ] [nal.transport.MiIoAsyncCommunication] - Could not parse ‘{“result”:{“life”:14592,“cfg_time”:0,“token”:“xxxxxxxx secret xxxxxxxxxxxxxxxx”,“mac”:“01:23:45:67:89:ab”,“fw_ver”:“1.2.4_60”,“hw_ver”:“MC200”,“model”:“zhimi.airpurifier.m1”,“wifi_fw_ver”:“SD878x-14.76.36.p79-702.1.0-WM”,“ap”:{“rssi”:-54,“ssid”:“my_ssid_aaaaaa”,“bssid”:“ba:98:76:54:32:10”},“netif”:{“localIp”:“192.11.22.33”,“mask”:“255.255.255.0”,“gw”:“192.11.22.254”},“mmfree”:27304,“otu_stat”:[64,44,111,2,107,16],“ott_stat”:[0, 208, 213, 0]},“id”:281}’ <- {“id”:281,“method”:“miIO.info”,“params”:[]} (Device: 03A7EA6D) gave error com.google.gson.stream.MalformedJsonException: Expected name at line 1 column 386 path $.result.mmfree

And in PaperUi i’ve got only basic Network [ssid, bssid, rssi, life] and Action [execute command] Channels, without temperature, humidity and air pollution index.

Steps to Reproduce (for Bugs)

I’m adding manually “Thing” using PaperUi interface (i’m only defining ip, name and token). Currently binding can’t detect it automatically. And thats it, error start to show up.

My Environment:

openHAB 2.2.0 Build #1099
addons: org.openhab.binding.miio-2.2.0-SNAPSHOT.jar - builded from your github repository (last commit: 58bcc7db9 branch:xiaomi-miio)

$ java -version
java version "1.8.0_151"
Java™ SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot™ Client VM (build 25.151-b12, mixed mode)

$ uname -a
Linux odroid-c1p 3.10.104 #4 SMP PREEMPT Wed Apr 12 22:22:17 CEST 2017 armv7l armv7l armv7l GNU/Linux

$ nodejs --version
v7.10.1

Firefox 57.0

Do you have an example of Xiaomi Air Purifier 2 xiaomi.things setup?

1 Like

Hi, I get similar errors. I’ve even updated miio binding and openhab to today’s latest version.
On 2.2-SNAPSHOT was the same.
Any ideas?