Xiaomi gateway not discovered

Could you provide the output/return value of “platform.system()”? I would like to do something like this:

https://github.com/Danielhiversen/PyXiaomiGateway/blob/master/PyXiaomiGateway/init.py#L120

Sure:

>>> platform.system()
'NetBSD'

One more thing, although now Gateway is discovered with all connected devices, it seems to only query it only one time, for example since I got this working at 15:00, I have straing line in temperature until now. Also when I tried to turn on light in Gateway or in wall switch i got:

2017-11-20 21:20:46 ERROR (SyncWorker_0) [PyXiaomiGateway] Got error element in data {“error”:“Invalid key”}

Of course key from mi app is correct, I tried to regenerate it, same behavior.

What is even more odd, on Centos VM with test HA it is not working also with same behavior (invalid key), but in FreeBSD VM also with test HA - I can turn it off and on how many times I want.

Any suggestion to this?

1 Like

I also can’t seem to discover my gateway. It works on a Hassio install with the same config.

I’m running Home Assistant on Docker on a Synology NAS on VMare on Windows 10. Everything seems to work fine, except this. Been working on it for HOURS. Wtf am I missing?

Maybe this is a solution for you.
Generate key at iOS will not work at this moment. You get a wrong key.
Generate key at Android is the solution for me. I get the right key with lowercase.

Thanks, already had it working. It was a VPN issue on Synology that blocked it. Once it’s discovered I can turn the VPN back on.

Hey guys, I think I’m in the same situation.

I initially setup home assistant in a docker and the gateway (firmware 1.4.1_151.0143) was detected and showing data from the sensors. After a couple of hours it would show the sensors as unavailable. Restarting the home assistant docker would reconnect fine…for a couple more hours.
I’ve since started investigation in other areas - more so the network. I’ve been playing around with node-red and can see udp traffic, but not on port 9898.

Wireshark shows UDP traffic from my gateway to 224.0.0.251 on port 5353.
This traffic is just “cache flush” messages and contains no sensor data.
I believe that it’s meant to be broadcasting to 224.0.0.50 on udp port 9898 but I see no traffic to port 9898 at all.

nmap shows that 9898 is open
9898/udp open monkeycom

I would expect to be seeing traffic on port 9898 with sensor data.
I’ve tried a couple of different networks, and hard reset the gateway multiple time but I get the same result.

The gateway works through the mi home app on android fine.
More info:
I’m running my docker containers with the --net host command, so it has an address on the same network as the gateway. So it should have full access to the host’s network.

Further investigation:
I installed Multicast Tester on my android phone and can see all the right multicast traffic on 224.0.0.50 port 9898. Still unsure as to why wireshark cannot see it.
I also spun up another docker container that runs tcpdump (corfr/tcpdump) and that can also view the right traffic. This container also uses --net host.

Am I making the right assumptions here?
Any help would be appreciated.

thanks,

Cam

Hey Guys,

I have the same error… Gateway port 9898 is open but HA doesn’t discover any sensor data…
HW version 3 on newest firmware.
Have a look at this: Thread

Old topic, but it may help someone
+1 for the solution with disabling (comment out) discovery_retry in config.
I have no idea why, but it helped.
Thank you!

@sztof - commenting it out just put the default value of 3.

Hi Friends is there any solution?
I have test with many different configurations un configuration.yalm

With host, interface, MAC , or without them…

Only works for a couple hours. then disabled…

Are you sure you have ports open in gateway? Check latest 0.90.2 as a lot of xiaomi fixes are there.

My gateway integration worked flawlessly for about a year, then about 10versions or so ago (around 0.85) it stopped working, also the direct connection to my Xiaomi roborock also started playing up… Eventually, I ended up biting the bullet and getting a conbee stick whch has now enabled me to get rid of my xiaomi and hue gateways and I connect directly to deconz… you should really give it a try if you are battling with the proprietry zigbee gateways…

There was no rhyme or reason as to why my xiomi gateway would connect/disconnect after being so stable for so long… so for the sake of time, spend the £35 on a conbee stick nad save yourself some headaches…