core: homekit_controller doesn't work fine after updating

The problem

After updating to 2024.8.0 the homekit_controller stopped working correctly with my Xiaomi Mi LED Desk Lamp 1S, in the previous version (2024.7.4) it was working fine.

What version of Home Assistant Core has the issue?

2024.8.0

What was the last working version of Home Assistant Core?

2024.7.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

HomeKit Device

Link to integration documentation on our website

https://www.home-assistant.io/integrations/homekit_controller

Diagnostics information

config_entry-homekit_controller-01J4S8K8YV9W0F1F0G7DVZFQ45.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:241
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: August 8, 2024 at 5:27:47 PM (6 occurrences)
Last logged: 12:54:30 AM

[140029886865200] Unexpected exception
[140029558588608] Unexpected exception
[140029492548160] Unexpected exception
[140029414778784] Unexpected exception
[140029339218800] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/ip/connection.py", line 116, in send_bytes
    return await result
           ^^^^^^^^^^^^
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 637, in async_handle_light_off_service
    await light.async_turn_off(**filter_turn_off_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/light.py", line 196, in async_turn_off
    await self.async_put_characteristics({CharacteristicsTypes.ON: False})
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/entity.py", line 140, in async_put_characteristics
    return await self._accessory.put_characteristics(payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/connection.py", line 986, in put_characteristics
    await self.pairing.put_characteristics(characteristics)
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/ip/pairing.py", line 313, in put_characteristics
    response = await self.connection.put_json(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/ip/connection.py", line 392, in put_json
    response = await self.put(
               ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/ip/connection.py", line 381, in put
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/ip/connection.py", line 527, in request
    resp = await self.protocol.send_bytes(request_bytes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/ip/connection.py", line 197, in send_bytes
    return await super().send_bytes(b"".join(buffer))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohomekit/controller/ip/connection.py", line 126, in send_bytes
    raise AccessoryDisconnectedError("Timeout while waiting for response")
aiohomekit.exceptions.AccessoryDisconnectedError: Timeout while waiting for response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 91 (40 by maintainers)

Commits related to this issue

Most upvoted comments

Its going to depend on how busy my day job is this week.

Just to confirm, the issue is still resolved after a prolonged period of 0 lux. Seems like the PR did the trick. Thanks for the prompt fix!

Carefully run rm -rf /config/custom_components/homekit_controller, restart

To get this into an update we need

I’m hoping we can get them into 2024.8.2 but it might take a bit longer.

It sure looks like it never got installed.

25 minutes since the last restart. Still working. Seems to have done the trick (touch wood)

3 hours in and still good on second PR. It seems resolved, but if lux changes indeed act like a keep-alive as others have discussed, still a remote possibility of failure. Will report back after a night (0 lux for hours) passes.

Unfortunately, all 4 of my current FP2s have again stopped reporting to HA. It works for about 5-10 minutes give or take after a restart. A quick reload on the Homekit Devices’ integration entries section jump-starts the devices again without having to restart HA, but that again is for a very short period as before.

Screenshot 2024-08-11 at 19 10 39

Working at the moment. But I don’t know if it’ll stop again like before. I think after several minutes from the HA restart the problem occurred before. So I’ll give 30 minutes and update?

cd /config

curl -o- -sSL https://gist.githubusercontent.com/bdraco/43f8043cb04b9838383fd71353e99b18/raw/core_integration_pr | bash /dev/stdin -d homekit_controller -p 123601

New version for testing… Important, the command has changed as new pr is #123601

~Can confirm lamp it’s still responding fine to commands~

Lamp it’s back to the malfunctioning state with this new version

Sorry, I have been away. Is this the new command that I have to test? Previous one didn’t work either. Several minutes after the FP2 stopped updating. Will try this now.

FP2 firmware is 1.2.7.0010_0080 here, suggest you upgrade, the changes from the firmware it ships with to now are dramatic.

Tested first PR. So far seems good. Moving on to second.

For camera apple is polling short UID 52 (Firmware Revision) which makes sense since its probably cheap to poll and unlikely to introduce load on the device.

Another thought is that for cameras the Apple client always polls ‘/characteristics?id=1.7’ every so often to keep cameras alive. We might be able to do the same thing without regressing #116143

Can confirm that the lamp it’s now working fine after the PR custom integration installation. Will keep updating

After updating to 2024.8.0 my Aqara FP2 Presence Sensor becomes unresponsive/unavailable within 5 minutes after restarting HomeAsssitant (or reloading HomeKit integration). The presence sensors in HA FP2 HomeKit device stop registering presence events and the built-in light sensor in FP2 also stops updating, so nothing comes through the HomeKit integration into HA. In Aqara app everything works as normal. I have tried re-pairing / restarting (both device and HA) multiple times, but nothing helps. It stops responding within approx. 5 minutes after each restart/reloading. I had been using FP2 via HomeKit with HA for over a year and I have never had this problem.

I have now restored 2024.7.4 from backup and the FP2 Sensor has been working correctly since.

But this means I cannot upgrade to 2024.8 😭.