20s delay on homekit controller

I just switch to MariaDB. But after that, all my entities on Homekit Controller have a delay for updating the state. Does anyone know the reason?

I use Homekit Controller to control the aqara gateway, the motion sensor will be triggered in aqara app immediately, but it takes over 20s to respond on HA.

Check the home assistant log, the supervisor log and the addon log for errors.

It does not have error information.

2020-04-01 14:20:29 DEBUG (MainThread) [homeassistant.components.homekit_controller.config_flow] HomeKit info C5:86:CE:C5:93:28: c# incremented, refreshing entities
2020-04-01 14:20:40 DEBUG (MainThread) [homeassistant.components.homekit_controller.connection] Starting HomeKit controller update
2020-04-01 14:20:42 DEBUG (MainThread) [homeassistant.components.homekit_controller.connection] Finished HomeKit controller update
2020-04-01 14:21:30 DEBUG (MainThread) [homeassistant.components.homekit_controller.connection] Starting HomeKit controller update
2020-04-01 14:21:30 DEBUG (MainThread) [homeassistant.components.homekit_controller.connection] Finished HomeKit controller update

And the other two logs?

Only updates state per minute.

2020-04-04 01:49:56 DEBUG (SyncWorker_14) [pyhap.characteristic] set_value: On to True
2020-04-04 01:50:57 DEBUG (SyncWorker_7) [pyhap.characteristic] set_value: On to False
2020-04-04 01:51:58 DEBUG (SyncWorker_9) [pyhap.characteristic] set_value: On to True
2020-04-04 01:52:59 DEBUG (SyncWorker_5) [pyhap.characteristic] set_value: On to False

That’s still the home assistant log. Not the supervisor log or the MariaDB addon log.

Hi,

Did you manage to fix this? I have this also setup through the HomeKit Controller and facing about a 1 min delay

Hi all, I have the same problem, although no MariaDB.

I simply have:

  • Aqara System of sensors and switches with Aqara hub G2H Pro
  • Ikea System of lights and window covers with Ikea Dirigera hub.

Both systems are integrated into Home Assistant via HomeKit Controller and all automations happen in Home Assistant.

Everything works perfectly after re-start, but after a few hours or so, the sensors have a lag of 20 seconds. For example, I enter a room, and the sensors won’t register motion until 20sec. later.

Only sensors show this lag. My Aqara switches still respond instantly, although they are connected to the same hub as the sensors. So weird!

How can I check what the problem is?
Where do I find the logs for HomeKit controller exactly?

Spent a whole day wrestling with this too, still could not find out why but wanted to post a workaround I found.

Workaround that might work for you:
On HA dashboard, go to the Homekit integration page (“HomeKit Device”), then find your device in the “Integration entries” list, click on the three dots beside that device, then select “System options”, then toggle “Enable polling for updates” to either on or off, then click Update.
Afterwards, my delay is gone even if I toggle it back to what it was before. So something in toggling that setting must have fixed it. At time of this writing, I am unsure how this could have possibly fixed it and how long this fix would last, but it is much better than nothing I guess.

More Background Info:
I have an Aqara FP2 sensor that was setup on the Aqara app and integrated with HA via the Homekit integration. Everything was working well for a while, zones were detecting and automations were triggering. Generally nothing to complain about. Then one day, all the automations from the FP2 zone triggers stopped working and while I was sitting there scratching my head for a minute, one of the lights turned on. I checked HA, the automation did execute for some reason. After some testing, I found there was a 20 to 30 second delay between me getting into a zone and HA firing off the automation.

After some more (a lot more) testing, I found that:

  1. Aqara FP2 detects the presence and movement with no problems as shown on the Aqara app.
  2. Home Assistant executes the automation as soon as it received the state change from “Clear” to “Detected”
  3. There was nothing in the debug logs that’d suggest any messages were dropped or whether there were relevant errors.

So this implies that something after the handoff from Aqara is delaying the signal and HA was performing faithfully as soon as it receives the signal. This leaves HomeKit as the most likely culprit but that’s a pretty big blackbox as it can be Aqara’s integration with Homekit, the Homekit protocol itself, the network that the HomeKit communications is on, or the Homekit Integration in HA. Digging into it more, I tried many solutions on the internet that did not seem to address the problem, most notably the various posts about mDNS, multicast, broadcast, and other Wifi / network settings. While I am sure it solves other problems, it didn’t help this one. I stopped barking up this tree after I paired another FP2 sensor and it was performing as intended without the delay. This meant that if it was a wifi / network problem, it is unlikely it’d be isolated to one device, and, if it was a homekit integration problem on HA, it probably should not only affect one device too (it can, but not likely).

So this pointed me to the individual device configuration. I then poked around for whatever I can tinker with on HA and found the workaround above to somehow work. I am guessing removing the device and reinstalling it works too, however, I was afraid that I might have to re-link or at least refresh all my automations since re-registering the device can cause some IDs to shift even if you name them back to the same entity name / ID. Re-installing was going to be my last resort, but I am glad I did not have to do it.

All in all, this solution has been working well. I am going to test out whether leaving “Enable polling for updates” off might actually be helpful here since the FP2 would be the one to do the pushing. I am unsure if luminance values or anything else is a poll, but personally I did not need those. Or, this polling setting might be totally irrelevant.

Anyways, hope this helps somebody who is frantically googling this issue to save sometime and hair pulling =D

2 Likes

I’ve had the same problem for a few days now. I tried cycling the power on FP2, but that didn’t solve the problem. So far, my solution has been to restart homeassistant, but after a few hours, the problem returns.

In my case, the problem appeared around the same time after I installed the latest FP2 update with the new AI person detection, which is now enabled. At the same time, I reworked my zones. My cat used to activate the light automation when he was on the stairs, which was leaving ghosts preventing the light from going out. I added an entry and exit zone to get around this problem. The new AI person detection fixes this problem, so I’ve removed these areas.

I also tried disabling Enable polling for updates, which also corrected the problem for the moment. If the problem returns in a few hours, I’ll try disabling AI person detection.

I can’t remember if there was also a home assistant update in the same period, so maybe I’ll try rolling an older backup.

I have the same issue. Either Aqara M2 hub starts responding slowly or FP2 sensors. Reloading the integration always works immediately, so it seems like an issue with HomeKit integration in HA.

When I was using those devices with native iOS HomeKit integration, it worked. When I connected it to the HA, it started doing this.

HomeKit integration with M2 needs to be reloaded monthly (connected via ethernet) and with FP2 sensor it’s random, sometimes I restart the integration daily, sometimes weekly, and sometimes it works for two weeks without delay. But the network seems to be good, I have a perfect mesh network all around the house with full bars everywhere and it also works flawlessly with Aqara app, but integration with HA is unreliable.

One workaround is to automate the reloading of those integrations maybe, but it needs proper investigation.

@Filipko Did you ever find a solution for this? I’ve been dealing with the same issue for a few months and it’s driving me nuts.

Aqara sensors are showing immediate reaction in the Aqara app, but Home Assistant to HomeKit integration is breaking. If I refresh the integration, it works great for about 10 minutes and then back to a 20-30 second (to infinite) delay.

Tried toggling the “Enable polling” setting on the HomeKit device and it seemed to work as well as refreshing the integration for a couple minutes and then it’s back to not working properly.

same issue! i thougth it was my mesh network. but i recently enalbed advanced ai detection.