Dropping connection to aqara hub

Hi,

I have been running home assistant with my aqara m2 hub for a couple months now and has been working great. The past week I have had a couple instances when home assistant stops getting updates from any of the aqara sensors.

The aqara app shows the sensors working and reporting fine. But the sensors in home assistant shows the same value as when it stopped reporting. The history graph shows data updates up until the crash and then its a straight line.

Other non aqara sensors and devices work OK at this point and only a restart of home assistant brings the aqara sensors back online. They don’t report as missing or errored, just no data updates.

I looked in the logs and saw the following:

2021-04-09 19:00:52 ERROR (zeroconf-ServiceBrowser__hap._tcp.local._3945363) [root] Uncaught thread exception#033[0m
Traceback (most recent call last):
   File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
     self.run()
   File "/srv/homeassistant/lib/python3.8/site-packages/zeroconf/__init__.py", line 1755, in run
     self._service_state_changed.fire
        File "/srv/homeassistant/lib/python3.8/site-packages/zeroconf/__init__.py", line 1513, in fire
     h(**kwargs)
   File "/srv/homeassistant/lib/python3.8/site-packages/zeroconf/__init__.py", line 1611, in on_change
        listener.add_service(*args)                                                                                                                                                                                                                         File "/srv/homeassistant/lib/python3.8/site-packages/aiohomekit/zeroconf/__init__.py", line 80, in add_service
     if info.properties[b"id"].decode() == self._device_id:
 KeyError: b'id'

Then, every minute it has the following:

 Traceback (most recent call last):
   File "/srv/homeassistant/lib/python3.8/site-packages/aiohomekit/controller/ip/connection.py", line 512, in _reconnect
     return await self._connect_once()                                                                                                                                                                                                                   File "/srv/homeassistant/lib/python3.8/site-packages/aiohomekit/controller/ip/connection.py", line 572, in _connect_once
     self.host, self.port = await async_find_device_ip_and_port(
   File "/srv/homeassistant/lib/python3.8/site-packages/aiohomekit/zeroconf/__init__.py", line 281, in async_find_device_ip_and_port
     data = await loop.run_in_executor(
   File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
     result = self.fn(*self.args, **self.kwargs)
   File "/srv/homeassistant/lib/python3.8/site-packages/aiohomekit/zeroconf/__init__.py", line 266, in _find_data_for_device_id                                                                                                     
   if info.properties[b"id"].decode() == device_id:
 KeyError: b'id'

This is quite frustrating as I thought it may be a network issue but as I can still use the aqara app OK, and within the aqara app I don’t see any missing data, along with a home assistant service restart only, makes me wonder if it’s a bug in home assistant that should be recoverable.

Any help would be appreciated as all I can think of next is to have a scrip monitoring the error log and have it restart home assistant. Not very elegant

Hi,

It’s been some time and there are no replies to your problem. We’re you able to solve the issue? My Homekit Controller to the Amara app seems to timeout. After a restart of HA the sensors are back online but then the sensors disappear again.

Thanks.

Sorry to be unhelpful, but it is fixed but I did nothing. It seemed to get over whatever was wrong with it by itself.

Thanks. Maybe this will also happen on my side…keeping my finders crossed :slight_smile: