Problem with Trådfri after upgrade - please help with Python log

I have had Tradfri integration running for half a year with 0.66 build but after updating yesterday to latest Home Assistant every thing stopped working.

I try to add IKEA TRÅDFRI as new found device with the auto discovery. When I press Configure and the add my Access Key I get the response “Unknown error occurred” in the front end. The log state the following:

2018-10-20 16:46:59 INFO (MainThread) [homeassistant.components.http.view] Serving /api/config/config_entries/flow/2bd3bc0e3ef14a7cab759bd9cc2c0c73 to 192.168.1.1 (auth: True)
2018-10-20 16:46:59 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 390, in start
    resp = await self._request_handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/web_app.py", line 366, in _handle
    resp = await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 106, in impl
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 113, in handle
    result = await result
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/data_validator.py", line 47, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/helpers/data_entry_flow.py", line 86, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 80, in async_configure
    flow, step_id, user_input)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 98, in _async_handle_step
    result = await getattr(flow, method)(user_input)  # type: Dict
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/tradfri/config_flow.py", line 52, in async_step_auth
    user_input[KEY_SECURITY_CODE])
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/tradfri/config_flow.py", line 151, in authenticate
    key = await api_factory.generate_psk(security_code)
  File "/Users/Emil/.homeassistant/deps/lib/python/site-packages/pytradfri/api/aiocoap_api.py", line 195, in generate_psk
    self._psk = await self.request(command)
  File "/Users/Emil/.homeassistant/deps/lib/python/site-packages/pytradfri/api/aiocoap_api.py", line 155, in request
    result = await self._execute(api_commands)
  File "/Users/Emil/.homeassistant/deps/lib/python/site-packages/pytradfri/api/aiocoap_api.py", line 146, in _execute
    _, res = await self._get_response(msg)
  File "/Users/Emil/.homeassistant/deps/lib/python/site-packages/pytradfri/api/aiocoap_api.py", line 95, in _get_response
    r = await pr.response
  File "/Users/Emil/.homeassistant/deps/lib/python/site-packages/aiocoap/protocol.py", line 816, in _run_outer
    yield from cls._run(app_request, response, weak_observation, protocol, log, exchange_monitor_factory)
  File "/Users/Emil/.homeassistant/deps/lib/python/site-packages/aiocoap/protocol.py", line 865, in _run
    blockresponse = yield from blockrequest.response
  File "/Users/Emil/.homeassistant/deps/lib/python/site-packages/aiocoap/protocol.py", line 695, in _init_phase2
    yield from self.protocol.fill_remote(self.app_request)
  File "/Users/Emil/.homeassistant/deps/lib/python/site-packages/aiocoap/protocol.py", line 426, in fill_remote
    raise RuntimeError("No transport could route message")
RuntimeError: No transport could route message

So I’m not able to enter my Access key and the integration with Trådfri does not work. Can anyone help understand the log and help me to get this to work.

I’m able to access Trådfri stand alone so the password is correct and everything seems to work then.

Can this have to do with the new authorization which came in 0.77? I’m not really good at understanding the error log.

After removing Home Assitant completely, uninstalled, installed and started all configuration again I get another similar error. This time when I enter the password for the Trådfri router I get the following error trace:

2018-10-24 20:31:04 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 390, in start
    resp = await self._request_handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/web_app.py", line 366, in _handle
    resp = await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 106, in impl
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 113, in handle
    result = await result
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/data_validator.py", line 47, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/helpers/data_entry_flow.py", line 86, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 80, in async_configure
    flow, step_id, user_input)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 98, in _async_handle_step
    result = await getattr(flow, method)(user_input)  # type: Dict
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/tradfri/config_flow.py", line 52, in async_step_auth
    user_input[KEY_SECURITY_CODE])
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/tradfri/config_flow.py", line 142, in authenticate
    from pytradfri.api.aiocoap_api import APIFactory
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 10, in <module>
    from aiocoap.transports import tinydtls
ImportError: cannot import name 'tinydtls' from 'aiocoap.transports' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiocoap/transports/__init__.py)

Please help me out here. I have reinstalled aiocoap and all dependencies I can find out.

tradfri is now part of the “configuration -> integrations” maybe you should remove it and add it from there ?

Thanks for the suggestion. I believe you mean I should try to add it as integration. I tried to and I got a similar error, but I don’t really know what it means. It seams that I’m missing some dependency but I believe I have installed everything. Please have a look at the new log if this make any sense:

2018-10-27 15:07:09 INFO (MainThread) [homeassistant.components.http.view] Serving /api/config/config_entries/flow/3469d602c81d46f2aeb2b15a36f80e05 to 192.168.1.1 (auth: True)
2018-10-27 15:07:09 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 390, in start
    resp = await self._request_handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/web_app.py", line 366, in _handle
    resp = await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 106, in impl
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 68, in auth_middleware
    return await handler(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 113, in handle
    result = await result
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/http/data_validator.py", line 47, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/helpers/data_entry_flow.py", line 86, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 80, in async_configure
    flow, step_id, user_input)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 98, in _async_handle_step
    result = await getattr(flow, method)(user_input)  # type: Dict
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/tradfri/config_flow.py", line 52, in async_step_auth
    user_input[KEY_SECURITY_CODE])
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/homeassistant/components/tradfri/config_flow.py", line 142, in authenticate
    from pytradfri.api.aiocoap_api import APIFactory
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 10, in <module>
    from aiocoap.transports import tinydtls
ImportError: cannot import name 'tinydtls' from 'aiocoap.transports' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aiocoap/transports/__init__.py)

Sorry, don’t know but it seems like a issue with tinydtls and aiocoap. There is a lot of history with issues there and I’m guessing maybe it’s related to the version you are using. You are running HA directly on some linux system ? For a software like this (HA) I would suggest using official dockers to avoid issues.

HW: Mac Mini 2011
OS: OSX High Sierra 10.13.6

Thanks for the support. The Trådfri integration worked fine when I used an official docker. Using docker it seems like discovery stops working and also I can not access the keys for SSL. Do I need to set up some kind of reverse proxy for these two items? I have no real clue in this area either.

I ran docker on a qnap for a while, but choose to go for the HASSOS on rpi (also based on docker) because everything is integrated and no hassle.

You can map folders from the outside into the docker to get to the ssl though if you want to go down that path. Either way when using docker it’s important to have the config file mapped outside the docker, so the config is saved when you update the docker.

My experience is along the lines of this, but I am not going the docker route. What is the challenge here, it seems the question was never answered?