DreamMaker Feel Fan Plus / Dream Maker DM-FAN02-W

Hello Home Assistant Community,

did someone already try to implement an DreamMaker Fan (for example the DM-FAN02-W) into Home Assistant?
The Fan is similar to the Xiaomi Fans and the Xiaomi Models without the Smartme branding are produced by DreamMaker.
The Fan is shown in the Xiaomi Home App but cannot be added at the moment. It Uses an ESP8266.

In my opinions there are two possibilities to get it implemented:

  • Bluetooth (The Remote uses Bluetooth)
  • Via the Xiaomi Token (can not be extracted at the moment)
3 Likes

I am also interested in this. I got my fan just this week and it is a DM-FAN02-W (Freedom Version). I made pretty much the same experience as you did. Right now it does not seem to be supported by any open source tool or library. So let’s start collecting some deeper insights about this device.

Device Wifi

  • When the device is reset, it creates an open WiFi called dm-fan02-w_dmiot_xxxxxx
  • You can connect to this WiFi and you’ll get an IPv4 address in the 192.168.4.0/24 network
  • The fan listens on 192.168.4.1:8080 for data but I could not get any reply yet
  • I have played around with python-miio/discovery/mDNS in this state (also with a string which could potentionally be a token, read more later), without any success.
  • So right now it looks like nothing can be done with the device’s open wifi. The official Dream Maker app does not use it for provisioning (see below) so I was not able to sniff anything useful.

Official Dream Maker App

The app is available for iOS and Android. The Android version is not available on the Play Store, but can be downloaded here: http://m.dm-maker.com/app.html?type=plus
Although the website is Chinese, the app is also available in English language. You need to have a Dream Maker account in order to use the app (sigh). This is what the app does when adding the fan:

  • Perform discovery using Bluetooth (BLE)
  • Provision the WiFi network including some sort of device token via Bluetooth Attribute Protocol
  • The fan then connects to the provisioned WiFi and contacts the Dream Maker servers. From now on it is controllable through the Dream Maker app. From what I can see the fan is always controlled through the cloud. Apparently the app does not support controlling the device locally. :rage:

I was able to pull some data from the Android app, the file /data/data/com.dmaker.purihome/shared_prefs/com.dmaker.purihome_preferences.xml contains the most interesting parts. It contains a string value for mps_deviceId_300xxxxx which looks similar to the token known from the MIIO devices (32 character string). However I was not able to do anything useful with it. And unlike the MIIO tokens this string does not change after resetting the device.

Xiaomi Mi Home App [dead end currently]

When setting your Xiaomi server to Germany or Singapore you can actually select the „Dream Maker Feel Fan Plus“ in there. Apparently it tries to discover the fan by WiFi (unlike the official Dream Maker app) and tries to connect to dmaker-fan-02_mibtxxxx. This is where the process stops, the fan cannot be found by the app. Note the difference in the WiFi names! Maybe it’s due to the so-called „Freedom Version“ which I got :slight_smile:

Xiaomi Mi Home App (alternate way) [dead end currently]

There seems to be another way to add this fan to the Mi Home App. Since the fan can be controlled through the MI IoT protocol you can link your Dream Maker account through the Mi Home App to your Xiaomi Account. This seems to be supported only if you set the server region to China in the Mi Home app. Here’s how you can link the Dream Maker account:

  1. Open Mi Home App (server needs to be set to Chinese mainland)
  2. Open “Profile”
  3. Click „Other platform devices“
  4. Select Dream Maker in the “Pair with account” list
  5. Sign In. This is where the process stops for non-Chinese users. The dialogs are all in Chinese and you need a phone number for signing into your Dream Maker account. This is not possible for non-Chinese people.

But from what I understand this would not help a lot anyway. Even if the linking of the Dream Maker account would be successful, control would still go through multiple cloud servers (through MI IOT protocol). There is a GitHub issue with a nice picture which demonstrates the protocol flow:

