Issues with Xiaomi Aqara Gateway - KeyError: 'key'

Hello,
Currently running HASS 0.64.3 within a docker on Unraid.

I’m not quite sure when (e.g. at which HASS update) my Xiaomi Aqara Gateway stopped working, but I’m no longer able to render it within HASS.

My component info in configuration has remained valid, and I’ve verified the key is correct:

#########################
###   Xiaomi Gateway  ###
#########################
xiaomi_aqara:
  discovery_retry: 10
  gateways:
    - host: 192.168.86.33
    - key: 70g*********

I do get some errors within the .log file, with the last line indicating “KeyError: ‘key’”

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/setup.py", line 148, in _async_setup_component
    component.setup, hass, processed_config)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/wink/__init__.py", line 312, in setup
    pywink.get_subscription_key())
  File "/usr/local/lib/python3.6/site-packages/pywink/api.py", line 577, in get_subscription_key
    response_dict = wink_api_fetch()
  File "/usr/local/lib/python3.6/site-packages/pywink/api.py", line 598, in wink_api_fetch
    raise WinkAPIException("401 Response from Wink API.  Maybe Bearer token is expired?")
pywink.api.WinkAPIException: 401 Response from Wink API.  Maybe Bearer token is expired?
2018-03-04 15:49:36 DEBUG (SyncWorker_0) [homeassistant.components.xiaomi_aqara] Expecting 2 gateways
2018-03-04 15:49:36 INFO (SyncWorker_0) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 1)
2018-03-04 15:49:36 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi_aqara
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/setup.py", line 148, in _async_setup_component
    component.setup, hass, processed_config)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/xiaomi_aqara.py", line 130, in setup
    xiaomi.discover_gateways()
  File "/usr/local/lib/python3.6/site-packages/xiaomi_gateway/__init__.py", line 93, in discover_gateways
    key = gateway['key']
KeyError: 'key'

Any suggestions of where / how to troubleshoot? I’ve googled around a bit and can’t find anything with the KeyError I’m getting.

There was a breaking change some releases ago - Use:

xiaomi_aqara:
  discovery_retry: 5
  gateways:
    - mac:
      key: !secret xiaomi_gw_key
1 Like

Yep. That did it. Thanks…didn’t even notice the removal of the dash on the component definition page.