Xiaomi aquara - No gateway discoverd

Hi,

  • Raspbian on Ras Pi 1B
  • Home assistant on Rasbian (v.0.69.1)
  • Disabled firewall on router, no firewall in Raspbian
  • Enabled Lan access
  • Tried to leave the MAC address mac: blank

My config :

xiaomi_aqara:
  discovery_retry: 10
  gateways:
    - mac: 7811dcb7bb6d
      key: 2ypq9y75v4pgj48f

Im newbie. I’m trying to setup xiaomi aqara. When i start Home assistant i got error. It is worth mentioning that I previously installed xiaomi gateway success. But when i restart Pi, i got this problem.

May 18 01:48:26 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform xiaomi_aqara
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/xiaomi_aqara.py", line 24, in setup_platform
    for (_, gateway) in hass.data[PY_XIAOMI_GATEWAY].gateways.items():
KeyError: 'xiaomi_gw'
May 18 01:48:26 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform xiaomi_aqara
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/xiaomi_aqara.py", line 24, in setup_platform
    for (_, gateway) in hass.data[PY_XIAOMI_GATEWAY].gateways.items():
KeyError: 'xiaomi_gw'

And log :

May 18 01:48:58 raspberrypi hass[3376]: 2018-05-18 01:48:58 INFO (Thread-3) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 10)
May 18 01:49:03 raspberrypi hass[3376]: 2018-05-18 01:49:03 INFO (Thread-3) [xiaomi_gateway] Gateway discovery finished in 5 seconds
May 18 01:49:03 raspberrypi hass[3376]: 2018-05-18 01:49:03 ERROR (Thread-3) [homeassistant.components.xiaomi_aqara] No gateway discovered
May 18 01:49:03 raspberrypi hass[3376]: 2018-05-18 01:49:03 INFO (MainThread) [homeassistant.setup] Setup of domain xiaomi_aqara took 52.2 seconds.
May 18 01:49:03 raspberrypi hass[3376]: 2018-05-18 01:49:03 ERROR (MainThread) [homeassistant.setup] Setup failed for xiaomi_aqara: Component failed to initialize.
May 18 01:49:03 raspberrypi hass[3376]: 2018-05-18 01:49:03 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_call_id=3049867408-4, domain=persistent_notification, service_data=notification_id=invalid_config, title=Invalid config, message=The following components and platforms could not be set up:
May 18 01:49:03 raspberrypi hass[3376]:  - [xiaomi-aqara](https://home-assistant.io/components/xiaomi_aqara/)
May 18 01:49:03 raspberrypi hass[3376]: Please check your config., service=create>
May 18 01:49:03 raspberrypi hass[3376]: 2018-05-18 01:49:03 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=notifying; title=Invalid config, message=The following components and platforms could not be set up:
May 18 01:49:03 raspberrypi hass[3376]:  - [xiaomi-aqara](https://home-assistant.io/components/xiaomi_aqara/)
May 18 01:49:03 raspberrypi hass[3376]: Please check your config. @ 2018-05-18T08:49:03.351548+07:00>>

And log :

May 18 01:49:23 raspberrypi hass[3376]: 2018-05-18 01:49:23 INFO (MainThread) [homeassistant.components.discovery] Found new service: xiaomi_gw {'host': '192.168.1.102', 'mac_address': '7811dcb7bb6d', 'hostname': 'lumi-gateway-v3_miio78811079.local.', 'port': 54321, 'properties': {'epoch': '1', 'mac': '7811dcb7bb6d'}}
May 18 01:49:23 raspberrypi hass[3376]: 2018-05-18 01:49:23 INFO (MainThread) [homeassistant.core] Bus:Handling <Event platform_discovered[L]: discovered=host=192.168.1.102, mac_address=7811dcb7bb6d, hostname=lumi-gateway-v3_miio78811079.local., port=54321, properties=epoch=1, mac=7811dcb7bb6d, service=xiaomi_gw>

image

Thank so much!

Your mac address can’t be right, you’re missing the “:” and it think it must be in capitals. The same for the key. One more thing, I thought python 3.6 was required now a days.

I modified my config but still got same error

xiaomi_aqara:
  discovery_retry: 10
  gateways:
    - mac: 7811dcb7bb6d
      key: 2ypq9y75v4pgj48f

Hi,

take out the mac number, just put only the key.

In my case i have this, and works!

xiaomi_aqara:
  discovery_retry: 10
  gateways:
    - mac:
      key: !secret xiaomi_key

Thank @garvarma, but dont work with me. Still got error

Fixed: Reboot router :smile:. Thanks everyone!