Ikea Tradfri connection Unknow error

Hello!
I would like some help with my home assistant setup(hass.io on linux system) :frowning:
I have been using home assistant for a while and it’s been working fine.
But every since i update to 0.98( and 0.98.1 aswell) I can’t connect to my tradfri hub in Home assistant.
The ikea app is working fine, but i can’t seem to connect it.
I get this error: https://paste.ubuntu.com/p/JcCX4PVC93/.
Can anyone help me? I have tried a fresh install of Hass.io but didn’t help :frowning:

What exactly do you mean by “can’t connect to” ?
Can you see the Gateway in HA ?
If you check the IKEA component docs, it tells you how to edit configuration.yaml, have you done what it says?

It can’t complete the integrations, because it gives an unknown error.
I checked the component docs, everything should be just fine.
When i set the home assistant version to 0.97.2 it still works but when ever i updated the version the connection breaks.

If you want help, you must give much more detailed information:

  • What platform are you running HA on ?
  • What is your client setup ?
  • What exact steps did you perform before the error appeared?
  • What exactly is the error message (pls provide screen shots)?
  • Does your IKEA App work ok? Can you configure and control lights using the App?
  • What platform are you running HA on ?
    Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-60-generic x86_64)
  • What is your client setup ?
    I installed with the HASS.io install scripts.
  • What exact steps did you perform before the error appeared?
    I wanted to add the ikea tradfri integration
  • What exactly is the error message (pls provide screen shots)?
    https://imgur.com/a/Uktit6k
  • Does your IKEA App work ok? Can you configure and control lights using the App?
    Yes, i did a complete reset and added everything again. So the Ikea app works, I just can’t add the integration in Hass

i seem to have the same problem, i’m working with docker on a raspberry pi.
version: 0.99.0.dev20190915

error log: 2019-09-15 09:36:01 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/homeassistant/homeassistant/components/http/real_ip.py", line 40, in real_ip_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 231, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 128, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 164, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 48, in wrapper result = await method(view, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 90, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 89, in async_configure result = await self._async_handle_step(flow, cur_step["step_id"], user_input) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 132, in _async_handle_step result: Dict = await getattr(flow, method)(user_input) File "/usr/src/homeassistant/homeassistant/components/tradfri/config_flow.py", line 55, in async_step_auth self.hass, host, user_input[KEY_SECURITY_CODE] File "/usr/src/homeassistant/homeassistant/components/tradfri/config_flow.py", line 164, in authenticate key = await api_factory.generate_psk(security_code) File "/usr/local/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 195, in generate_psk self._psk = await self.request(command) File "/usr/local/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 155, in request result = await self._execute(api_commands) File "/usr/local/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 146, in _execute _, res = await self._get_response(msg) File "/usr/local/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 95, in _get_response r = await pr.response File "/usr/local/lib/python3.7/site-packages/aiocoap/protocol.py", line 720, in _run_outer await cls._run(app_request, response, weak_observation, protocol, log) File "/usr/local/lib/python3.7/site-packages/aiocoap/protocol.py", line 745, in _run await protocol.find_remote_and_interface(app_request) File "/usr/local/lib/python3.7/site-packages/aiocoap/protocol.py", line 295, in find_remote_and_interface if await ri.fill_or_recognize_remote(message): File "/usr/local/lib/python3.7/site-packages/aiocoap/tokenmanager.py", line 179, in fill_or_recognize_remote return await self.token_interface.fill_or_recognize_remote(message) File "/usr/local/lib/python3.7/site-packages/aiocoap/messagemanager.py", line 327, in fill_or_recognize_remote remote = await self.message_interface.determine_remote(message) File "/usr/local/lib/python3.7/site-packages/aiocoap/transports/tinydtls.py", line 328, in determine_remote dtlsparams = self.ctx.client_credentials.credentials_from_request(request) File "/usr/local/lib/python3.7/site-packages/aiocoap/credentials.py", line 285, in credentials_from_request raise CredentialsMissingError("No suitable credentials for %s" % uri) aiocoap.credentials.CredentialsMissingError: No suitable credentials for coaps://192.168.1.2:5684/15011/9063

Are you guys using configuration.yaml or the new integration feature of Lovelace when trying to connect?
Remember that the new integration method takes precedence and whatever is in configuration.yaml is ignored. If you wish to use configuration.yaml instead, you have to delete the integration first.
However, I have found that using configuration.yaml to define the IKEA hub, instead of relying on autodiscovery has helped on the very first time setup.

I tried both ways, but I get the error on both of them.

I had the same issue, getting a CredentialMissingErorr exception.
This was due to an updated API in the latest Trådfri gateway firmware. This has been fixed in the latest pytradfri which was updated in HA 0.99.1.

My solution was to update Home Assistant.

I have the same problem.
Linux odroid-1 4.15.0-65-generic #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux, using python3.7.3, ha 0.99.3. Tradfri gateway has firmware 1.9.27, the app claims that this is the newest version.
pytradfri is 6.3.1

  • With discovery and without tradfri section in configuration.yaml the ui shows the new Tradfri integration and the configure button, if i enter the ip and a string or the real security code the ‘Unknown error occured’.
  • Without discovery and the old tradfri section in configuration.yaml: Same behaviour.
  • Without discovery and without tradfri section: Need to add the integration via plus botton, same same.

