Not able to get Xiaomi Gateway Key

Lucky! Too good Reunion. :call_me_hand:t2: Ok, I have the Chinese version ZHWG11LM and don’t understand why I haven’t the xiaomi_aqara.play_ringtone :anguished: while I already add it with Homekit several times.

If at random on the net you find me a reference I would be interested :stuck_out_tongue_winking_eye: because I have already returned 2 which were in the end version 3 without a speaker. :expressionless:

If anyone don’t want to risk install an unofficial emulator,
or turn off windows features like WSL or VM,

You could use Android Studio, Android Emulator, and install apk on that instead.

It works also.

Had to do fresh install of hass once again since for some reason I couldn’t access my device.
I’m not sure what just happened but I was still able to get the ‘about’ option to access the key just a few weeks ago on my android phone.
Anyone faced the same problem like I did?
Nvm, just had to reinstall old version of mihome

Wich one did you install? I just change my server so I have the same issue. I tried 6.2.602 but not old enough :confused:

I used 5.1.37

It’s linked in my comment above

Tried this method and also replacing the main.bundle file for the correct device (different folders for latest vevs version). Nothing worked. Does this still work for anyone?

i just use the modified app Mi Home :

https://www.kapiba.ru

and update the app manually with apk download every month

Windows:
Download and run token_extractor

Or

1 Like

A solution for Xiaomi Smart Home Gateway 2 (DGNWG02LM, lumi.gateway.v3, chinese version), tested on firmware 1.4.1_17:

To enable developer mode or so called “LAN function” in Xiaomi Gateway 2 after the ability to do this was removed from Xiaomi Home App, use xiaomi-cloud-tokens-extractor and miiocli tools.

  1. You need to extract a token of your gateway from Xiaomi Cloud using xiaomi-cloud-tokens-extractor - just pull it, run and enter your cloud credentials. As output you will get a list of your devices and their tokens.

  2. Use previously extracted token as parameter for miiocli tool command to set manualy Developer Key in your Gateway (key value can be a random 16 bytes long alpha-numeric string), example:

miiocli gateway --ip 192.168.1.7 --token 652e1b285fef684209500a22d5be62f8 set_developer_key f40e1b285fes682r09100

As you got an output…

Running command set_developer_key
[‘ok’]

… your gateway is in developer or “LAN function” mode.

7 Likes

Hey,

The extraction of the tokens worked like a charm but i dont have c++ so i cant install miio. Is there some other way to get it to work?

Are you on a windows machine?

Hi everyone,
I’ve been dealing this the issues on the Gateway Aqara integration for a while, until I found the following video in youtube and everything was resolved IN MINUTES!!

It’s in spanish, however the briefing is: download the Mi Home application (ancient version) that is shared in the comments of the video (Google Drive) and install it in your phone (desinstall the current version previously).

https://drive.google.com/file/d/16cyD…

Once you have the ancient version you can acces to the LAN menu and finish very smoothly the integration. It took me just a few minutes.

Hope it helps you !!

3 Likes

I have 3 gateway devices:
ZNDMWG03LM (china version) v3
DGNWG02LM (Chinese version) v2
DGNWG05LM (Europe version) v2

I don’t think I will need v3 anymore, because I have WiFi, BT, and Zigbee in the NUC device.

I will need the v2, only for the lamp (to connect with the xiaomi motion sensor and use it as a night light) and for the speaker, to connect it with 2 pieces of xiaomi door sensors (when the door is opened, to ring, and if the door is left open longer than 2 minutes, also to ring)

I’m interested in which v2 version is easy to connect to Home assistant, EU or China? And if you can leave me the tutorial according to which you connected the gateway?

This seems like the most straightforward way to do this.
I’ve tried this and also the “ancient APK” method from the Spanish video below.

Nevertheless, in all cases even though the methods “succeed” (e.g.: set_developer_key = OK) I don’t see the Gatewey opening it’s port to LAN connections:

(venv) ➜  temp sudo nmap -sU 192.168.68.60 -p 9898                                                                                

Starting Nmap 7.60 ( https://nmap.org ) at 2023-02-15 09:51 -03
Nmap scan report for 192.168.68.60
Host is up (0.059s latency).

PORT     STATE  SERVICE
9898/udp closed monkeycom
MAC Address: 04:CF:8C:xx:xx:xx (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 0.67 seconds

Before I open apart the device, am I missing something obvious such as a reboot or a part change for any of these “Enable developer mode / LAN function” to take effect?

Thanks for any guidance provided!

I have the token for my Gateway v3 but can’t get the key. I have tried lots of versions of the Mi Home app and tried the set-developer-key option using the python miio app but that gives me this:
“ERROR:miio.miioprotocol:Got error when receiving: {‘code’: -9999, ‘message’: ‘user ack timeout’}”
Anyone else get this error or know how to fix it?

thanks

DGNWG02LM (Chinese version) v2 china server
DGNWG05LM (Europe version) v2 EU server

get the token with https://github.com/AlexxIT/XiaomiGateway3

1 Like

Thanks, but I have the token, I need the key

Hi, I’ve token and set developer key on my Xiaomi Gateway 2 (lumi.gateway.v3) but I can’t open port 9898, I tried with some anciest version of Mi app but there not see the gateway, in those version. Any suggestion?

Any news how to enable LAN easily?