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

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

I have the same issue. Receive the output from the Gateway via UART, but can’t type commands in Putty. Don’t understand it.

Yesterday I received my new lumi gateway v3, and I have same problem, I found that port 54321 is open.

PORT STATE SERVICE
54321/udp open|filtered bo2k

Hi, can I have help on integrating the gateway to hassio?
I did not update firmware and quickly managed to enable lan mode, copied the key and the mac address (but I can see it also from the router, assigned fixed ip to the gateway).
With nmap scan I find 9898 port closed and I use a fritzbox 7590 router which I don’t know if has multicast service enabled, I know from other users they did not need to solder to have the gateway working in hassio, so I ask if there is a way to have this working, I also have pihole running on my hassio but I don’t think it is blocking the connection to the gateway

hi,

It sounds like you have done everything correct to what i did.

Did you buy the V1 or V2 gateway?

This is my config

xiaomi_aqara:
  discovery_retry: 5
  gateways:
      key: ulgzlmqpi0csw5rj

What command did you use in nmap? i used the below and showed me both ports open
nmap -sU 192.168.0.108 -p 9898,4321

Finally what firmware version is it currently on?

1 Like

I had a lot of connection problems after a little while. I also looked at the various options (increasing discovery_retry, adding mac address (without the : characters), adding IP address, but nothing really worked. Then I discovered that it will not work through your home assistant Yaml configuration if you also configure it in Node Red. Removing the Node Red configuration and restarting everything fixed my problems and nothing else was needed except the default config.

I have been following this post for months, and finally got around to zapping my Xiaomi gateway, and it was really easy and quite painless and I now have set of security screwdriver bits to add to my tool collection. Now to add some sensors etc.

One question, I have a light level reading and the light entity in HA from the gateway. I did notice temperature and other bits in putty, is there any way to get these into HA?

Interesting. Can you give some more details on what you see?

I have taken my wires off now, but I remembered seeing the same thing in a YouTube video,

https://www.youtube.com/watch?v=2bkz-nHXtpM&t=1048s

Hi folks,

Unfortunately also have this problem with lummi gateway v3, HA doesn’t discover any of my 2 gateways supporting Xiaomi sensors.

Any solution yet to solve this?

I also had problems connecting the gateway. Ended up giving up and buying a Conbee stick, it works with most Xiaomi devices. Now I’m wondering why I didn’t get one long ago, it works very well. It also has a hassio add on for easy integration https://phoscon.de/en/conbee2