Xiaomi gateway on HassOS

Hi,

I’ve recently purchased a Xiaomi gateway and have it up and running but am struggling to get it to connected to Home Assistant running on HassOS 1.10.

I can see it searching for the gateway but its not finding it:

INFO (SyncWorker_5) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 1)
....
INFO (SyncWorker_5) [homeassistant.components.xiaomi_aqara] Discovering Xiaomi Gateways (Try 10)
ERROR (SyncWorker_5) [homeassistant.components.xiaomi_aqara] No gateway discovered
ERROR (MainThread) [homeassistant.setup] Setup failed for xiaomi_aqara: Component failed to initialize.

I’ve enabled LAN on the Mi Home app, tried lots of config including IP, with the key without the key etc, factory reset the gateway and started again, disabled and re-enabled my router firewall and pretty much every thing in the troubleshooting guide here:

But it all seems to come down to the use of: --net=host
I’ve tried to add docker-compose.yml file in the config directory with network mode set to host:

  version: '3'
  services:
    homeassistant:
      container_name: home-assistant
      image: homeassistant/home-assistant
      volumes:
        - /config:/config
        - /etc/localtime:/etc/localtime:ro
      restart: always
      network_mode: host

But I’m not sure if its being picked up, would HassOS pick this up and should it be in the config directory? If not is there any other way to set --net=host, I’ve seen talk of setting it in the docker run command but tbh don’t know where to start with that.

Any help greatly appreciated.

Thanks

Pete

It turns out adding the host in gets this working:

xiaomi_aqara:
  discovery_retry: 10
  gateways:
    - mac: XXXXXXXXXX  (miss out the ":" ) 
      host: XXX.XXX.XX.XX
      key: XXXXXXXXXXXXXXXX
1 Like

Thanks for posting this update! Was it a pain to get the key? Can you point me to the guide you used to retrieve it? It was a nightmare getting the Xiaomi vacuum key, and I’m not sure if I want to go down that road again…

Get the key for a Gateway is much easier than for a Vaccum : you just need to retrieve it from the Mi Home app as explained here : https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)#Adding_the_Xiaomi_Gateway_to_Domoticz

1 Like

Xiaomi gateway is driving me crazy.

For ages it’s been fine, but recently it’s temperamental. It works in Mi Home app but in HA, when I restart, it just tells me the config is incorrect. Even when I haven’t changed it at all.

Happened the other day, stopped working, I was pulling my hair out. Must have restarted 10 times, changed the config, added the host, MAC etc to config.yaml. Changed the key in Mi Home, and nothing worked.

Then it just suddenly did start working again. Today I restarted for a different reason and it’s giving me the configuration error again.

To get the key/password I just followed this from the troubleshooting section:

https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)#Adding_the_Xiaomi_Gateway_to_Domoticz

I’m having issues too, I can get some sort of connection but I just get as far as:

2018-10-09 18:38:22 DEBUG (SyncWorker_5) [xiaomi_gateway] _send_cmd >> b'{"cmd" : "get_id_list"}'
2018-10-09 18:38:32 ERROR (SyncWorker_5) [xiaomi_gateway] Cannot connect to Gateway
2018-10-09 18:38:37 INFO (SyncWorker_5) [xiaomi_gateway] Gateway discovery finished in 5 seconds
2018-10-09 18:38:37 INFO (SyncWorker_5) [xiaomi_gateway] Creating Multicast Socket
2018-10-09 18:38:37 DEBUG (SyncWorker_5) [homeassistant.components.xiaomi_aqara] Gateways discovered. Listening for broadcasts
2018-10-09 18:38:37 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.xiaomi_aqara

And if I try anything with the hub I just get:

DEBUG (SyncWorker_7) [xiaomi_gateway] Gateway Token was not obtained yet. Cannot send commands to the gateway

Going to set up a home assistant installation not using HassOS see if that works…

Works for me thnks