Anyone lose access to their Xiaomi Aqara gateway today?

My NAS Docker jacobalberty/unifi image auto updated this afternoon using Watchtower and at the same time, my Aqara Gateway dropped off of Home Assistant and the Mi Home App. I’'ve reset the gateway and tried adding it to both of my SSID’s (using the Mi app) without success even though the controller shows it as a connected client and it can be pinged.

For testing, I got out my 4G WiFi router and reset the Aqara Gateway again and this time tried joining it to that and it connected first time and appeared in the Mi Home app as a device.

Anyone with with both a 5.10.24 controller and Aqara Hub having issues?

FYI, my Aqara hub is now working again in HA except for power monitoring from my Xiaomi Zigbee switches. The attributes are showing as:

in_use: 1
load_power: null
power_consumed: null
battery_level: 100
friendly_name: Fridge Kitchen
icon: mdi:power-plug

I cannot get the gateway to connect back to the Mi Home app so I have no devices in their at all and unable to check the power stats that way.

P.S Also upgraded to 0.93.2 today so don’t know if that is related.

[EDIT] Spoiler. If you have issues with your Mi Home app pairing with your xiaomi hub, make sure your network DNS is set 1.1.1.1 or 8.8.8.8 etc as my issue was related to that. I had the Adblock Home add-on as the DNS an no way I could get it to pair. Changed DNS and instantly paired. I’m still stuck with HA seeing the hub but that’s a whole nother story. :cry:

Me but not only since today but 4-5 days… My gateway is working fine on Xiaomi home but not find in home assistant… (H.A 0.93.2 and Gateway 2.75.3 it’s a MIJIA v2 and aqara sensors)

I’m on .90.2 and HA does see my Xiaomi sensors

no issues with 0.93.2 and gateway firmware 1.4.1_167.0158, and plugin 2.75.3
(running HA on ubuntu as virtenv)

Thanks. I’ve traced the problem to the Adguard Home add-on. With my DNS pointing to that, no way the Mi Home app will complete the setup process even though the gateway does actually connect to my network.

With all my mucking around though, it seems I’ve factory restored the hub and now not only do I have to re-pair 30 devices, HA will no longer connect to it even though I’ve updated the key.

I’m stuffed now. One step forward, one back. I can now get the gateway to connect and appear in the Mi Home app but now I’ve lost it in HA. Arghh…!

This is my config:

xiaomi_aqara:
  discovery_retry: 10
  gateways:
    # - mac: !secret Xaiomi_MAC
    - host: 10.0.1.20
      key: !secret Xaiomi_API

Prior to my messing with the gateway and resetting it 38 times, I only had the key defined and it’s been working fine for 2yrs! Now it just does not want to connect to HA. The gateway can be pinged and is showing in my UniFi controller on that (fixed) IP address. The Mi Home app can control it and I’ve turned the LAN control on and off and reset the key several times, always updating it in my secrets file.

Is it possible the original key is persistently stored somewhere preventing connection with the new key?

in HA? Nope - not afaik. And the code at core/homeassistant/components/xiaomi_aqara/__init__.py at dev · home-assistant/core · GitHub doesn’t suggest it is picked up anywhere other than the configuration.yaml file.

When you say it doens’t want to connect - are there any errors (either the standard log, or in the syslog if you get stuff there)? Does the xiaomi_aqara.play_ringtone service show in dev_service? Does it work?

Thanks @walaj . Logs pretty sparse.

2019-05-30 17:19:02 WARNING (MainThread) [homeassistant.setup] Setup of xiaomi_aqara is taking over 10 seconds.
2019-05-30 17:19:07 ERROR (SyncWorker_12) [homeassistant.components.xiaomi_aqara] No gateway discovered
2019-05-30 17:19:07 ERROR (MainThread) [homeassistant.setup] Setup failed for xiaomi_aqara: Component failed to initialize.

Where do I get the syslog from? I have no xiaomi services available at all. It was working this morning when I was trying to get the gateway to initialise in the Mi Home app and once I removed Adguard Home as the DNS, Mi Home app connected and added the gateway straight away. Seems like that at that time though, it dropped off from HA never to be seen again. I’ve tried adding the MAC, Host etc and nothing works. Maybe my gateway has died?

Can someone try updating their gateway key in the Mi Home app and then update it in HA and see if it still connects?

:roll_eyes: what if it doesn’t connect any more… :thinking:

Seriously, you should check the troubleshooting part of the docs. The error you get has nothing to do with the key but indicates there is a connection problem:

That means that Home Assistant is not getting any response from your Xiaomi gateway. Might be a local network problem or your firewall.

Are you sure host is correct, try to remove it as it disables multicast discovery.