Integration worked fine before, i am not aware of any changes. It just stopped to work and i deleted the last integration in the ui.

2019-10-07 20:24:27 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 40, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 231, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 128, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/config/config_entries.py", line 164, in post
    return await super().post(request, flow_id)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/data_validator.py", line 48, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/data_entry_flow.py", line 90, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 89, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/srv/homeassistant/lib/python3.7/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.7/site-packages/homeassistant/components/tradfri/config_flow.py", line 55, in async_step_auth
    self.hass, host, user_input[KEY_SECURITY_CODE]
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/tradfri/config_flow.py", line 164, in authenticate
    key = await api_factory.generate_psk(security_code)
  File "/srv/homeassistant/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 195, in generate_psk
    self._psk = await self.request(command)
  File "/srv/homeassistant/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 155, in request
    result = await self._execute(api_commands)
  File "/srv/homeassistant/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 146, in _execute
    _, res = await self._get_response(msg)
  File "/srv/homeassistant/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 95, in _get_response
    r = await pr.response
  File "/srv/homeassistant/lib/python3.7/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 "/srv/homeassistant/lib/python3.7/site-packages/aiocoap/protocol.py", line 865, in _run
    blockresponse = yield from blockrequest.response
  File "/srv/homeassistant/lib/python3.7/site-packages/aiocoap/protocol.py", line 695, in _init_phase2
    yield from self.protocol.fill_remote(self.app_request)
  File "/srv/homeassistant/lib/python3.7/site-packages/aiocoap/protocol.py", line 426, in fill_remote
    raise RuntimeError("No transport could route message")
RuntimeError: No transport could route message

As we need to switch of the lights as 10 years ago, i apprecciate help :smiley:
Aleks

2 Likes

Have exactly the same issue. Same HA version, same Ikea firmware.

Having the same issue, but using the docker container for 0.100.2. I had to revert back to 97.2 to get everything working again.

Running 0.100.2 myself, no issues with Tradfri, using VENV install on Raspbian OS. :slight_smile:

Problem exists also in 0.101.2.

2019-11-03 17:19:17 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 40, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 136, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 122, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/config/config_entries.py", line 163, in post
    return await super().post(request, flow_id)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/http/data_validator.py", line 48, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/data_entry_flow.py", line 90, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 89, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/srv/homeassistant/lib/python3.7/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.7/site-packages/homeassistant/components/tradfri/config_flow.py", line 52, in async_step_auth
    self.hass, host, user_input[KEY_SECURITY_CODE]
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/tradfri/config_flow.py", line 161, in authenticate
    key = await api_factory.generate_psk(security_code)
  File "/srv/homeassistant/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 195, in generate_psk
    self._psk = await self.request(command)
  File "/srv/homeassistant/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 155, in request
    result = await self._execute(api_commands)
  File "/srv/homeassistant/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 146, in _execute
    _, res = await self._get_response(msg)
  File "/srv/homeassistant/lib/python3.7/site-packages/pytradfri/api/aiocoap_api.py", line 95, in _get_response
    r = await pr.response
  File "/srv/homeassistant/lib/python3.7/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 "/srv/homeassistant/lib/python3.7/site-packages/aiocoap/protocol.py", line 865, in _run
    blockresponse = yield from blockrequest.response
  File "/srv/homeassistant/lib/python3.7/site-packages/aiocoap/protocol.py", line 695, in _init_phase2
    yield from self.protocol.fill_remote(self.app_request)
  File "/srv/homeassistant/lib/python3.7/site-packages/aiocoap/protocol.py", line 426, in fill_remote
    raise RuntimeError("No transport could route message")
RuntimeError: No transport could route message

pytradfri has not changed (still 6.3.1), aiocoap 0.4a1, tried against the requirements aiohttp 3.6.2, but same same.

Any luck fixing this? I seem to have hit the same issue after update from 0.108 to 0.113: IKEA Tradfri integration cannot be re-added after upgrade to 0.113.3

Thanks

Here even with a fresh install of hassos image with core-2021.2.3 on a RPi 3:
unknown error when trying to integrate IKEA Tradfri after sending Security key via WebUI.

Same issue here. Core-2021.2.3 os 5.12 on Pi 3.

Unknown error after trying to re-add

Logger: aiohttp.server
Source: components/tradfri/config_flow.py:168
First occurred: 10:05:03 (3 occurrences)
Last logged: 10:06:39

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 96, in _get_response
    r = await pr.response
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 169, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 106, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 155, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 213, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/tradfri/config_flow.py", line 53, in async_step_auth
    auth = await authenticate(
  File "/usr/src/homeassistant/homeassistant/components/tradfri/config_flow.py", line 168, in authenticate
    key = await api_factory.generate_psk(security_code)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 220, in generate_psk
    self._psk = await self.request(command)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 168, in request
    result = await self._execute(api_commands)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 152, in _execute
    _, res = await self._get_response(msg)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 116, in _get_response
    await self._update_credentials()
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 236, in _update_credentials
    "psk": self._psk.encode("utf-8"),
AttributeError: 'NoneType' object has no attribute 'encode'