Xiaomi Mijia Smart Tower Fan


did anybody try to bind to Xiaomi Mi IO Binding and use the new Xiaomi Mijia Smart Tower Fan via openHAB, yet?

I tried this afternoon and after successfully getting the token the device thing came online in openHAB. I only have to items. An On/Off Switch and an item “(experimental)Execute Test Commands”. I did not try the second one as I do not know what commands I could send there.

Unfortunately the first one, the On/Off switch, does not work.

Well, if there is more information or anything about that, let me know here. Of course, I’m also happy to test. If there are ideas to try.


what is the model Id you get in OH?

You can try to add it as basic device and override the model id with some of the supported ones, you have high chance it will work ( e.g. try zhimi.fan.za1).

Please feedback your results, which channels works and which not and we may can add it later as supported device

Hi Marcel,

the model id I get which is also in the thing is: dmaker.fan.p9

Did I understood correct that I just want to try to change this to zhimi.fan.za1 for example? I will try right away and will be back with more.


It took a while until the thing came back online. Turning the On/Off switch on and off did not have any effect on the tower fan as well as with the original model id.

Do I need to restart openHAB or the binding or recreate the On/Off switch item?

I took quick look.
Your device indeed seems to be more different than I hoped for…

So in order to get things more working, please enable the debug loggin for the binding, so we can see the communication. Also, please enable the command channel (that allows custom commands to be send)

Please try to send the following via the command channel and feedback the reply of the device:

