home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.32k stars 30.63k forks source link

HomeKit Device Integration - "KeyError: 'characteristics'" #98112

Closed ammacdonald3 closed 1 year ago

ammacdonald3 commented 1 year ago

The problem

I recently added two new Aqara door sensors and one new Aqara motion sensor. The sensors initially fed over to Home Assistant and automatically created entities through the HomeKit Device integration. However, very frequently, the entities report a "Became Unavailable" status. My resolution is to reload the HomeKit Device integration, which seems to temporarily resolve the issue before it happens again.

The sensors integrate with the Aqara app and report statuses there without issue. Additionally, I have dozens of other Aqara sensors that have been integrated with Home Assistant through the HomeKit Device integration (via an Aqara G2H camera hub). All other sensors have generally performed without issue, but since adding these three new ones, they periodically report "Became Unavailable" as well (but not as often as the three new sensors).

Restarting Home Assistant and/or reloading the integration provides a temporary fix until it eventually starts happening again. Restarting the hub (Aqara G2H camera) didn't do anything.

What version of Home Assistant Core has the issue?

core-2023.8.1

What was the last working version of Home Assistant Core?

No response

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

home-assistant_homekit_controller_2023-08-09T14-09-18.808Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Unexpected exception from <bound method HKDevice.async_update of <homeassistant.components.homekit_controller.connection.HKDevice object at 0x7fc2f39be850>>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 116, in _handle_timer_finish
    await task
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/connection.py", line 769, in async_update
    new_values_dict = await self.get_characteristics(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/connection.py", line 837, in get_characteristics
    return await self.pairing.get_characteristics(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohomekit/controller/ip/pairing.py", line 274, in get_characteristics
    return format_characteristic_list(response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohomekit/controller/ip/pairing.py", line 60, in format_characteristic_list
    for c in data["characteristics"]:
             ~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'characteristics'

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @jc2k, @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit_controller) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `homekit_controller` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign homekit_controller` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


homekit_controller documentation homekit_controller source (message by IssueLinks)

bdraco commented 1 year ago

2023-08-09 10:09:18.042 DEBUG (MainThread) [aiohomekit.controller.ip.connection] 192.168.0.231: raw response: bytearray(b'{"status":-70407}')

bdraco commented 1 year ago

This error meads the device it out of resources:

outOfResource: -70407,
ammacdonald3 commented 1 year ago

Thank you for the help! Do you know what the "out of resource" error means? Is it possible that too many devices are connected to my Aqara hub?

bdraco commented 1 year ago

The vendor decides when to throw that error. You would have to ask them

ammacdonald3 commented 1 year ago

Sounds good, thank you again! I'll close out this issue and explore alternate methods (maybe connecting these sensors directly to HA with Skyconnect).