0.56.1 is out & fix this bug.
I am losing the will to live with this gateway… It connected twice, I was able to setup and customise my components, then restarted core and then nothing… tried for another 2 days and now it is connected again…
I am however getting this error when I try and turn off the light on the gateway:
ERROR (SyncWorker_1) [PyXiaomiGateway] Got error element in data {"error":"Invalid key"}
This thing is so super flaky…
I have the follwing thoughts around possible problem areas:
- Server is set to mainland (china) in the iOs App, could this be causing issues? It is the only way I can see to add the gateway…
- I have a UniFi® Security Gateway, although I am told this has muticast by default…
- I have a linksys mesh wifi network in bridge mode… could the gateway changing between 2 AP’s on the mesch be causing issues?
- I am running HA in docker on my Synology NAS, however have net=host in my docker run cli command.
I am about to reboot, but will bet anyone a beer the Xiaomi gateway cannot be discovered on reboot…
Super frustrating as I managed to open my OpenGarage component (once) using the wireless button… so it works… sometimes and more often not…
Any ideas here? Any help much appreciated, otherwise, this little, noisy, screamin kit is heading back to china…
Just keep calm and stick to this topic: PyXiaomiGateway Problem: {"error":"Invalid key"} - #39 by uiguy
If you are willing to do some testing we will find a proper solution and I will guide you to a stable setup. You will need to spent some more hours because your infrastructure is the cause and we have to identify the critical parts.
Hi, so my button appears to be working fine now… the light on the gateway seems to theow invalid key, happy to help test where i can
Just to add, i tried turning off the gayeway light with the app and this also failed, so i think the issue is with the gateway and my infrastructure and not with home assistant per se…
I will try to explain the local network protocol of the gateway a bit: The communication between Gateway and Home Assistant uses UDP. A protocol without handshaking dialogues and error correction if a packet gets lost. At the discovery of the Gateway a command requests the first token. All further needed tokens are published via a heartbeat message (multicast (udp), port 9898). The latest published token is always needed to execute a command on the gateway. If Home Assistant just receives the first token and none of the heartbeats with new tokens you will receive the “Invalid key” error message and the control of devices will fail.
There are two possibilities now: You network / wireless connection is very bad. There is packet loss and Home Assistant doesn’t receive all needed heartbeat messages. Second possibility: Your network doesn’t transport multicast messages properly and your Home Assistant instance just receives the first token (received directly by UDP (no multicast)) and this token never gets updated because of the missing multicast traffic.
Hi guys,
I have a Xiaomi Gateway and it worked well before “aqara” update and it seems to work well now, but I got this message all the time when I restart HA:
Failed config
General Errors:
- Component not found: xiaomi_aquara
- Setup failed for xiaomi_aquara: Component not found.
I don’t know whats wrong because everything works well. This is what in my configuration.yaml:
xiaomi_aqara:
discovery_retry: 5
gateways:
- mac: Gateway MAC address here
key: Gateway token here
This is the repeatedly error message in log file:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/xiaomi.py", line 113, in _retrieve_list
res = requests.get(url, timeout=5, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 518, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 639, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 514, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.31.1', port=80): Read timed out. (read timeout=5)
2017-10-27 08:09:28 WARNING (MainThread) [homeassistant.components.device_tracker] Updating device list from xiaomi took longer than the scheduled scan interval 0:00:12
2017-10-27 08:09:30 ERROR (SyncWorker_9) [homeassistant.components.device_tracker.xiaomi] Connection to the router timed out at URL http://192.168.31.1/cgi-bin/luci/;stok=036ace34426fc19f588c6c2cb226eef9/api/misystem/devicelist
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 386, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 382, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
I can use my gateway light, xiaomi button, cube, sensors, everything. What’s wrong than?
Please check your network. Your OpenWRT router (192.168.31.1) isn’t available and Home Assistant is unable to contact the Xiaomi Gateway.
Hi, thank you for your answer. It was my fault. I had been stupid because I use bad string “xiaomi_aquara” instead of “xiaomi_aqara”.
I have the same problem as the previous poster but does not appear to be a typo.
Error is:
2017-11-02 13:21:55 ERROR (MainThread) [homeassistant.loader] Unable to find component xiaomi_aqara
2017-11-02 13:21:55 ERROR (MainThread) [homeassistant.setup] Setup failed for xiaomi_aqara: Component not found.
2017-11-02 13:21:56 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=Invalid config, message=The following components and platforms could not be set up:
xiaomi_aqara
2017-11-02 13:21:56 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.invalid_config, old_state=None, new_state=<state persistent_notification.invalid_config=The following components and platforms could not be set up:
xiaomi_aqara
I have not had any other issues with anything else I have setup. eg. mysensors gateways (x2), Philips Hue, Wemo,
I am currently running Hass.io 0.52.1 on a Raspberry Pi which is connected to my LAN via Ethernet. Wifi supplied to the Xiaomi Gateway is via a router running Gargoyle firmware. I have tried a variety of configuration.yaml entries but it is currently:
xiaomi_aqara:
discovery_retry: 10
interface: '192.168.1.168'
gateways:
- host: 192.168.1.168
mac: 34ce00fa5e77
key: xxxxduu9ybt6xxxx
Help?
You need to upgrade to a newer version of Ha
Thanks Daniel. Some progress though I now have this error:
2017-11-02 16:51:08 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi_aqara
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 194, in _async_setup_component
component.setup, hass, processed_config)
File “/usr/lib/python3.6/asyncio/futures.py”, line 331, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.6/asyncio/tasks.py”, line 244, in _wakeup
future.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 244, in result
raise self._exception
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/components/xiaomi_aqara.py”, line 95, in setup
interface)
File “/usr/lib/python3.6/site-packages/PyXiaomiGateway/init.py”, line 31, in init
self._socket.bind((interface, 0))
OSError: [Errno 99] Address not available
2017-11-02 16:51:09 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=Invalid config, message=The following components and platforms could not be set up:
- xiaomi-aqara
Please check your config, notification_id=invalid_config, service_call_id=1966250672-2>
2017-11-02 16:51:09 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.invalid_config, old_state=None, new_state=<state persistent_notification.invalid_config=The following components and platforms could not be set up:- xiaomi-aqara
Please check your config; title=Invalid config @ 2017-11-02T16:51:09.107352+10:00>>
I have slimmed down my configuration.yaml to this:
xiaomi_aqara:
discovery_retry: 10
interface: '192.168.1.168'
gateways:
- mac:
key: xxxxduu9ybt6xxxx
Something is wrong the interface adress
Might be an issue with the instructions or the underlying code as I thought I had the config correct as per the docs? I have changed my configuration.yaml to the following and it is working. Thanks for the help Daniel!
xiaomi_aqara:
discovery_retry: 10
gateways:
- host: 192.168.1.168
- mac:
key: xxxxduu9ybt6xxxxx
Then it would be great if you can help update and improve the documentation. In the upper right corner of any documentation page, you will find “Edit this page on GitHub”. Follow the link and submit your suggested change. Demonstrated here: https://youtu.be/dRfk9JAlPJk?t=1h16m17s
I would be happy to but I am not sure what the issue is with the interface line. Should it not have the single quotes around it? If they are supposed to be there I don’t know why it did not work?
Edit: I will try the interface line without the quotes and see if it works.
Hi,
In my case i have this configuration in HA 0.56.2, and works well. The mac field i have it empty.
xiaomi_aqara:
discovery_retry: 10
gateways:
- mac:
key: !secret xiaomi_key
Hope can help you
No using the interface line does not work for me. I tried the following.
xiaomi_aqara:
discovery_retry: 10
interface: 192.168.1.168
gateways:
- mac:
key: xxxxduu9ybt6xxxxx
and received the following error:
2017-11-02 19:32:29 INFO (MainThread) [homeassistant.setup] Setting up xiaomi_aqara
2017-11-02 19:32:29 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi_aqara
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 194, in _async_setup_component
component.setup, hass, processed_config)
File “/usr/lib/python3.6/asyncio/futures.py”, line 331, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.6/asyncio/tasks.py”, line 244, in _wakeup
future.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 244, in result
raise self._exception
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/components/xiaomi_aqara.py”, line 95, in setup
interface)
File “/usr/lib/python3.6/site-packages/PyXiaomiGateway/init.py”, line 31, in init
self._socket.bind((interface, 0))
OSError: [Errno 99] Address not available
2017-11-02 19:32:29 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=Invalid config, message=The following components and platforms could not be set up:
- xiaomi-aqara
Please check your config, notification_id=invalid_config, service_call_id=1965771440-2>
2017-11-02 19:32:29 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.invalid_config, old_state=None, new_state=<state persistent_notification.invalid_config=The following components and platforms could not be set up:- xiaomi-aqara
Please check your config; title=Invalid config @ 2017-11-02T19:32:29.920413+10:00>>
However I do see the following with my “working” configuration.yaml entry. What controlling is not going to be possible?
2017-11-02 19:39:04 INFO (MainThread) [homeassistant.loader] Loaded xiaomi_aqara from homeassistant.components.xiaomi_aqara
2017-11-02 19:39:04 WARNING (MainThread) [homeassistant.components.xiaomi_aqara] Gateway Key is not provided. Controlling gateway device will not be possible.
2017-11-02 19:39:04 WARNING (MainThread) [homeassistant.components.xiaomi_aqara] Static address (192.168.1.168:9898) of the gateway provided. Discovery of this host will be skipped.
I have now just slimmed the configuration.yaml entry right back to what @garvarma showed and no error messages. So not sure what the issue is with specifying the gateway IP address?