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

Chances are pretty good that the ports are open if HA can communicate with them. I had to rip my first one open because I was too eager and left the fw update go through before getting it into HA. It was easy to fix though since I found a pretty straight forward tutorial

Thanks guys, just to be sure I did confirm by installing nmap (never knew this great thing existed)
https://nmap.org/download.html

Got

PORT     STATE SERVICE

9898/udp open  monkeycom

:crossed_fingers:

Good, it should work then.

1 Like

Just upgraded to 1.4.1_167.0158 and everything is working fine.

Reminder for everyone to check in LAN on the gateway is open https://medium.com/@likeguitarz/home-assistant-how-to-get-xiaomi-home-gateway-lan-password-key-and-mac-address-100d54083446

and if you’re bothered, install https://nmap.org/download.html and run Nmap -sU IPofgateway -p 9898 to make sure 9898 port is open
then update away

Thanks all for the help

Hello,

I have a lumi-gateway-v3_miio83880019 and i can see my sensors but not my gateway in HA, i try nmap the result is :

PORT     STATE SERVICE

9898/udp open  monkeycom

MAC Address: 78:11:DC:FB:2B:35 (Xiaomi Electronics,co.)

so i am happy to dont have to soldered and open the box, but i dont understand what is wrong in my config?

Do i need to reset all, connect into Mi Home, suppress the gateway and go to HA with :

xiaomi_aqara:
  discovery_retry: 5
  gateways:
    - host: 192.168.1.55
      key: xxxxxxxxxxxxxxxx

and the gateway should appear in notification?

I make a precision : i have a lumi-gateway installed with homekit_controller first.
So i unstall all from Mi Home and try to just add the lumi-gateway-v3_miio83880019.

Thanks for a response…what a mess…

Just got a xiaomi hub update 1.4.1_170.0158 come through… Still no open 9898 port :roll_eyes: this leads me to believe it will never be opened again… not Game to do the update on my working hub.

Just so you’re aware, as long as the port is already opened, updating the FW will not break it. I’m running the latest FW on 3 hubs and all 3 are in HA perfectly.

If you aren’t waiting for any feature enhancements, just assign them static addresses and then disable external traffic to those IPs via your router.

To get the ports open, it’s a pretty easy process, follow these instructions. I had to do it on my first hub because I updated the FW before I opened the ports.

Hi everyone.

i’m hitting into this trouble too. You all mention opening ports but what does that mean? Is it port forwarding?

The ports referred here are the ports that open when you enable network mode (or whatever it’s called in the hub settings in the xiaomi mi home app).

Basically, what happens is you need to enable the “local control mode”, mentioned above, I believe they call it network mode, and when you do, if you have an older version of firmware, it will open these required ports up for you. The problems are: A, it has been reported that some units are now being shipped with the newer broken firmware that doesn’t open the ports, and B, the app instantly and obnoxiously tries to get you to update the firmware when you first go to the settings page you need to go to. B can be avoided if you navigate quickly, but you have to click options, then “about” almost simultaneously or you’ll get the FW prompt and have to start over.

If you look at my last post, I pasted a link to a way to manually open the 2 ports that are SUPPOSED to open when you enable network mode in the app. It requires minimal to little solder skills, and the ability to follow a very easy to read list of commands (in the link above), but once finished, you’ll be able to get the states and everything in HA right away. It doesn’t break any existing functionality either, it’s litterally just opening ports that the app is supposed to open, but xiaomi doesn’t seem to be too concerned to fix it

2 Likes

Hi Justin,

Thanks a lot for this explanation it makes sense and i do have the new firmware unfortunately so looks like the hub is naff for getting into HA at the minute.

In that post do you know roughly where the guide is as there’s 207 comments so quite a few to scroll through to find it, unless you know exactly where it is.

Ah sorry, that link used to take you directly to the post I was referring to, it must’ve changed. I found it and just copied the text, but all the credit goes to the guy at the end of it.

well, tried to set param network.open_pf to 3 - it helped me!
Can see gateway in openhab, iobroker and 9898 port is opened.

