You can also try this version: https://github.com/lazcad/homeassistant/pull/15
I have added some extra retry if it fails to connect.
Thanks, are there any plans to submit this to HA?
@anon35356645 and @pikapt: The error you posted should not happen with this fix:
The code is tested with HA 0.36.1
Thanks a lot! i’ll try to test it asap
looking good! I’ll leave it during this afternoon and i’ll check the logs later to see if i have any error
Great if you could report back any error
Ok so I’got a “timeout”…
Jan 26 14:30:09 raspberrypi hass[6149]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 14:30:09 raspberrypi hass[6149]: ERROR:custom_components.xiaomi:No data in response from hub None
after that I already had an update from xiaomi sensors… so i’m not sure why and when this happens
well looks like several time outs:
Jan 26 14:20:39 raspberrypi hass[6149]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 14:20:39 raspberrypi hass[6149]: ERROR:custom_components.xiaomi:No data in response from hub None
Jan 26 14:30:09 raspberrypi hass[6149]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 14:30:09 raspberrypi hass[6149]: ERROR:custom_components.xiaomi:No data in response from hub None
Jan 26 14:33:07 raspberrypi hass[6149]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 14:33:07 raspberrypi hass[6149]: ERROR:custom_components.xiaomi:No data in response from hub None
I’ve tried pyAqara and i had an identical issue:
hass[2615]: ERROR:pyAqara.gateway:Timeout on socket - Failed to connect the ip 192.168.1.19, automatic retry
Timeout is something that always can happen. But the sensors are still updating ok?
well I’m only monitoring the log file, i’m not home right now! I can see the sensors being updated in the logfile but i’m not sure if there is something missing. The first time I found out that something was not working was because the motion sensor triggered an automation (turn on lights). I think I was having this timeout error at the time because when the gateway is not communicating with hass , all the events triggered by the sensors are not detected. I can test it a little bit further later when I get home but I think that i’ll have the same issue.
I wonder if i’m the only one with this issue or maybe i’m the only one that is using this in a “production environment”…
Hmm, the risk for the motion sensor to be stuck in “motion” state should at least be lower now.
Jan 26 15:23:02 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Response does not match return cmd. Expected read_ack
Jan 26 15:23:12 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 15:23:12 raspberrypi hass[967]: ERROR:custom_components.xiaomi:No data in response from hub None
really wierd behaviour. Are you having the same errors or it just my hub Daniel? Maybe I have a faulty hub or so?
Is that just after start of HA?
It’s after some time.The first few minutes everything is ok. After a few minutes it starts getting timeouts, again, quite ramdomly:
Jan 26 15:10:31 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 15:10:31 raspberrypi hass[967]: ERROR:custom_components.xiaomi:No data in response from hub None
Jan 26 15:18:25 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 15:18:25 raspberrypi hass[967]: ERROR:custom_components.xiaomi:No data in response from hub None
Jan 26 15:23:02 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Response does not match return cmd. Expected read_ack
Jan 26 15:23:12 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 15:23:12 raspberrypi hass[967]: ERROR:custom_components.xiaomi:No data in response from hub None
Jan 26 15:24:21 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 15:24:22 raspberrypi hass[967]: ERROR:custom_components.xiaomi:No data in response from hub None
Jan 26 15:25:40 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Response does not match return cmd. Expected read_ack
Jan 26 15:25:50 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 15:25:50 raspberrypi hass[967]: ERROR:custom_components.xiaomi:No data in response from hub None
Jan 26 15:30:04 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 15:30:04 raspberrypi hass[967]: ERROR:custom_components.xiaomi:No data in response from hub None
Jan 26 15:35:57 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 15:35:57 raspberrypi hass[967]: ERROR:custom_components.xiaomi:No data in response from hub None
Jan 26 15:36:46 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 15:36:46 raspberrypi hass[967]: ERROR:custom_components.xiaomi:No data in response from hub None
Jan 26 15:39:05 raspberrypi hass[967]: ERROR:custom_components.xiaomi:Cannot connect to Gateway
Jan 26 15:39:06 raspberrypi hass[967]: ERROR:custom_components.xiaomi:No data in response from hub None
I’ve noticed that if you send several commands to the hub, it looks like it got stressed out and stops answering. Maybe we’re making too much requests to the hub which cause this?
Thnx, it’s working. I’ve installed the app on android and the gateway was discovered.
My pi was connected to lan and the gateway was wifi.
I’ve set my pi to wifi and it worked
as additional note. I also had problems when my account was disconnected in the Xiaomi APP Mi Home.
After re-logging in, the errors disapperaed. DOn’t know what was the cause of the disconnection inside the MiHome app
I wonder if I connecting my PI through wireless would make any difference…
Well it’s even worse, now my sensors are detected in hass but thay are static. When I try to switch something on in the frontend I have an error on the logfile
Jan 26 18:30:15 raspberrypi hass[1588]: ERROR:custom_components.xiaomi:Invalid Key
I’ve generated a new key but god the same thing…
Invalid key means that you miss printed the xiaomi gateway key, so you have just read only.
16 digits key, if its necessary change the key once more, if you have letters and numbers which seems to be similar.
Can you paste your config?
Go to the Mi Home app and validate the key again.
xiaomi:
gateways:
- sid:
key: 7rei5erfyo1dserw
Nobody has the same issues with door senors that they are suddenly changed to state “on/open”?