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
71.14k stars 29.81k forks source link

Unable to add homekit accessories #25118

Closed CLARENNE-Q closed 5 years ago

CLARENNE-Q commented 5 years ago

Home Assistant release with the issue:

0.95.4

Last working Home Assistant release (if known): 0.95.4

Operating environment (Hass.io/Docker/Windows/etc.):

Docker

Component/platform:

Synology

Description of problem: When I try to add Homekit access the return this error:


500 Internal Server Error

Server got itself in trouble

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

Traceback (if applicable):

2019-07-13 03:00:53 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/app/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware
    return await handler(request)
  File "/usr/src/app/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/usr/src/app/homeassistant/components/http/auth.py", line 216, in auth_middleware
    return await handler(request)
  File "/usr/src/app/homeassistant/components/http/view.py", line 115, in handle
    result = await result
  File "/usr/src/app/homeassistant/components/config/config_entries.py", line 120, in post
    return await super().post(request)
  File "/usr/src/app/homeassistant/components/http/data_validator.py", line 46, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/app/homeassistant/helpers/data_entry_flow.py", line 57, in post
    handler, context={'source': config_entries.SOURCE_USER})
  File "/usr/src/app/homeassistant/data_entry_flow.py", line 71, in async_init
    return await self._async_handle_step(flow, flow.init_step, data)
  File "/usr/src/app/homeassistant/data_entry_flow.py", line 123, in _async_handle_step
    result = await getattr(flow, method)(user_input)  # type: Dict
  File "/usr/src/app/homeassistant/components/homekit_controller/config_flow.py", line 86, in async_step_user
    self.controller.discover, 5
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homekit/controller/controller.py", line 89, in discover
    return discover_homekit_devices(max_seconds)
  File "/usr/local/lib/python3.7/site-packages/homekit/zeroconf_impl/__init__.py", line 102, in discover_homekit_devices
    info.properties
  File "/usr/local/lib/python3.7/site-packages/homekit/zeroconf_impl/__init__.py", line 153, in parse_discovery_properties
    d['flags'] = FeatureFlags[flags]
  File "/usr/local/lib/python3.7/site-packages/homekit/model/feature_flags.py", line 33, in __getitem__
    raise KeyError('Item {item} not found'.format(item=item))
KeyError: 'Item 2 not found'

Additional information:

ghost commented 5 years ago

Hey there @Jc2k, mind taking a look at this issue as its been labeled with a integration (homekit_controller) you are listed as a codeowner for? Thanks!

This is a automatic comment generated by codeowners-mention to help ensure issues and pull requests are seen by the right people.

Jc2k commented 5 years ago

What kind of homekit device are you trying to pair? It looks like it has a feature flag we don't recognise in its Bonjour/mDNS record.

SimonThoustrup commented 5 years ago

Hi. Similar error on 0.96.5 when selecting HomeKit Accesory from the 'Add new Integration' menu. I never see the next input box, the system just reloads the 'Add new Integration' menu.

  File "/usr/local/share/homeassistant/lib/python3.7/site-packages/homekit/controller/controller.py", line 89, in discover
    return discover_homekit_devices(max_seconds)
  File "/usr/local/share/homeassistant/lib/python3.7/site-packages/homekit/zeroconf_impl/init.py", line 102, in discover_homekit_devices
    info.properties
  File "/usr/local/share/homeassistant/lib/python3.7/site-packages/homekit/zeroconf_impl/init.py", line 153, in parse_discovery_properties
    d['flags'] = FeatureFlags[flags]
  File "/usr/local/share/homeassistant/lib/python3.7/site-packages/homekit/model/feature_flags.py", line 33, in getitem
    raise KeyError('Item {item} not found'.format(item=item))
KeyError: 'Item 2 not found'

Aparently it's fixed in homekit_python 0.15.0.

Jc2k commented 5 years ago

Thanks @SimonThoustrup.

Can you confirm what the make and model of your homekit accessories are.

SimonThoustrup commented 5 years ago

It's the Gardena Smart Gateway (connecting to a Sileno City mower).

Jc2k commented 5 years ago

Ok well hopefully the PR for 0.15.0 will fix pairing but I don’t think we support any mower specific homekit types in HASS yet, do you know how it manifests in proper iOS?

pkmnct commented 4 years ago

I hate to dig up an old thread, but I am facing the exact same error listed here in a brand new install (0.103.6) of home-assistant:

2020-07-13 05:40:50 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py", line 40, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 136, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/view.py", line 123, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/config/config_entries.py", line 130, in post
    return await super().post(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/data_validator.py", line 48, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/data_entry_flow.py", line 60, in post
    handler, context={"source": config_entries.SOURCE_USER}
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/data_entry_flow.py", line 73, in async_init
    return await self._async_handle_step(flow, flow.init_step, data)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/data_entry_flow.py", line 132, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/homekit_controller/config_flow.py", line 82, in async_step_user
    all_hosts = await self.hass.async_add_executor_job(self.controller.discover, 5)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homekit/controller/controller.py", line 90, in discover
    return discover_homekit_devices(max_seconds)
  File "/srv/homeassistant/lib/python3.6/site-packages/homekit/zeroconf_impl/__init__.py", line 102, in discover_homekit_devices
    info.properties
  File "/srv/homeassistant/lib/python3.6/site-packages/homekit/zeroconf_impl/__init__.py", line 180, in parse_discovery_properties
    d['category'] = Categories[int(category)]
  File "/srv/homeassistant/lib/python3.6/site-packages/homekit/model/categories.py", line 94, in __getitem__
    raise KeyError('Item {item} not found'.format(item=item))
KeyError: 'Item 31 not found'
Jc2k commented 4 years ago

It's best to open a new issue so that it appears in the devs todo list. I only noticed because I happened to get a GH email.

That's quite an old release you have there - we are on 0.112 now - and quite a bit of code in that traceback doesn't exist any more. We don't even use the same homekit library any more. So can you try with 0.112 and raise a new issue if you still have problems.