get_prop["power", "mode", "speed", "roll_enable", "roll_angle", 'time_off", "light", 'beep_sound", "child_lock"]

please also try get_prop["all"]

looks like the values can be set with s_power , s_mode etc… e.g. you can try to send s_power["on"] dunno what it expects (e.g. on/off or 1 or 0 ) you can give it a try based on the responses from the get_prop

note these appear to be all the supported commands
METHOD_GET_PROP = “get_prop”;
METHOD_SET_LIGHT = “s_light”;
METHOD_SET_LOCK = “s_lock”;
METHOD_SET_MODE = “s_mode”;
METHOD_SET_POWER = “s_power”;
METHOD_SET_ROLL = “s_roll”;
METHOD_SET_SOUND = “s_sound”;
METHOD_SET_SPEED = “s_speed”;
METHOD_SET_TIME_OFF = “s_t_off”;

Ok, I’ll try. And I’m motivated. First tries were not successful:

2020-08-10 19:51:46.309 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":145,"method":"get_prop","params":["power","mode","speed","roll_enable","roll_angle","time_off","light","beep_sound","child_lock"]} -> (Device: 0E45C3B1 token: 50B1703DXXXXXXXXXXXXXXXX6C998021 Queue: 2)
2020-08-10 19:51:50.525 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for 0E45C3B1 type: GET_PROPERTY, result: {}, fullresponse: {"id":145,"error":{"code":-9999,"message":"user ack timeout"},"exe_time":4020}
2020-08-10 19:51:50.526 [DEBUG] [internal.handler.MiIoAbstractHandler] - Error received: {"code":-9999,"message":"user ack timeout"}

2020-08-10 19:53:09.369 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":149,"method":"get_prop","params":["all"]} -> (Device: 0E45C3B1 token: 50B1703DXXXXXXXXXXXXXXXX6C998021 Queue: 1)
2020-08-10 19:53:13.439 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for 0E45C3B1 type: GET_PROPERTY, result: {}, fullresponse: {"id":149,"error":{"code":-9999,"message":"user ack timeout"},"exe_time":4020}
2020-08-10 19:53:13.442 [DEBUG] [internal.handler.MiIoAbstractHandler] - Error received: {"code":-9999,"message":"user ack timeout"}

Any idea? What did I do wrong?

I also got some other information back. Which includes MAC, token, IP…

Btw, I put the devices back to dmaker.fan.p9

Than your device may be of a very different type (not a miio, but a miot device, for which there is some experimental support in the binding).

Try to execute:
get_properties[{"did": "power", "siid": 2, "piid": 1} ]

If you get any meaning full result, it is a miot device. Than in your conf/misc folder, can you create a miio folder and drop the attached file in there.

Than remove the old device (unsupported one) and (manually) add the device as a miio:basic device (copy the token, as it will not be added automatically)

dmaker.fan.p9-miot.json (5.2 KB)

Looks good:

2020-08-10 22:04:43.024 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":284,"method":"get_properties","params":[{"did":"power","siid":2,"piid":1}]} -> (Device: 0E45C3B1 token: 50B1703DXXXXXXXXXXXXXXXX6C998021 Queue: 1)
2020-08-10 22:04:43.306 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for 0E45C3B1 type: GET_PROPERTIES, result: [{"did":"power","siid":2,"piid":1,"code":0,"value":true}], fullresponse: {"id":284,"result":[{"did":"power","siid":2,"piid":1,"code":0,"value":true}],"exe_time":230}

Trying the next step now.

What do I use for “Device ID” when adding the tower fan as a miio basic device?

It will auto populate to your real device ID (dmaker.fan.p9), but if not you can fill it in.

The json file has the reference of the piid and siid for each of the properties. If the loading goes well, you should get a channel for all those properties

Ok… When adding it through the inbox it was a unsupported device again, but it had Device ID filled with 0E45C3B1 and Device Model String filled with dmaker.fan.p9 - but it did not work. I then removed the unsupported device again and added a MI IO Basic device, as you wrote and filled in Device ID and Device Model String with the content from above.

The device is online but I only see 5 channels, when I click show more. The only Action channel is Execute Command.

I put the file dmaker.fan.p9-miot.json into /etc/openhab2/misc/miio (which is also mapped to /srv/openhab2-conf/misc/miio). Can I see something in openhab.log if the this file is loaded? With debugging for MIIO turned on there is a lot of traffic in the log. So I grepped for dmaker.fan.p9-miot.json and did not find anything. What I found is:

2020-08-11 09:28:17.209 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Building Channel Structure for miio:basic:db8ee822 - Model: dmaker.fan.p9
2020-08-11 09:28:17.211 [WARN ] [io.internal.handler.MiIoBasicHandler] - Database entry for model 'dmaker.fan.p9' cannot be found.

That you the building channel structure… is good, it means that it is indeed now configured as basic device. Unfortunate seems the json file is not found.

Are the permissions in a way that openhab can read the file?

Do you see any line in your log like Adding local json db file: or Error while searching for database file in the log.

This is showing up in the very beginning of the start of the binding, and should also appear if you modify the file

Yes. The owner of the file is the user openhab. Also from the directory miio I created inside misc.

Unfortunately nothing like this can be found in openhab.log. :frowning: Even grepping for json does not turn anything up. I also modified the file (putting an extra linefeed at the end of the file. Nothing.

Do I need to restart openHAB?

Ok, I restarted openHAB and now the file was loaded (two times?).

2020-08-11 13:01:58.644 [DEBUG] [ernal.basic.MiIoDatabaseWatchService] - Adding local json db file: dmaker.fan.p9-miot.json, file:/etc/openhab2/misc/miio/dmaker.fan.p9-miot.json
2020-08-11 13:01:58.923 [DEBUG] [ernal.basic.MiIoDatabaseWatchService] - Adding local json db file: dmaker.fan.p9-miot.json, file:/etc/openhab2/misc/miio/dmaker.fan.p9-miot.json
2020-08-11 13:03:34.240 [DEBUG] [io.internal.handler.MiIoBasicHandler] - Using device database: /etc/openhab2/misc/miio/dmaker.fan.p9-miot.json for device dmaker.fan.p9

And now I got a lot of new channels:

Device Information-Device Manufacturer

Device Information-Device Model

Device Information-Device Serial Number

Device Information-Current Firmware Version

Fan-Switch Status

Fan-Fan Level


Fan-Horizontal Swing

Fan-Horizontal Angle


Fan-Power Off Delay Time


Fan-Speed Level

Physical Control Locked-Physical Control Locked

I will try those after lunch and will be back here as soon as I have tried. :wink:

So far, so good. :slight_smile:

I can control the tower fan somehow. But the current status of the items is only changed when I control through openHAB. If I turn on/off on the fan itself or alter the speed, swing… I do not see any updates in openHAB.

Also I cannot link HorizontalAngle and OffDelayTime to an item. Maybe because the Standard (system:default) and all other options are missing as profile in the linking box in Paper UI (it’s just emptry).

Also you might have noticed that the channel PhysicalControlsLocked has the wrong name (Physical Control Locked-Physical Control Locked). Which is not very important but also might not be wanted like that. Or is the first one the category and the second one the name?

I would expect that at the next refresh (typically each 30 seconds) the device would send the new state to opehab. So if you change something via a button on the device, or via the mihome app, it is max 30 sec before OH gets the new values.

I created the file from the published xiaomi spec, but these are notoriously having many mistakes.
Many times also including properties the device does not support.

FYI: this is the source of the info: http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p9:1
It also provides a hint on the expected values. note you may want to view reformatted like with http://jsonviewer.stack.hu/ or so to make it somewhat readable

So you prob need to tweak the json file to get it properly working. (e.g. change Numbers intro Strings etc to match the real expected input/output from the device)

A good check is: does the mihome app show this info. If not, there is a good chance it is not supported.

Thank you for the links. I found another value. Motor Control. Edited the json file. Will keep you posted here. I also checked what happens with the values when I change something at the fan. Will post everything here, also a sniplet from the sitemap, when it is finished and works.

Btw, it really is the case that the values change after 30 seconds. Thank you for that hint, too. I guess that it is possible to change the 30 seconds to like 10 seconds in the thing or does this create too much overhead?

I have one problem, though, hopefully you can help:

I delete the thing and changed something else for these two values. The parameterType was STRING, but these are NUMBER values. So I changed the parameterTyp to NUMBER as well.

After re-adding the thing to openHAB I am still not able to link these two channels to an item. The profile pull down menu is still empty, like described above.

Any idea?

Ok, got it. I had to change the uint16 and uint32 types to uint8. Then it worked. And I can control everything I can also control in the Xiaomi Home app. :smiley:

Here’s a screenshot from my sitemap:

And what is in my sitemap file:

Text item=XiaomiMijiaSmartTowerFan_FanSwitchStatus label="Turmventilator [MAP(tasmota2.map):%s]" labelcolor=[XiaomiMijiaSmartTowerFan172270134_Online=="NULL"="gray",XiaomiMijiaSmartTowerFan172270134_Online=="Uninitialized"="gray",XiaomiMijiaSmartTowerFan172270134_Online=="OFF"="red",XiaomiMijiaSmartTowerFan172270134_Online=="ON"="green"] valuecolor=["NULL"="gray","Uninitialized"="gray","ON"="red","OFF"="green"] icon="fan" {
  Switch item=XiaomiMijiaSmartTowerFan_FanSwitchStatus
  Switch item=XiaomiMijiaSmartTowerFan_FanMode label="Modus []" mappings=[0="Standard", 1="Natürlich", 2="Schlaf"]
  Switch item=XiaomiMijiaSmartTowerFan_FanFanLevel label="Lüfterstufe []" mappings=[1="1", 2="2", 3="3", 4="4"]
  Setpoint item=XiaomiMijiaSmartTowerFan_FanSpeedLevel label="Windstärke [%s%%] "step=1 minValue=1 maxValue=100
  Switch item=XiaomiMijiaSmartTowerFan_FanHorizontalSwing
  Switch item=XiaomiMijiaSmartTowerFan_FanMotorControl label="Justierung []" mappings=[1="Links", 2="Rechts"] visibility=[XiaomiMijiaSmartTowerFan_FanHorizontalSwing==OFF]
  Setpoint item=XiaomiMijiaSmartTowerFan_FanHorizontalAngle label="Drehwinkel [%s°]" step=30 minValue=30 maxValue=150
  Setpoint item=XiaomiMijiaSmartTowerFan_FanPowerOffDelayTime label="geplante Abschaltung [%s min]" step=1 minValue=0 maxValue=480
  Switch item=XiaomiMijiaSmartTowerFan_FanAlarm
  Switch item=XiaomiMijiaSmartTowerFan_FanBrightness
  Switch item=XiaomiMijiaSmartTowerFan_PhysicalControlLocked

And the tuned dmaker.fan.p9-miot.json file:
dmaker.fan.p9-miot.json (5.6 KB)

1 Like

Thank you again @marcel_verpaalen for helping me here with tons of information and links. :+1:

Will this be implemented in a future version of the binding or will I need to keep the json file im place to run the tower fan?