Conclusion

  • I was not able to add the device to the Mi Home App.
  • We still need to figure out what can be done through the local WiFi.
  • The coolest thing would be if somebody would come up with a custom firmware for this ESP8266 device. I don’t know how hard this is as I have no experiences with ESPHome and the like.
1 Like

So, it looks like something can be done. I was able to sniff the communication between the Dream Maker servers and the fan, as it is not encrypted (WTF?). To me it looks like the protocol is just JSON over a TCP socket. This is what my fan does after it connects to my local WiFi (if it has been provisioned through the Dream Maker app):

  1. Request IP over DHCP (obviously)
  2. DNS lookup for cloud1.dm-maker.com
  3. Contact cloud1.dm-maker.com at port 31270 over TCP
  4. After an initial handshake (which looks a bit weird to me: SYN, SYN-ACK, ACK, FIN-ACK, ACK, FIN-ACK, ACK) a persistent TCP connection is established between the fan and the server. Data is pushed around between the fan and the server using PSH packets. This how the communication starts (server pushes):
{"action":81,"resource_id":127,"version":"zeico_3.0.0","code":0}

The fan then sends the following data to the server:

{"action": 1,"resource_id":2001,"version":"zeico_3.0.0","code":0,"msg_id":0,"data":{"product_id":"XXXXXX","device_id":"XXXXX","device_key":"XXXXX","comm_version":"dmiot_v1.1.0","rf_version":"v3.1.6","mcu_version":"fan_0001"}}

So this looks like the authentication. Unfortunately I could not find how device_id/device_key relate to any settings in the Dream Maker app. For now this is not important anyway I think.

The fan periodically pushes updates to the server. This is pushed through the same TCP stream, so no reauthentication is required:

{"action": 1,"resource_id":127,"version":"zeico_3.0.0","data":{"comm_version":"dmiot_v1.1.0","rf_version":"v3.1.6","mcu_version":"fan_0001","signal":38}}

The server always replies with:

{"action":81,"resource_id":127,"version":"zeico_3.0.0","code":0}

The server also pushes data to the fan like this (when turning on through the app):

{"action":4,"resource_id":9031,"version":"zeico_3.0.0","data":{"source":"manual","power":1},"msg_id":47912}

And the fan replies:

{"action": 84,  "version":"zeico_3.0.0","resource_id":9031,"msg_id":47912,"code":0,"data":{"source":"manual","deviceException":0,"useException":0,"power":1,"mode":0,"speed":1,"roll_enable":0,"roll_angle":90,"power_delay":0,"sound":1,"light":1,"child_lock":0,"temperature":25.0,"humidity":59.0,"ext1":97,"ext2":102,"ext3":24884,"ext4":25137,"ext5":943206968,"ext6":1630823777}}

So this looks like a rather simple protocol. The question is: does the protocol look familiar to anybody? Ideally we could reuse some existing implementation of it.

Rewriting a TCP server from scratch would definitely be doable, but it’s still quite a lot of work. Integrating that thing into Home Assistant is probably the least problem, once a little implementation for this exists. Maybe we could also go the MQTT way, which translates the JSON requests into MQTT topics and commands.

If somebody want’s to get started, just provision your fan through the official app and change the DNS record for cloud1.dm-maker.com later to point to a local dev machine. Writing a little Python TCP server which listens on port 31270 and does the JSON magic is definitely possible.

Only once this is done it makes sense to look at the provisioning of the fan I think. As I said earlier this is done over BLE. From my observations it’s just writing to 4 different attributes using GATT (SSID at handle 0x002a, Wifi-Password at handle 0x002c, unknown 6 byte value at handle 0x002e and unknown 4 byte value at handle 0x0030).

I will be gone for a longer time as we are expecting a child very very soon. Does anybody accept the challenge?

2 Likes

I would love to contribute and I have time- just no experience with TCP. Maye there’s some more dumb work I could do, or maybe someone can point me to a good summary/tutorial?

The protocol looks new to me, but it’s simple enough. TCP server should also be not too hard. I guess I’ll be able to look into this by the end of next month.

2 Likes

