Mi Connector and Xiaomi

Carrying on the conversation from here, regarding Xiaomi devices and the Mi Connector app. I'd been struggling to keep my Xiaomi contacts and motion sensors connected for a while now. They were always solid for me on ST, and for a long while HE too, until the past few months that is.

I decided to remove them all and restart building my Zigbee mesh, throwing in 3 Xbees along the way. Even with the Xbees, they wouldn't stay connected, so I removed them for good. Then I came across @fison67's Mi Connector app and wanted to look into this further. After buying two Xiaomi hubs, which neither would work with Mi Connector, I took a last stab and bought an older version, model DGNWG02LM (I can’t say this will work for all but has done for me). Although this hub is working for me.

There’s a very long thread on ST regarding Mi Connector, which is worth a read.

The app and instructions are here

I'm running the app on my QNAP docker (feel free to PM me if you have questions), which isn’t so far away from the instructions in the link above for the Synology NAS. Or you can run the app on a PI.

You also must set the Xiaomi mobile app into developer mode, which can be tricky if you can’t read Chinese, but there are many posts around on how to do this. The app could find my Xiaomi hub fine; however, it couldn’t obtain the token from it (which is required). You can obtain this once you have the hub in developer mode manually. Some simple instructions here for that.

For iOS: You first need to enable local network functions by using the iOS Mi Home App iosApp Mi

Here is what I did.

  1. Open the Xiaomi app, and select your hub.

  2. Select More Options.

  3. Select the 3 dots at the top right

  4. Hit "About"

  5. Tap in the middle of the screen a few times and a menu will appear

  6. Some options are in Chinese, select the one below to enter the network options
    image

  7. Set the switch to on.
    image
    Some say note your password below the switch, although I haven’t needed that as yet.

  8. Back in the options, select the next option down, this will give you the Token for the hub (this is needed).
    image

  9. Hit the bottom right button which will copy all text, open a mail and paste in the details and mail it to yourself. The Token is needed for the next step.

  10. In the Mi Connect app, select "Manage Devices", "Device List" then "Add".
    image

  11. Add your Hub IP and paste the token in from step 9.
    image

  12. Go to "Add Devices ST" and you should see your hub listed. At this point you need all the required drivers in HE from GitHub.

  13. Once the drivers are installed in HE, you can select the devices in the Mi Connector App and then register them. They should then be passed to HE for you to rename.

Tips.
Try to make sure the Xiaomi hub you buy will work, this is the tricky part. I found that model DGNWG02LM works for me. The Aqara version will not work, and you also need to have the Xiaomi server set as Mainland China (I believe you can block net access once installed, if you’re worried about sending data to their servers, although I haven’t tried this yet)
If your devices aren’t being found on the Mi Connector after adding to the Xiaomi app, restart your docker or PI. They should then appear.
If you try to register a device in Mi Connector and receive an "undefined" error, then you don’t have the correct driver in HE.
The devices add process will add generic names to the devices in HE, but the DNI should point you to which device you are dealing with (see the details you mailed to yourself in step 9). If adding a few devices at once, it can be tricky to understand which device, is which.

But many thanks to @fison67 for a great app, and helping me keep my Xiaomi devices, and not relegate them to the "spare parts" box :+1:

8 Likes

Have you tried changing the channels? I had a problems keeping things connected and then I did a scan of local wifi signals (fortunately my AP can do that) to determine channels and signal strengths and then changed my own wifi and zigbee channels to be as far away as possible in my case wifi 12 and zigbee 13.

I also took advice from the community and moved all my bulbs off and swapped to hue based bulbs.

So far it's been pretty solid over the past week. One day I might even test to see if they survive an outage :grinning:

1 Like

Yup, I have tried all (and I mean all) over a long period.
I have no ZLL devices on HE, I keep them on Hue. I also removed any bad repeaters I found when scanning with my Xbees.

They would pair fine, but just wouldnt stay fine. They'd drop after a few hours. In the end I gave up, and at least now I have less stress and more time on my hands :wink:

But like I say, perviously these devices were fine, I'd had them on HE with no problems for over a year. :expressionless:

4 Likes

Epic post man. :+1:t3:

3 Likes

Fantastic! If I wasn’t getting the good results from the Aqara HomeKit hub, this would be my preferred choice. Very well written instructions indeed.

Great that there is an option that doesn’t require one to be deep into Apple gear.

3 Likes

@Royski

Really good instructions! Thanks so much. If my Xiaomi devices start falling off, this is the route I'm taking.

2 Likes

For anyone else interested in duplicating @Royski's setup, I did a search on eBay/AliExpress/GearBest/Banggood for the cheapest price on the Xiaomi Mijia Gateway (model: DGNWG02LM) - the same unit described above by Roy.

The cheapest I found was on AliExpress, at the Mi smartHome Store. The base unit (fits Chinese wall-socket) is $21.40. With any other socket adapter (EU/UK/AU/US), it is $22.30.

That particular AliExpress store accepts PayPal, with a surcharge of $0.90. So my total checkout price was $23.20.

Once again, @Royski - thanks so much!

And @fison67 - for making this possible!

2 Likes

This is the one I ordered, but the same model number :+1:

2 Likes

Interesting that it decided to simply fall off like that. I wonder if there was a new AP introduced in your area (neighbour replacing their gear for example) that caused this.

Still, it underlies the potential fragility of these systems. Fortunately I have the same hub as you so if mine goes to crap I have another route to go.

Thanks for sharing!

1 Like

Hi @Royski
First of all, thanks for posting this and passing on the info. Much appreciated.
I have an RPi and have followed the instructions and installed 'docker' OK.
Looking at the github repository I can see all the drivers which are still correct for ST.
I'm assuming you just converted these to use with HE? (replace physicalgraph with hubitat).
I haven't got a MiHome hub yet but may order one if I get problems with these devices again.
Is there any other pertinent info that you think we may need to know?
Also, how are these behaving for you now. Any issues or have they been solid for you.
Thanks again.

Hi @bobbles,

The drivers are for HE, so all good.
Mine have been solid, and once back to work next week (from home :wink:) I’ll be moving all others over. Speed of execution has been very good too, so no complaints here :+1:

Ah ha.
Found them.
Thanks.

EDIT: One more thing, sorry.
Did you use Xiaomi Gateway or Xiaomi Gateway2.

1 Like

I added both drivers just in case. But it’s used the Xiaomi Gateway driver.

2 Likes

Hi @Royski
Sorry to be a pain but I've hit a brick wall.
I've managed to complete everything up to step 10.
This is where I'm getting a bit lost.

What is this in? I'm assuming in the Xiaomi Home app but I'm not seeing this. I'm on an Android if that makes a difference.
Thanks.

NP :slight_smile:

Ok, do you have your token for the Xiaomi hub?

If so, add the IP of the Hub, and then the Token.
You use this in the Mi Connector (docker or rPI) app.

I have the token.
Everything was good from points 1 to 9.
This is what I'm seeing in the Mi Connector app. I'm using an RPi with docker installed.
Never used it before so I'm not sure what else I need to do with 'docker'.

Ah ok, so on that part you need to follow the install part for either Docker or the rPI from here mate.

Once thats installed, you navigate to the http://Mi_connector_IP:30000/ address and thats where you pick up step 10. Maybe I should have been more clear there, but did assume that would be already done :wink:

Ah ha. That would be my fault.
When I see instructions I just follow them blindly. :blush:
I'll let you know how I get on.

1 Like

I cant blame you either, especially when I'm also a "skimmer" :joy:

I have already installed docker but didn't do the last bit. My fault.

1 Like