Cannot connect Xiaomi Gateway (lumi.gateway.v3) to HA

I wonder if it is possible to downgrade the firmware.

Can you detail the versions involved? “New”, “current” and “old” lose their meaning very rapidly.

Hello @nickrout ,

I forgot to note down the returned gateway’s fw/hw version but the firmware was updated to the latest
The new working device has a fw_ver: 1.4.1_149 hw_ver:MW300, mcu_fw_ver:0143

Regards,

Be aware someone reported their Gateway stopped working on the new update. My current one is still working.
SmartSelect_20181122-043650_Mi%20Home

1 Like

Good day! I have the same problem with the gateway, HA does not see it, nor does it show that the ports are also closed from the command line. Firmware last updated immediately after unpacking the package! Does anyone have a thread of thought how to roll back the firmware to the gateway?


Please stop posting pictures of your terminal session. Copy and paste is quite well established now.

I just setup a Mi gateway (has the M shield logo on the front) and stupidly first thing I did was update the firmware. Though it does look like the required ports are open on the device after enabling dev mode and multicast on the router:

nmap -sU -Pn 192.168.100.175 -p 9898,4321
Starting Nmap 7.70 ( https://nmap.org ) at 2018-11-22 09:08 Pacific Standard Time
Nmap scan report for 192.168.100.175
Host is up (0.11s latency).

PORT     STATE         SERVICE
4321/udp open|filtered rwhois
9898/udp open          monkeycom
MAC Address: 7C:49:EB:B0:9E:E2 (Unknown)

I’m not actually running HA any more (moved to pure node-red) but the node red extension won’t connect to the hub so not sure if the same issue. Are there any other command line tools etc I can use to confirm developer mode wifi access is still working?

Did some digging.

Here’s a the docs to the protocol Xiaomi gateways use, specially listing the LAN connectivity stuff:
http://docs.opencloud.aqara.cn/en/development/gateway-LAN-communication/#discover-the-gateway-device

So from that doc it says to send a “whois” message over UDP to the gateway. On windows these are the steps I found easiest, if someone knows a good cmd line/Linux way for doing the same please post.

  1. Get your Gateway’s IP from your router.
  2. Go get this tool https://packetsender.com/ . Seems legit but DL at own risk.
  3. Open the Packet Sender app and set these options:
    ASCII:{"cmd":"whois"}
    Address:Gatway IP address
    Port:4321
    After port there’s a dropdown to chose the protocol. Probably set to TCP by default. Change it to UDP.
  4. Hit the Send button.
  5. In the log at the bottom of the app a couple of entries should appear. I received this message from the gateway:
    {"cmd":"iam","port":"9898","sid":"7c49ebb09ee2","model":"gateway","proto_version":"1.1.2","ip":"192.168.100.175"}

So now I know I can connect to the gateway and the LAN protocol stuff seems to be working.

Now notice the proto_version returned from the gateway is 1.1.2, so this is actually refering to these docs:
https://aqara.gitbooks.io/lumi-gateway-lan-communication-api/content/chapter1.html

I then sent {"cmd" : "get_id_list"} to the gateway on port 9898, this worked and returned a list of my devices. v2 of the protocol is {"cmd" : "discovery"} . So now I know my gateway is working and I can get a list of devices using firmware version 1.4.1_159.0143. Maybe newer gateway hardware/ future firmware versions use v2 of the communication protocol. Either way I’ve proved my gateway works correctly and the issue is elsewhere.

PS:
If you want to get the status of a specific device connected to the gateway, use this: {"cmd":"read","sid":"SID_OF_DEVICE"}

1 Like

Cool, well done! Linux equivalent:

echo '{"cmd":"whois"}' | nc -u ipaddressofgateway 4321

That looks considerably easier than Powerhell :stuck_out_tongue:

My issue ended up being an incompatibility with newer versions of node-red and the node-red-contrib-mi-devices package: https://github.com/pierrecle/node-red-contrib-mi-devices/issues/42

Was also trivial to build a node-red flow to send/receive the UDP packets to achieve the same as above.

1 Like

I have the same problem with a new extra gateway:
root@kali:~# nmap -sU -Pnnmap -sU -Pn 192.168.2.24 -p 9898,4321
Starting Nmap 7.70 ( https://nmap.org ) at 2018-11-24 17:45 CET
Nmap scan report for XiaomiGateway2.XXXXX.it (192.168.2.24)
Host is up (0.082s latency).

PORT STATE SERVICE
4321/udp closed rwhois
9898/udp closed monkeycom
MAC Address: 7C:49:EB:B1:B5:77 (Unknown)

Is there any solution ?
Downgrade
Opening the port?

Thanks

1 Like

What do you mean “opening the port”?

I have bought gateway yesterday and have the same problem, too.

1 Like

It is not possible to open ports in developer mode.

Check you have the Chinese version. I’ve seen on forums people have had trouble with units purchased in HK etc.

Nmap says ports are closed.
I wondered if in the meantime someone figured out how to open them (via commands downgrade or other)
Opened a dispute but I guess it is a though call (works with app). I asked for a discount on a new unit. Will ask for a Chinese unit :slight_smile:

I don’t know of any commands beyond those documented in the pages pointed to above.

So this is where I purchased mine:
https://www.ebay.com/itm/For-Xiaomi-Smart-Multifunctional-Gateway-Temperature-Motion-Sensor-APP-Switch/183182614913?ssPageName=STRK%3AMEBIDX%3AIT&var=690459464473&_trksid=p2057872.m2749.l2649

What I did:

  1. Make sure you have a 2.4GHz wifi network. Wont work with 5Ghz.
  2. Make sure your wifi SSID doesn’t have any special characters. Mine is english letters and numbers (Usually bad to start the SSID with a number). Haven’t tried but maybe special characters in your wifi password might affect it.
  3. Get an Android device to setup the gateway from the app. iOS sucks for setup at least.
  4. Updated the firmware to 1.4.1_159.0143
  5. Enable developer mode on the gateway.
  6. Make sure the gateway is within a couple of meters of your wifi router during setup.
  7. Enable multicast on your router.
  8. RESTART EVERYTHING. Router, gateway, phone
  9. Check if the ports are open on the gateway.
  10. Did the stuff in my previous post to test if the LAN functionality was working.

Other things to check:
Firewall on the device you’re trying to access the gateway from
That you can ping the gateway
The first key the gateway generated in dev mode may not have been valid, try generating a new key

1 Like

Good day! Are there any other suggestions for solving problems

Hi, thanks for all the info on this thread.
I have been using my lumi.gateway.v3 for two years and had no issues with developer/lan mode and I’m running the latest update, see attached image.

But I have a friend with same v3 gateway but new install and has this problem where the udp data is not working.
Having read through the post it seems to be;

  1. Setup issue, where the previous 1-10 checklist will help.
  2. Hardware batch issue
  3. Firmware issue
  4. OR Xiaomi are starting to remove the Dev/Lan mode support from their Gateway !
    Let’s hope for OpenLab, HomeAssistant and all others its not (4).

Has anyone got any Xiaomi support contacts who can confirm if this is a known problem.

1 Like

Hi, my very first post here.
It appears that the following has finally worked with my copy of the gateway model lumi.gateway.v3 and my dockerized HA.
The host string is critical as without it my gateway was never visible to HA after enabling the wireless communication protocol:

apj@zbook15:~$ sudo nmap -sU -Pn 10.10.10.9 -p 9898,4321

Starting Nmap 7.60 ( https://nmap.org ) at 2019-01-27 23:29 GMT
Nmap scan report for lumi-gateway-v3_miio98956133 (10.10.10.9)
Host is up (0.0080s latency).

PORT     STATE         SERVICE
4321/udp open|filtered rwhois
9898/udp open          monkeycom

Nmap done: 1 IP address (1 host up) scanned in 1.57 seconds
apj@zbook15:~$ echo '{"cmd":"whois"}' | nc -u 10.10.10.9 4321
{"cmd":"iam","port":"9898","sid":"7c49edd1e100","model":"gateway","proto_version":"1.1.2","ip":"10.10.10.9"}        

xiaomi_aqara:
discovery_retry: 10
gateways:
- mac: XXXXXXXXXX (remove all “:” and use lower case letters )
host: XXX.XXX.XX.XX
key: XXXXXXXXXXXXXXXX