Thanks. I removed the host and just left the key as that they way it was for the last 2yrs but still no go. Something obviously going on with my UniFi network or the gateway itself.

depends on the platform - on my virtenv direct install on ubuntu, there is a bucket load of extra logging in /var/log/syslog that I dont get in the homeassistant.log

walaj@JonLabNUC:/home/homeassistant/.homeassistant/automations$ cat /var/log/syslog|grep hass|tail -10
May 30 18:12:55 JonLabNUC hass[14441]: 2019-05-30 18:12:55 INFO (MainThread) [homeassistant.helpers.script] Script battery_sensor_from_attributes: Running script
May 30 18:12:55 JonLabNUC hass[14441]: 2019-05-30 18:12:55 INFO (MainThread) [homeassistant.helpers.script] Script battery_sensor_from_attributes: Executing step call service
May 30 18:12:55 JonLabNUC hass[14441]: 2019-05-30 18:12:55 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: sensor plug_158d0002431039_battery, sending update
May 30 18:12:55 JonLabNUC hass[14441]: 2019-05-30 18:12:55 INFO (MainThread) [homeassistant.helpers.script] Script battery_sensor_from_attributes: Executing step call service
May 30 18:12:55 JonLabNUC hass[14441]: 2019-05-30 18:12:55 INFO (MainThread) [homeassistant.components.mqtt] Got update for entity with hash: ('sensor', 'plug_158d0002431039_battery') '{'name': 'WashingMachine Battery', 'state_topic': 'homeassistant/sensor/plug_158d0002431039_battery/state', 'value_template': '{{ value_json.value | int }}', 'unit_of_measurement': '%', 'device_class': 'battery', 'unique_id': 'plug_158d0002431039_battery', 'json_attributes_topic': 'homeassistant/sensor/plug_158d0002431039_battery/attributes', 'platform': 'mqtt', 'discovery_hash': ('sensor', 'plug_158d0002431039_battery')}'
May 30 18:12:55 JonLabNUC hass[14441]: 2019-05-30 18:12:55 INFO (MainThread) [homeassistant.components.mqtt] Updating component: sensor.washingmachine_battery
May 30 18:12:55 JonLabNUC hass[14441]: 2019-05-30 18:12:55 INFO (MainThread) [homeassistant.helpers.script] Script battery_sensor_from_attributes: Executing step call service
May 30 18:13:00 JonLabNUC hass[14441]: 2019-05-30 18:13:00 INFO (MainThread) [homeassistant.components.automation] Executing update_battery_status_group_members
May 30 18:13:00 JonLabNUC hass[14441]: 2019-05-30 18:13:00 INFO (MainThread) [homeassistant.helpers.script] Script update_battery_status_group_members: Running script
May 30 18:13:00 JonLabNUC hass[14441]: 2019-05-30 18:13:00 INFO (MainThread) [homeassistant.helpers.script] Script update_battery_status_group_members: Executing step call service

Can you check UDP port 9898 is open on your gateway. You can use nmap as below. Replace 192.168.x.x with the ip address of your gateway.

sudo nmap -sU -p 9898 192.168.x. x

Welcome @Pete and thanks for the practical advice.

Host is up (-0.12s latency).
PORT     STATE         SERVICE
9898/udp open|filtered monkeycom

Looks OK?

Thanks, but looks more difficult with Hassio/HassOS. I’ve set the logger to debug and restarted so we’ll see what that dishes up.

Yep. That’s fine. Mine was closed since a firmware update.

Yeah, I’m a bit stumped now. :cry:

Probably not relevant since you’ve commented it out, but if it’s not commented out in your actual config then you have a dash before the “mac” part of your config.

My own aqara config looks as below (not real MAC values):

xiaomi_aqara:
  discovery_retry: 10
  gateways:
    - key: secretkey1
      host: 192.168.1.30
      mac: 7811DCB1FBG9
    - key: secretkey2
      host: 192.168.1.15
      mac: 7C49EB1C29G2

Is the MAC only required if you have multiple gateways?

Also might be no harm to double check the MAC value on the gateway itself and in ubiquiti. I could swear I’ve seen the MAC change for some chinese devices when I’ve hard reset them.

EDIT: also you have Xiaomi spelt incorrectly in your reference to your secrets file; is this the same spelling in the actual secrets file as well? Could be you’re not providing a valid key at all.

Try to increase discovery_retry. Mine is set at 25 and it will connect eventually lol

I also have dash in front of mac, no issue.

Thanks. I’ve tried adding all those (and fixing my spelling mistake) along with a retry at 25 but still not working even though I can ping the Aqara gateway. I’m going to try and downgrade my entire UniFi network even though it was working yesterday morning with the current firmware before I hard reset the Aqara. There is a bit of chatter on the UniFi forums about 4.0.42.10433 so I’ll give that a go.