Xiaomi gateway is recognized, but does not take any commands or brings data - Help needed

i finally managed to make the xiaomi component run. i see the status of the light, but i can’t change on/off, brightness or colors.

when i look into the log-file it says:

[PyXiaomiGateway] Got error element in data {“error”:“Invalid key”}

i checked the key a couple of times, it’s correct.

do you have any hints?

Try to regenerate a new key.

i tried this already a couple of times - but nothing changes.

any luck on this?
I’m getting the same error.

Same here
double checked everything
Regenerated key several times

keep getting :

[PyXiaomiGateway] Got error element in data {"error":"Invalid key"}

@Danielhiversen any ideas ?

Does your router supports multicasting?

Yes, the gateway is also recognized by HA
When I turn on the led through the MiHome app and restart the HA, the HA shows up with the gateway as ON and shows the correct color, but if I turn it off through the app, nothing changes on HA.
It’s like it syncs on HA boot and loses the sync somehow

I guess your router does not support multicasting

I have TP-Link archer c2, as I’ve noticed on other threads, this is the exact same one other users purchased to make this work, so unless it’s a configuration to be set on the router, it’s not the issue

BTW, it worked for the first time I set it up (i was able to turn it on and watch the sensors state changes) but the next day it stopped and never worked again
So I guess if something was not supported it wouldn’t have worked in the first place

Update: double checked, multicast is available and enabled on my network

Mine is working rock-solid since the beta component.

So either your router doesnt support multicasting or theres something wrong with your gateway key.

At Xiaomi Gateway component page says:
If you receive an {"error":"Invalid key"} in your log while trying to control the gateway light, you should generate the key again using an Android Phone or alternatively an emulator such as bluestacks. In some instances there is an issue with keys being generated using the iOS application.

Not iOS, Android
Tried multiple keys
Multicast is supported and enabled.

Configuration snippest: (mac & key values altered)

xiaomi_aqara:
  discovery_retry: 5
  gateways:
  - mac: 78:16:GG:B0:50:0B
    key: w8nbyegcxa9333lo

Try with clear mac address

 gateways:
   - mac:
     key: w8nbyegcxa9333lo

Thanks but same result
The gateway is obviously recognized as its state on boot recognized, but it somehow lose its sync afterwards…

hello!

I have exactly the same troubles… factory reseted the gateway, tried everything I could find here in the forums…

But my symptoms are the same :confused: am running 60.1 with python 3.6.3
Hope sowmeone knows a solution to this problem :frowning:

Hi, i have same issue.
Actually HA 0.44.1 work fine with 21 devices xiaomi and i try to use a new hardware with HA (0.58, 0.60, 0.62).
But with the new version of HA, the 21 devices was detected but the data sync not working.

The diff software between was usage of Docker on new hardware.
I add new device (158d00016c763e) on gateway by app Home android, and now the status of new device change only one time and after nothing (no push activity).

xiaomi_aqara:
  discovery_retry: 10
  gateways:
    - mac: f0c225cd9e42
      key: !secret xiaomi_key
      host: 10.0.0.8



2018-01-28 08:49:41 DEBUG (SyncWorker_0) [homeassistant.components.xiaomi_aqara] Expecting 1 gateways
2018-01-28 08:49:41 INFO (SyncWorker_0) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 1)
2018-01-28 08:49:41 INFO (SyncWorker_0) [xiaomi_gateway] Xiaomi Gateway f0c225cd9e42 configured at IP 10.0.0.8:9898
2018-01-28 08:49:41 INFO (SyncWorker_0) [xiaomi_gateway] Discovering Xiaomi Devices
2018-01-28 08:49:41 INFO (SyncWorker_0) [xiaomi_gateway] Found 21 devices
2018-01-28 08:49:41 DEBUG (SyncWorker_0) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d000254e221"}'
 ....
2018-01-28 08:49:47 INFO (SyncWorker_0) [xiaomi_gateway] Gateway discovery finished in 5 seconds
2018-01-28 08:49:47 INFO (SyncWorker_0) [xiaomi_gateway] Creating Multicast Socket
2018-01-28 08:49:47 DEBUG (SyncWorker_0) [homeassistant.components.xiaomi_aqara] Gateways discovered. Listening for broadcasts
2018-01-28 08:49:47 INFO (MainThread) [homeassistant.setup] Setup of domain xiaomi_aqara took 5.3 seconds.
2018-01-28 08:49:47 INFO (MainThread) [homeassistant.loader] Loaded binary_sensor.xiaomi_aqara from homeassistant.components.binary_sensor.xiaomi_aqara
2018-01-28 08:49:47 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.xiaomi_aqara
2018-01-28 08:49:47 INFO (MainThread) [homeassistant.loader] Loaded sensor.xiaomi_aqara from homeassistant.components.sensor.xiaomi_aqara
2018-01-28 08:49:47 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.xiaomi_aqara
2018-01-28 08:49:47 INFO (MainThread) [homeassistant.loader] Loaded switch.xiaomi_aqara from homeassistant.components.switch.xiaomi_aqara
2018-01-28 08:49:47 INFO (MainThread) [homeassistant.components.switch] Setting up switch.xiaomi_aqara


2018-01-28 09:08:50 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d000254e221"}'
2018-01-28 09:08:50 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'magnet', 'sid': '158d000254e221', 'short_id': 11115, 'data': '{"voltage":3005,"status":"close"}'}
2018-01-28 09:08:50 DEBUG (SyncWorker_3) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'magnet', 'sid': '158d000254e221', 'short_id': 11115, 'data': '{"voltage":3005,"status":"close"}'}
2018-01-28 09:08:50 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Door Window Sensor_158d00016c763e: on>: {'voltage': 3005, 'status': 'close'}
... nothing after

Finally i fix the issue.
I use docker-compose for HA with option privileged: true and is bad, use network_mode: “host” and all request come.

I’ve just upgraded to 0.70.1 on Win 10 and I get the same error …

Got error element in data {“error”:“Invalid key”}
6:55 PM C:\Users\Keith\AppData\Roaming.homeassistant\deps\Python36\site-packages\xiaomi_gateway_init_.py (ERROR)

The gateway and all my sensors are discovered but they all show unavailable due to the above, all was working perfectly till the upgrade from 0.69.1.

Anyone else experiencing this?

Just as a data point, working fine on 0.70.1 on hassbian.

It works fine on HASSIO as well but I only use HASSIO for my zwave stuff which I can’t use in Win10.

Why not use hassio for everything?