Xiaomi Gateway not Connecting

I’ve had the Xiaomi Gateway setup and operating in Hass.io for several months now. I am using it along with several sensors and all has been working well (sensors report state back to HA)

However, I am unable to connect to the Gateway itself to control the light, alarm, etc. The Gateway does not appear as an entity in HA.

After scouring the forums, I have been unable to find others with the exact same issue I am having with the following errors shown in the log:

2018-04-21 18:37:03 ERROR (SyncWorker_10) [xiaomi_gateway] Cannot connect to Gateway
2018-04-21 18:37:04 ERROR (SyncWorker_10) [xiaomi_gateway] No data in response from hub None
2018-04-21 18:37:14 ERROR (SyncWorker_10) [xiaomi_gateway] Cannot connect to Gateway
2018-04-21 18:37:24 ERROR (SyncWorker_10) [xiaomi_gateway] Cannot connect to Gateway
2018-04-21 18:37:34 ERROR (SyncWorker_10) [xiaomi_gateway] Cannot connect to Gateway
2018-04-21 18:37:44 ERROR (SyncWorker_10) [xiaomi_gateway] Cannot connect to Gateway
2018-04-21 18:37:54 ERROR (SyncWorker_10) [xiaomi_gateway] Cannot connect to Gateway
2018-04-21 18:37:54 ERROR (SyncWorker_10) [xiaomi_gateway] Got error element in data {“error”:“No device”}
2018-04-21 18:37:54 ERROR (SyncWorker_10) [xiaomi_gateway] Got error element in data {“error”:“No device”}
2018-04-21 18:37:54 ERROR (SyncWorker_10) [xiaomi_gateway] Not a valid device. Check the mac adress and update the firmware.

Sometimes, it is just the last error. It doesn’t make sense to me as all the associated sensors are connected and working fine, just not the gateway.

I have tried all possible setups in my config, including listing the MAC address, but nothing seems to get it connected.

My current setup is:
xiaomi_aqara:
discovery_retry: 10
gateways:
- host: 192.168.0.1
mac: 7811dcb3XXXX
key: 6uiz5hxcpd21XXXX

At the risk of opening another gateway thread, I was hoping someone might have some ideas or thoughts on how to solve the problem.

Your MAC address looks off mine works & it’s formatted
mac: 78:11:dc:b3:XXXX
If you only have 1 router there’s no need to list the host.

Just asking the obvious question… did you upgrade the firmware of your gateway?

Yeah, I’ve tried all sorts of combinations for the config: including the host name, adding ‘:’ in mac address, capitalising mac address, etc.

I’ve tried updating the firmware several times via the app. It says I’m on 1.3.1_141.0143.

I’ve also tried restarting the gateway several times, but no luck.

I got some additional errors if this sheds any light?

2018-04-25 12:40:36 ERROR (SyncWorker_8) [xiaomi_gateway] Non matching response. Expecting read_ack, but got write_ack
2018-04-25 12:40:36 ERROR (SyncWorker_7) [xiaomi_gateway] Non matching response. Expecting write_ack, but got read_ack

this is my working setup:

xiaomi_aqara:
  discovery_retry: 10
  gateways:
    - key: E12345XXXXXXXXXX

try making without “mac” and “host” line and make “key” capital letters

It seems your firmware is pretty old, I’m using 1.4.1_154.0143 so I guess you first need to figure out why your gateway it not updating to the latest firmware.

Thanks. Tried this but no luck.

This is interesting. No matter what I do, I seem to be stuck on the current firmware update.

I have found this thread, which may provide me some help:

I do have similar issue.
On one hand Xiaomi Gateway works as intended - I’m getting all sensors readings and I can control the gateway light via Mi Home app.
On the other hand I cannot connect the light to HA.

Xiaomi gateway info:

{
  "fw_ver": "1.4.1_156",
  "hw_ver": "MW300",
  "model": "lumi.gateway.v3",
  "mcu_fw_ver": "0143"
}

Debug logs from HA:

INFO (Thread-3) [xiaomi_gateway] Xiaomi Gateway 38700c45062f configured at IP 192.168.0.11:9898
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd >> b’{“cmd”:“read”,“sid”:“38700c45062f”}’
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd resp << {‘sid’: ‘38700c45062f’, ‘cmd’: ‘read_ack’, ‘data’: ‘{“error”:“No device”}’}
ERROR (Thread-3) [xiaomi_gateway] Got error element in data {“error”:“No device”}
INFO (Thread-3) [xiaomi_gateway] Discovering Xiaomi Devices
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd >> b’{“cmd” : “get_id_list”}’
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd resp << {‘token’: ‘gKjTln66EGifuy6C’, ‘sid’: ‘7811dcb7b352’, ‘cmd’: ‘get_id_list_ack’, ‘data’: ‘[“158d0001fa53f1”,“158d0001fa3cf3”,“158d0002019236”,“158d000201923b”]’}
INFO (Thread-3) [xiaomi_gateway] Found 5 devices
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd >> b’{“cmd”:“read”,“sid”:“158d0001fa53f1”}’
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd resp << {‘sid’: ‘158d0001fa53f1’, ‘cmd’: ‘read_ack’, ‘short_id’: 93, ‘data’: ‘{“voltage”:2975,“temperature”:“2835”,“humidity”:“4759”}’, ‘model’: ‘sensor_ht’}
DEBUG (Thread-3) [xiaomi_gateway] Registering device 158d0001fa53f1, sensor_ht as: sensor
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd >> b’{“cmd”:“read”,“sid”:“158d0001fa3cf3”}’
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd resp << {‘sid’: ‘158d0001fa3cf3’, ‘cmd’: ‘read_ack’, ‘short_id’: 25895, ‘data’: ‘{“voltage”:2965,“temperature”:“2697”,“humidity”:“5051”}’, ‘model’: ‘sensor_ht’}
DEBUG (Thread-3) [xiaomi_gateway] Registering device 158d0001fa3cf3, sensor_ht as: sensor
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd >> b’{“cmd”:“read”,“sid”:“158d0002019236”}’
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd resp << {‘sid’: ‘158d0002019236’, ‘cmd’: ‘read_ack’, ‘short_id’: 46852, ‘data’: ‘{“voltage”:3015,“temperature”:“2763”,“humidity”:“5031”}’, ‘model’: ‘sensor_ht’}
DEBUG (Thread-3) [xiaomi_gateway] Registering device 158d0002019236, sensor_ht as: sensor
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd >> b’{“cmd”:“read”,“sid”:“158d000201923b”}’
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd resp << {‘sid’: ‘158d000201923b’, ‘cmd’: ‘read_ack’, ‘short_id’: 3998, ‘data’: ‘{“voltage”:3035,“temperature”:“2726”,“humidity”:“5214”}’, ‘model’: ‘sensor_ht’}
DEBUG (Thread-3) [xiaomi_gateway] Registering device 158d000201923b, sensor_ht as: sensor
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd >> b’{“cmd”:“read”,“sid”:“38700c45062f”}’
DEBUG (Thread-3) [xiaomi_gateway] _send_cmd resp << {‘sid’: ‘38700c45062f’, ‘cmd’: ‘read_ack’, ‘data’: ‘{“error”:“No device”}’}
ERROR (Thread-3) [xiaomi_gateway] Got error element in data {“error”:“No device”}
ERROR (Thread-3) [xiaomi_gateway] Not a valid device. Check the mac adress and update the firmware.
INFO (Thread-3) [xiaomi_gateway] Gateway discovery finished in 5 seconds
INFO (Thread-3) [xiaomi_gateway] Creating Multicast Socket

It looks like 5 devices are found but one does not get registered and it’s the Gateway. It returns {“error”: “No device”}

I don’t know what’s wrong. Anyone had similar issue and found a solution?

Best regards.

That’s magical… somehow both illumination and light appeared today out of nowhere in my HA.
Sadly the light doesn’t work, ie. can’t turn it on using HA. Switch goes back to Off after a second or two and light itself apparently does not turn on.