FAQ:

  1. Find specific screw bit like fork to open gateway case.
  2. Find UART cable/board.
  3. Solder 3 wires GND and RX / TX like here (Image .
  4. Disconnect RX wire from UART module.
  5. Dont connect Vcc (power) from UART to gateway.
  6. Turn on gateway (220V).
  7. Open putty application, connect to serial port (COM1-30) -select yours one0.
  8. Wait for fully load of gateway, connect RX wire to UART.
  9. You will see all messages of gateway.
  10. Send command psm-set network.open_pf 3 , send it few time in case it was spammed by gateway and it can be lost in msgs…
  11. Check your param by command psm-get network.open_pf to be sure its OK.
  12. Turn off gateway.
  13. Turn it ON.
  14. Check your port.
  15. Say thx to this guy - ds2003
2 Likes

Hi me again,

Long story short i got an extra hub today and managed to not update the firmware so i am on ver 1.4.1_150. Will this firmware version open the ports needed for home assistant to communicate with it? I have managed to turn the wireless protocol on and added the key into HA but nothing appeared which is different to last time as last time it said aqara couldn’t be set up.

Any advice would be appreciated!

Just to add to this if i add the IP address I get the aqara config is invalid but if i add the MAC address or just the key nothing shows up in my notifications and i can’t see the device in the states section.

Did you ever get this working? same firmware and Hassio cannot connect to hub

I am on the newest firmware 1.4.1_170.0158.

I cannot get the hub to connect to hassio. Like you mentioned I updated after first turning on the hub and integrating it into the Mi Home app.

I was unaware I needed to put it LAN mode first.

Would this method work with my firmware? I am willing to open it up if it’ll work.

1 Like

Post logs, add the gateway device to

logger:

in your config. Restart, post us the config, and logs.

Check if port is open using nmap. Plenty of resources in this thread for how to check these things.

Hey,

thanks for helping here is what is in my logs when i search xiaomi after reboot

2019-07-10 20:23:57 INFO (MainThread) [homeassistant.setup] Setting up xiaomi_aqara
2019-07-10 20:23:58 INFO (SyncWorker_13) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 1)
2019-07-10 20:23:58 INFO (SyncWorker_13) [xiaomi_gateway] Xiaomi Gateway 04cf8c9147f5 found at IP 192.168.1.86
2019-07-10 20:23:58 INFO (SyncWorker_13) [xiaomi_gateway] Discovering Xiaomi Devices
2019-07-10 20:23:58 INFO (SyncWorker_13) [xiaomi_gateway] Found 1 devices
2019-07-10 20:24:03 INFO (SyncWorker_13) [xiaomi_gateway] Gateway discovery finished in 5 seconds
2019-07-10 20:24:03 INFO (SyncWorker_13) [xiaomi_gateway] Creating Multicast Socket
2019-07-10 20:24:04 INFO (MainThread) [homeassistant.setup] Setup of domain xiaomi_aqara took 7.0 seconds.
2019-07-10 20:24:04 INFO (MainThread) [homeassistant.components.switch] Setting up switch.xiaomi_aqara
2019-07-10 20:24:04 INFO (MainThread) [homeassistant.components.light] Setting up light.xiaomi_aqara
2019-07-10 20:24:04 INFO (MainThread) [homeassistant.components.lock] Setting up lock.xiaomi_aqara
2019-07-10 20:24:04 INFO (MainThread) [homeassistant.components.cover] Setting up cover.xiaomi_aqara
2019-07-10 20:24:05 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.xiaomi_aqara
2019-07-10 20:24:05 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.xiaomi_aqara
2019-07-10 20:24:16 INFO (SyncWorker_8) [homeassistant.loader] Loaded axis from homeassistant.components.axis
2019-07-10 20:24:28 INFO (MainThread) [homeassistant.components.discovery] Found new service: xiaomi_gw {'host': '192.168.1.86', 'port': 54321, 'hostname': 'lumi-gateway-v3_miio131979463.local.', 'properties': {'epoch': '1', 'mac': '04cf8c9147f5'}, 'mac_address': '04cf8c9147f5'}

my config is also

#Hub V2
xiaomi_aqara:
  discovery_retry: 5
  gateways:
      key: ulgzlmqpi0csw5rj

Also did nmap and it looks as though they are closed

Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-10 20:30 BST
NSE: Loaded 148 scripts for scanning.
NSE: Script Pre-scanning.
Initiating NSE at 20:30
Completed NSE at 20:30, 0.00s elapsed
Initiating NSE at 20:30
Completed NSE at 20:30, 0.00s elapsed
Initiating ARP Ping Scan at 20:30
Scanning 192.168.1.86 [1 port]
Completed ARP Ping Scan at 20:30, 0.05s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 20:30
Completed Parallel DNS resolution of 1 host. at 20:30, 0.02s elapsed
Initiating SYN Stealth Scan at 20:30
Scanning 192.168.1.86 [1000 ports]
Completed SYN Stealth Scan at 20:31, 3.43s elapsed (1000 total ports)
Initiating Service scan at 20:31
Initiating OS detection (try #1) against 192.168.1.86
NSE: Script scanning 192.168.1.86.
Initiating NSE at 20:31
Completed NSE at 20:31, 0.00s elapsed
Initiating NSE at 20:31
Completed NSE at 20:31, 0.00s elapsed
Nmap scan report for 192.168.1.86
Host is up (0.0094s latency).
All 1000 scanned ports on 192.168.1.86 are closed
MAC Address: 04:CF:8C:91:47:F5 (Unknown)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: specialized
Running: IHome embedded, iRobot embedded
OS CPE: cpe:/h:ihome:isp5wwc cpe:/h:irobot:roomba_980
OS details: IHome SmartPlug iSP5WWC, iRobot Roomba 980 vacuum cleaner
Network Distance: 1 hop

TRACEROUTE
HOP RTT     ADDRESS
1   9.40 ms 192.168.1.86

NSE: Script Post-scanning.
Initiating NSE at 20:31
Completed NSE at 20:31, 0.00s elapsed
Initiating NSE at 20:31
Completed NSE at 20:31, 0.00s elapsed
Read data files from: /usr/local/bin/../share/nmap
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.93 seconds
           Raw packets sent: 1117 (49.702KB) | Rcvd: 1007 (40.530KB)

Your logs look fine? or am I having a blonde moment?

Do you see your gateway or sensors in your states panel on hassio? if not, are there stil no errors in your log? like failed to setup switch.xiaomi_aqara…

Also, not sure why your port is not opened, could be a number of things to try if its still not working, like turning on and off LAN mode on the hub app, getting new key, restarting router and xiaomi, i have even seen some people say its the phone they were using that messed up

No that’s the bit i’m lost about haha! I see nothing and nothing in my entities list either!

Re read my edit^^, but that is strange, maybe someone else can help you but as far as i can tell it seems that your multicast and discovery are working, but the port just isnt opened? I would try to mess around with the developer mode on the hub app some more