PyXiaomiGateway Problem: {"error":"Invalid key"}

Since I have the same invalid key issue I have disabled local lan and enabled again and got a new key using an android device this time (I have iOS devices) .fresh installation hassio AIO on a raspberry 1 but again the same error when I sent a command to my gateway :frowning: invalid key.any suggestions?

The iOS app generates invalid keys. Use Android via an emulator like bluestacks and generate a valid key…

Sorry but if I got this right, you are saying that an android sim on my Mac can only do the job correctly and not a native android device ? I used a huawei p9 lite to generate the key .

Thing is, that iOS generates invalid keys. Use the android app to generate the key. Should male no difference, if you’re using a realy device or an emulator :slight_smile:

Thank you Jacob, sadly , I did this and I got the same results ! I will generate another key and retry and let you know .

Confirmed. iOS app generates wrong key, it took me weeks to find out, :frowning:

Btw, I saw that from log

Discovered: {'host': '192.168.1.1x7', 'port': 54321, 'hostname': 'lumi-gateway-v3_miio97xxxx98.local.', 'properties': {'epoch': '1', 'mac': '34ce0088xxx7'}, 'mac_address': '34ce0088xxx7'}

I dont know why 54321 port?
PS: Im trying to run hass on docker but no luck without net=host. Someone told me that we need to config for multicast but not sure how

Hi,

I’m struggling with the same issue. I’ve followed of all the troubleshooting steps, and generated the key in an Android device, several times: I still get the same message. Any ideas?

Thanks

Hi!

Sorry to bother again, but I’m desperate trying to find a fix for this issue. I think what you just explained is what happens to me.

When I run ngrep port 9898 I don’t receive anything like this:

U 192.168.1.206:4321 -> 224.0.0.50:9898

{"cmd":"heartbeat","model":"gateway","sid":"XXXXXXXXXXXX","short_id":"0","token":"XXXXXXXXX","data":"{\"ip\":\"192.168.1.206\"}"}

So I guess my network is causing the problem, but I can’t find a solution. Any ideas?

Thanks

Huh, It seems happened to me. Again
After few try re-generation password from Android app but the problem is still the same “invalid key”

Look at the PyXiaomiGateway repo I found https://github.com/Danielhiversen/PyXiaomiGateway/compare/invalid_key?expand=1
Hopefully we can have another way to deal with this.

Thanks

By the way, the discovery is working fine. HA can see the gateway and all its sub-devices

Same issue here, try to activate the light on the gateway from ha, Error in the log.

UPDATE: resetting a new key made it work.

I’m getting the same issue. I use an Android, tried generating a new key, and have reset both the gateway and HomeAssistant multiple times. HA sees the motion sensors that I have connected to the gateway, but it doesn’t receive updates on the status for the devices and when I attempt to turn on the gateway light from HA, I get this invalid key error.

Same issue here. Only one gateway. Generated a new key - without success.

I’m running on 0.57.3 right now.

I should have mentioned my HA version. I’m also on version 0.57.3 on Hassio. Fresh install with literally nothing but xiaomi active (and samba so I can edit my config).

I remember you had a working setup in the past. Did you change something?

Yes @syssi that’s correct.

I had a working (Xiaomi) environment with 0.47. Finally I was able to update to 0.57 (was busy with work before) and this broke my Xiaomi installation.

I then updated to Python 3.6 and created a new vEnv and after that at least all my sensors showed up again and my (one) button is working in an automation. But I can’t turn on the gateway light nor can I play a sound :frowning:

Any errors in the log?

Hi @Danielhiversen,

I just tried to turn on the Gateway light via the web GUI and I can see the following:

2017-11-22 11:57:45 DEBUG (SyncWorker_2) [homeassistant.components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling
2017-11-22 11:58:16 DEBUG (SyncWorker_19) [homeassistant.components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling
2017-11-22 11:58:47 DEBUG (SyncWorker_10) [homeassistant.components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling
2017-11-22 11:58:47 DEBUG (SyncWorker_0) [homeassistant.components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling
2017-11-22 11:59:18 DEBUG (SyncWorker_3) [homeassistant.components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling
2017-11-22 11:59:18 DEBUG (SyncWorker_1) [homeassistant.components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling
2017-11-22 11:59:49 DEBUG (SyncWorker_5) [homeassistant.components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling
2017-11-22 11:59:49 DEBUG (SyncWorker_17) [homeassistant.components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling
2017-11-22 12:00:20 DEBUG (SyncWorker_18) [homeassistant.components.binary_sensor.xiaomi_aqara] Updating xiaomi sensor by polling
2017-11-22 12:00:44 ERROR (SyncWorker_19) [PyXiaomiGateway] Got error element in data {“error”:“Invalid key”}

So the key in the config is wrong or your router does not support multicasting.

It’s just strange that I only updated to 0.57.3 (and Python).

Same gateway like before and same router setup. And it was working like a charm before :frowning:

Key and Mac and not case sensitive and I don’t need the : for the mac, right?