Homekit error in 0.68

Hello everyone,

Tried the HomeKit integration introduced a few updates ago with mixed success (some devices not responding etc) so I thought it might be a good time to test it again. However, now I cannot even get it to work at all. Removed the pin-code option in the configuration file so it only reads homekit: and removed the .homekit.state file and rebooted my docker container. All I get now is an error in the log:

Log Details (ERROR)

Thu May 10 2018 09:28:04 GMT+0200 (CEST)

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/app/homeassistant/components/homekit/init.py”, line 204, in start
self.add_bridge_accessory(state)
File “/usr/src/app/homeassistant/components/homekit/init.py”, line 190, in add_bridge_accessory
self.bridge.add_accessory(acc)
File “/usr/local/lib/python3.6/site-packages/pyhap/accessory.py”, line 468, in add_accessory
raise ValueError(“Duplicate AID found when attempting to add accessory”)
ValueError: Duplicate AID found when attempting to add accessory

Anyone got any ideas?

@upsideduck The error is caused by to entities having the same entity_id.
That normally should not happen / be the case.

Can you take a look at config? It would be good to now if it’s a component error, so to speak, or introduced though manual configuration.

If you have problems identifying the entities, debug logging for the homekit component might help you with that.

logger:
  default: warning
  logs:
    homeassistant.components.homekit: debug

If you know the entity_id, you can use the filter to temporally exclude the entities to test if homekit works.

Besides that, you can try updating to the recent beta. In case the error is caused by a misbehaving component, it might already be fixed.

Hope that helps

@cdce8p Thanks for the reply. I was guessing something like this had happened but I would have expected other complications if this had happened.

The logger gave me an I idea of where to start looking and I could begon to narrow down which entity was the faulty one by first using the exclude_domains tag and then further narrowing down by using exclude_entities. Luckily it was a entity which I do not want I homekit anyway,

Thanks!

I have the same problem and the process by @upsideduck is quite painful. Is there a better way to find the duplicate? I have lots of entities, and restarting HASS each time to test it is painful…add in the homekit service delay as is documented on the homekit doco page…I’ll be here for a month of sundays.

Debug logs for both pyhap and homekit give little indication (as per: https://www.home-assistant.io/components/homekit/)

Any other way to narrow this down?

I’m beginning to think that my issue is to do with long entity names.

binary_sensor.this_is_long_entity_name_one
binary_sensor.this_is_long_entity_name_two

These then get truncated to appear as a duplicate.

Can anyone tell me what the mac characters is for an entity name (that in turn translates to an Accessory ID - AID)?

That they appear to have the same name, doesn’t have anything to do with the AID. It’s just that the Home App can’t display characters beyond a certain length. However you can rename your entities in the App.

Any ideas how to fix this error? I can’t find duplicated entities.

I listed all entities with

{%- for state in states -%}
- {{state.entity_id + "\n"}}
{%- endfor -%}

…but there are no duplicated entities.

2020-02-18 22:00:19 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 247, in async_run
    await self._handle_action(action, variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 331, in _handle_action
    await self._actions[_determine_action(action)](action, variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 413, in _async_call_service
    context=context,
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 96, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context
  File "/usr/src/homeassistant/homeassistant/core.py", line 1226, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1253, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/homekit/__init__.py", line 167, in handle_homekit_service_start
    homekit.start()
  File "/usr/src/homeassistant/homeassistant/components/homekit/__init__.py", line 378, in start
    self.add_bridge_accessory(state)
  File "/usr/src/homeassistant/homeassistant/components/homekit/__init__.py", line 350, in add_bridge_accessory
    self.bridge.add_accessory(acc)
  File "/usr/local/lib/python3.7/site-packages/pyhap/accessory.py", line 354, in add_accessory
    raise ValueError("Duplicate AID found when attempting to add accessory")
ValueError: Duplicate AID found when attempting to add accessory