It turned out that the implementation was even simpler than I thought. I have just finished an initial proof-of-concept Python server which acts as a bridge between the Dream Maker protocol and MQTT:

At this point in time it is already functional but far from complete. If anybody wants to write more user documentation I’ll happily accept merge requests :smiley:

I have also created a script for provisioning the fan over BLE. So it is possible to use the fan completely independent from any Chinese phone apps.

Things that need to be improved:

  • I am not happy with the ini configuration. We could also configure the entire MQTT uri through a command line switch and ditch the ini.
  • setup.py script is missing
  • systemd unit file is missing
3 Likes

Really nice job, unfortunately it is way beyond my knowledge to test it :grinning:
Can we expect an implementation which is more digestable? Don’t want to be look greedy, but this python thing is not easy for me (I think I can deal with the MQTT part). Thank you for your work :+1:

1 Like

So if you ran HA on a rpi, couldn’t you use that as the host for the python file?

Sure you can run this on the same machine as HA. It only needs to listen on TCP port 31270, which should not be conflicting with HA at all.

Alright, looks like I’ll have to wait for a more “polished” implementation or more extensive documentation as I don’t even know where to begin asking questions :sweat_smile:
Great to see you got it working though, very promising!

Edit: I guess I do know where to start - how would I install amqtt on a HA server, and how would I run the service? As pip and python3 do not seem to be available?

Hello,
Thank you very much, i got 2 with battery , and added just 2 without (each about 20 Euro)
I can only use the code, maybe I can do a short install Guide.
Is ist necessary to keep the DNS rebind, or is it just necessary for the setup?
After Setup i could block the internet access for the fans.

The fake DNS-records need to be kept permanently. And yes, you can block internet access for the fans.

You can also provision the fans through Bluetooth if you are using Linux (script is included in the git repo), so there is no need to enter your WiFi credentials in any Chinese app. Also see the doc folder on GitHub.

1 Like

Thank you a lot, it seems that dreammaker new app doesn’t support the fan anymore, so your script is the only way to get it connected and controlled.
Some people have the fans still in there app (I think 1.2)
But you can’t add fans at the moment.

Maybe anyone could tell me if there is any chance we could use esphome with this fan?
It has a esp32-wroom-32d and pinouts are rxd rxd gnd and boot.

And this is the remote, maybe we could use Bluetooth to remote control the fan.

Unfortunately have the same problem.
Last year everything worked fine with the app. This year no longer (same app version). When starting the app, I had to log in again. But did not work with the saved credentials from the PasswordSafe.
Device reset did not help. Now it beeps again every time I press a button :frowning:

1 Like

Exactly the same happened to me :confused:

I really regret resetting the fan, I should have just sticked to the bluetooth remote, but now the fan is back to that annoying loud beep on every input, and the constantly glowing lights, both of which could only be disabled via the app …

Just a quick heads up: I was trying to get this to work with @direx python script but sadly with no success (the fan didn’t seem to connect to the server :/).

But while doing so I noticed that the Dream Maker App was working again like it did a year ago, so I could just login (with the newly created account), reset my fan and add it the “regular” way to the app.

While this may not be the best approach (still having to rely on some chinese server and app), it was enough for me, as I could finally disable the fan’s beeps and status LEDs again. As I usually control the fan via the Bluetooth remote, that solution is fine for me (at least for now) :slight_smile:

I am trying to add the device again in the dm+ app after I had to create a new account and reset my fan. Cannot find the manual. How did you manage to connect it again? I was able to reset the device, but it is not discovered in the app.

Hmm, mine was discovered automatically after resetting it :confused:

Do you have an entry for “Dream Maker Feel Fan Plus” when you try to manually add a new device? While the app was broken, I only had 4-5 devices in that list, and the fan wasn’t part of it. Now that it’s working again (at least for me), I have once again many devices (about ~20) including the fan in that list.

You should set to Macao China the region in app settings, this worked for me.

I’m on version 1.1.1 of the app (package: com.dmaker.purihome), and I don’t have any region settings.