Cannot connect to Xiaomi gateway

I am setting up a HASSIO server running on HyperV and trying to connect it to a Xiaomi gateway. For some reason, I just can’t get HASSIO to see the gateway.

I have run Nmap from an Ubuntu machine on the network and see port 9898 open on the gateway for UDP traffic. The Gateway is otherwise looking fine. Likewise, HASSIO is otherwise working fine (albeit it’s not doing much)

My config is

xiaomi_aqara:
  discovery_retry: 5
  gateways:
    - key: hjfjgfjgfgfnsfsbx
      mac: 04:cf:8c:ab:xx:xx
      host: 10.9.10.50

I am getting the following error in the log

2019-08-17 13:37:59 WARNING (MainThread) [homeassistant.setup] Setup of xiaomi_aqara is taking over 10 seconds.
2019-08-17 13:37:59 ERROR (SyncWorker_1) [xiaomi_gateway] Cannot connect to Gateway
2019-08-17 13:37:59 ERROR (SyncWorker_1) [xiaomi_gateway] No data in response from hub None
2019-08-17 13:38:09 ERROR (SyncWorker_1) [xiaomi_gateway] Cannot connect to Gateway
2019-08-17 13:38:19 ERROR (SyncWorker_1) [xiaomi_gateway] Cannot connect to Gateway

I have created a fresh Hassio instance just for this using the latest version. It is otherwise on the network ok and working fine.

Any ideas what else I can try? Many thanks.

Does multicast work on your VM?

there are two ports - 9898 and 4321 that need to be open

Thanks for the advice.
I have tested ports 9898 and 4321 using Nmap. They are open intermittently :confused:
It almost seems like when one is open then the other is closed which seems wrong.
Also the app is now complaining that the WiFi signal at the gateway is weak even when it’s next to the WiFi AP.
It’s seeing the sensors ok it seems, but I’m suspicious of the hardware now.
Wdyt?
Many thanks

This is my output:

walaj@JonLabNUC:/home/homeassistant/.homeassistant$ sudo nmap -sU 192.168.1.72 -p 9898,4321

Starting Nmap 7.01 ( https://nmap.org ) at 2019-08-21 09:54 AEST
Nmap scan report for LUMI-GATEWAY-V3_MAIN (192.168.1.72)
Host is up (0.0021s latency).
PORT     STATE         SERVICE
4321/udp open|filtered rwhois
9898/udp open          unknown
MAC Address: 78:11:DC:E1:F8:CD (Unknown)

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

I ran it a couple of times, and other than one “no reply”, was open each time.

Not idea what to suggest.

I have a funny feeling the integration wants the MAC address without the colons, in other words

04cf8cabxxxx

yes. this ^^

mac

(string)(Optional)

The MAC address of your gateway. Needs to be formatted without “:”.  *Optional if only using one gateway.*

good spot.

Hi again
Thanks for the input.
I tried taking out the colons from the MAC address. Unfortunately that didn’t help.
I bought a second gateway in case there was a fault with the first one.
I get exactly the same results.

I will look again at the HASS VM to make sure that there is no filtering on its virtual network port, but last time I asked, my tech guy said no…
If anyone can advise on any further troubleshooting steps, that would be great.
Thank

just checking that you have unlocked the dev mode in the app?
(I’m assuming yes, but assumption…)

Thanks for the suggestion.
LAN access is enabled on both gateways and I have noted down the password. I followed the guide here
https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)#Adding_the_Xiaomi_Gateway_to_Domoticz

if lan access is enabled, and the ports show as (mostly) open in nmap, then I’m at a loss.

If the ports were not open, that would the obvious problem - some hubs (Europe version I think) dont support the LAN connection, but that isn’t an issue here). Also, there was a xiamoi firware version that locked the ports if you upgraded BEFORE unlocking…

Thanks for the feedback.
I have now set up a fresh instance of HASSIO on a brand new Pi 4 and still no luck.
I have two gateways. They are both new and they are both running firmware 1.4.1.170. They both have LAN mode turned on in the Mi Home app using the special menu.
They are connected to the network fine and I can ping them both.

I noticed in the hass.io page on Xiaomi, is says

Please note, there are two versions of the hub: v1 and v2. v1 can be used with Home Assistant without any problems, however, v2 might be less straight forward when it comes to enabling the local API, and might even require you to open up your device in order to do so. Xiaomi has suggested this is in the pipeline.

I am wondering if this might be my problem somehow. The guide also says

If your gateway’s MAC address starts with 04:CF:8C, there is a good chance that the required port 9898 is closed on your gateway (you can check it with the Nmap utility, using the command sudo nmap - sU {gateway_ip} -p 9898). To fix that issue, you need to do these steps:

Then lists a pretty horrible set of steps.
And both my gateways’ MAC addresses do start with those 6 digits :frowning:

I am hoping very much to avoid having to do those steps. Soldering is not my think at all!!

And what does nmap tell you?

The ports are closed :frowning:
I’m going to have to open them up aren’t I?..

only if you want to integration using the hub and HA.

The alternative is to skip the hub completely, and get a zigbee/usb adaptor…

Yeah but the hub has this this great feature where it barks like a dog and freaks out the pets…

2 Likes

Thanks all
I do need the hubs because I need them in two places and ideally I will run HASSIO on a VM so I can’t easily use a USB dongle
Thanks again

Hi again
I got a colleague to do the necessary soldering and console config and the Xiaomi gateway and sensors are now visible in HASSIO!
Thanks very much for everyone’s help :slight_smile:

1 Like

oh congrats!!