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

Tags: #<Tag:0x00007fc3f7634490>

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

yeh i think the ports are closed still! I don’t know why because the firmware version isn’t the latest where we know there is a bug with ports not opening so i’m lost!

ok so on nmap i coped someone else’s query and the ports are supposedly open
This was my nmap query - nmap -sU -p 9898,4321 192.168.1.86

Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-10 21:19 BST
Nmap scan report for 192.168.1.86
Host is up (0.082s latency).

PORT     STATE         SERVICE
4321/udp open|filtered rwhois
9898/udp open          monkeycom
MAC Address: 04:CF:8C:91:47:F5 (Unknown)

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

so why the hell can’t i see it in home assistant!!!

I thought i would update this thread as i’ve got it WORKING and thought i’d do a personal retro WOHO!

Things i’ve learnt:

  1. Buy a Mijia V1 or V2 but don’t update the firmware. You can get to the “about” tab quickly enough before it prompts you to update firmware. My firmware is currently 1.4.1_150 and the ports open when i enable it in the dev mode
  2. Do not go into lovelace edit. So turns out i had once edited the lovelace ui and therefore it wasn’t updating automatically. If you are unsure if you have been in or not just reinstall HAAS but take all your config out first obviously
  3. Nmap is useful if you know how to use it. I was just doing some basic port search which didn’t work so used this command instead and gave me the information i wanted to know (which was they are open) nmap -sU 192.168.0.108 -p 9898,4321. This gave me the golden ticket which is the below outcome that means it’s open and is communicating with home assistant
Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-10 21:19 BST
Nmap scan report for 192.168.1.86
Host is up (0.082s latency).

PORT     STATE         SERVICE
4321/udp open|filtered rwhois
9898/udp open          monkeycom
MAC Address: 04:CF:8C:91:47:F5 (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 3.08 seconds
  1. logging is helpful as the below logs did confirm that the gateway was picked up by home assistant
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:04 INFO (MainThread) [homeassistant.components.lock] Setting up lock.xiaomi_aqara
2019-07-10 20:24:04 DEBUG (SyncWorker_14) [pyaarlo] set:4RD3817HA08E5/deviceId=4RD3817HA08E5
2019-07-10 20:24:04 DEBUG (SyncWorker_14) [pyaarlo] set:4RD3817HA08E5/deviceName=Living room
2019-07-10 20:24:04 INFO (MainThread) [homeassistant.components.cover] Setting up cover.xiaomi_aqara
  1. this is all the config you need non of the mac or IP stuff
xiaomi_aqara:
  discovery_retry: 5
  gateways:
      key: ulgzlmqpi0csw5rj

Big thanks to @chief_tate & @Justin_Snyder for their help if it wasn’t for them helping i wouldn’t of realised my mistake!

i hope this post helps another noob like me but the biggest thing to note if you skim this is.

DON’T UPDATE YOUR FIRMWARE WHEN YOU FIRST PLUG IT IN. otherwise you’re screwed and going to have to go down the solder method.

2 Likes

Glad we could help and glad you got it working! They really try to force you into that firmware update don’t they? :rofl:

2 Likes

Hi, friends! Sorry for my english. nmap shows this:
Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-13 19:11 RTZ 2 (ceia)
Nmap scan report for 192.168.1.72
Host is up.
PORT STATE SERVICE
9898/udp open|filtered monkeycom

What is this? How to remove filtered

I tried open ports the UART according to the instructions, but the program putty does not allow to enter commands. Help plz, what else can i try? fw 1.4.1_170.0158