Xiaomi gateway not discovered

I know but now in the info you can get the access token directly in “gateway informations” (a big Json)
“token”:“d…CCb6”

The question now is do not get feedback for xiaomi gateway

Uh. This is strange. I will check it. Please power-cycle your gateway in the mean time and try again. Please don’t update/regenerate the key.

I’ll try that when I’m back from work. I did try to reset it but I haven’t thought about simply unplug and replug it.

About regenerating the key, I’m afraid I did that a few times already.

Just wanted to let everyone know, that i was having trouble with HA detecting the gateway aswell. For me it started since i bought a new router ( Asus RT-AC88U). So i messed arround with the settings but i couldn’t get it to work and i also used the newest custom merlin firmware which did not work either. A few times it worked but after HA restart it was gone again.

Only thing that did work for me was flashing the oldest firmware possible on the router (version 3.0.0.4.380.3941).
So it sucks i can’t use a newer firmware version but at least everything is working now for me.

Nice, that it worked for you. But in my case, a friend of mine has the same router and firmware (AVM Fritz!Box 7590) and it works for him. So the router can’t be the problem (for me)

I`m home from working now :slight_smile:
I´m having HA on a Raspberry Pi 3 on a Fritz!Box (Router). The Gateway is connected via WiFi (what else :smiley:) to the Router; the RPi is connected via LAN to the Router. All Devices have the latest firmware (incl. Raspian Stretch)

I i´ve tried:

  • Discover the Gateway on my RPi
  • Discover tge GW on 2 different Virtual Machines with Docker-Images of hass.io and homeassistant
  • Setting up/reset the key multiple times on iOS and Android
  • Connect the GW with a Guest-Network
  • Tried another Xiaomi-Account
  • Tried to connect the RPi via WLAN to the Router
  • Tried with/without mac, interface (IP) and key in the config

None of this ways discovered the Gateway via Homeassistant

Still no success. I’ve found a french forum where a handful of people where having the same issue after buying a gateway recently. Maybe we have a faulty serie ?

Your setup is very like mine. Please connect the raspberry pi by WiFi just for testing. Which fritzbox generation and firmware do you use? I will try to build the same setup for debugging.

I´ve tried the WiFI-Raspberry (second last point on my list :smiley: ) Its a Fritz!Box 7590 (latest generation) with 6.86 and two days ago 6.88 Labor (beta). Are you from germany?

Yes. The fritzbox country. :wink: Did you power-cycle the xiaomi gateway once?

Multiple times. Maybe we could talk on another medium, like discord? We could post the solution here, if we find it

I assume your setup is fine. Your enumeration is nearly complete and gapless. Give me some time to replicate your setup. I have an unused and untouched gateway lying around. May be I can reproduce something and compoare with my working gateway.

I was able to reproduce the behaviour of new gateways. A proper discovery would look like this:

192.168.130.35:54580 -> 224.0.0.50:4321: {"cmd":"whois"}
192.168.130.35:54580 <- 192.168.130.29:4321: {"cmd":"iam","port":"9898","sid":"286fffffffff","model":"gateway","ip":"192.168.130.29"}

In my case there are two gateways online (192.168.130.29 and 192.168.130.63). The second one should respond to the “whois” message, too but it doesn’t. I just connected the new gateway to my WiFi, updated the firmware to the current version (149), paired a wireless button and enabled the local network protocol by moving the slider and press “confirm”. The action was confirmed with “result: {“ok”}”.

Right, like I did. iOS or Android? Initial I paired a doorsensor, motionsendsor, temp/humi-sensor and a wireless button.

New knowledge: Enable the local protocol doesn’t enable the local protocol at the moment. It can be verified by:

$ sudo nmap -sU -p 9898 192.168.130.29

Starting Nmap 7.40 ( https://nmap.org ) at 2017-08-28 22:17 CEST
Nmap scan report for lumi-gateway-v3-miio52244965.fritz.box (192.168.130.29)
Host is up (0.084s latency).
PORT     STATE SERVICE
9898/udp open  monkeycom
MAC Address: 28:6C:FF:FF:FF:FF (Xiaomi Electronics,co.)

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

$ sudo nmap -sU -p 9898 192.168.130.63

Starting Nmap 7.40 ( https://nmap.org ) at 2017-08-28 22:17 CEST
Nmap scan report for lumi-gateway-v3-miio56801386.fritz.box (192.168.130.63)
Host is up (0.043s latency).
PORT     STATE  SERVICE
9898/udp closed monkeycom
MAC Address: 34:EE:EE:EE:EE:EE (Unknown)

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

Okay, and what does it mean? Should i wait, until the local protocol is applied?

I knew I wasn’t crazy.

2 Likes

And with the nmap-command i get the same behaviour like your second gateway (63)

Yes. I think you can re-generate the key from time to time. If the nmap call reports port 9898 to be open it went fine. I removed the complete discovery step from PyXiaomiGateway for testing and added a static entry:

self.gateways['192.168.130.63'] = XiaomiGateway('192.168.130.63', 9898, '34ffffffffff', 'dqsfotxeeixnfcee', self._socket)

You can see the closed port at the network traffic:

192.168.130.63 -> 192.168.130.35: Destination unreachble (Port unreachable)

So the discovery isn’t broken. It’s the local protocol somehow.