Anyone lose access to their Xiaomi Aqara gateway today?

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.

Downgraded all wireless and switches, still no go. Tried every combination of key, mac, host without success. Can ping gateway and control it from Mi Home App. Re-generated api key several times in app, updated config and restarted, still no go. Lost now.

I’ve now ordered a Conbee II from Amazon so I’ll be offline with 30 odd sensors for 2 weeks while I await its arrival. Be nice not to have to rely on the Xiaomi Hub.

optional with one gateway, mandatory with more than 1:

vol.Optional(CONF_GATEWAYS, default={}):
    vol.All(cv.ensure_list, vol.Any(
        vol.All([GATEWAY_CONFIG_MAC_OPTIONAL], vol.Length(max=1)),
        vol.All([GATEWAY_CONFIG_MAC_REQUIRED], vol.Length(min=2))
    ), [_fix_conf_defaults]),

thats really strange.

I guess you couldn’t get any useful debug? (or way too much!)

good luck

Might be easier to quote to the docs as not everybody reads the source code :wink:;

mac
(string)(Optional)The MAC address of your gateway. Needs to be formatted without “:”.
Optional if only using one gateway.

That’s a bummer. I’m making some network changes soon and will likely need to reset one of the hubs, this makes me nervous.

I have a few cc2531 sticks on standby just in case but honestly I preferred using the Xiaomi hubs rather than mqtt.

Yep, it seems the gateway reset has screwed it up. In my efforts to get it talking to the Mi Home app which wasn’t really necessary now that I think about it, HA will no longer talk to it. I even sparked up another HA instance on a Pi to test and that couldn’t see it either. Lesson learnt. If it ain’t broke…

I’ll switch to Deconz and see if that is a better long-term solution.

Nope, nothing useful when I changed the log to debug. I had the same issue with non-visibility of the xiaomi hub when I tried installing HA in Docker on my NAS many months ago. It’s the reason I gave up with Docker for HA and Node Red.

I’m now running HassOS on NUC i3 and apart from this (not so little) issue today, it’s been rock solid.

SOLVED! Turns out an update effects the gateway when it’s reset or something along those lines and the UDP ports required for HA access get closed.

From a Linux machine on the network, run this command.

sudo nmap -sU 192.168.xx.xx -p 9898,4321

If both ports say closed, you have to crack the unit open, solder three wires and connect a serial converter to send it a command via PuTTy. Fortunately I’m a hardware guy and I’ve flashed many Sonoff’s and other devices so I’m well versed at this.

The solution is documented here https://community.openhab.org/t/solved-openhab2-xiaomi-mi-gateway-does-not-respond/52963/126

There is also another HA thread with tons of information on this issue here.

Once done, you should get the following back:

pi@pi-plantgateway:~ $ sudo nmap -sU 10.0.1.20 -p 9898,4321

Starting Nmap 7.40 ( https://nmap.org ) at 2019-06-01 23:34 NZST
Nmap scan report for 10.0.1.20
Host is up (-0.12s latency).
PORT     STATE         SERVICE
4321/udp open|filtered rwhois
9898/udp open          monkeycom
MAC Address: 34:CE:00:00:00:00 (Unknown)

Glad you got it sorted. So resetting your hub switched off the developer mode, and when enabling developer mode again the firmware bug was preventing the ports from being opened? I had thought that developer mode was persistent across a reset, so that’s a bummer.

I’ll have to keep the SSID of my network the same so I don’t ever have to reset the device… Although I’ve soldered and flashed sonoffs, my actual soldering skills aren’t that great and I don’t like the idea of connecting a mains-powered device to my laptop USB port.

I lost track as I reset the damn Aqara gateway so many times trying to get it working. I had two issues.

  1. After resetting, I could not get the gateway to appear in the mi Home app even though it was actually connected to my network. This was DNS related and your DNS should ideally be 8.8.8.8 when joining the gateway to the app.

  2. My 2nd issue was lack of visibility to HA which turns out to be blocked port so after one of the resets, the ports got blocked and I didn’t realise.

A simply soft 5s soft network reset may not result in the problems I encountered?

N.B As a side note, my colours on my gateway light are now back to front after the reset. Red is Blue and vice versa so something went screwy.

1 Like

I rebuilt my Home Assistant server in an attempt to resolve some folder and file permission errors as well as cleaning up old code. I followed a different guide than the one I had used before. I could see the gateway, I could turn the light on and off, and my temperature and door sensors would read at startup, but then refuse to update.

The solution was my Docker-compose YAML file.
My old config had

homeassistant:
    container_name: homeassistant
    image: homeassistant/home-assistant
    network_mode: "host"

but the new config omitted "network_mode: “host”

Once I added that back in and ran my docker-compose up -d command, all is working.