IKEA Tradfri aiocoap.credentials.CredentialsMissingError: No suitable credentials for

I struggled a lot with getting the IKEA Tradfri devices to be working with HA. Took some time to get the modules installed correctly. But now I am at the place where this one kicks in:

    2018-11-17 17:13:52 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 390, in start
    resp = await self._request_handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_app.py", line 366, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 106, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 97, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 66, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 97, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/view.py", line 113, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/data_validator.py", line 47, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/data_entry_flow.py", line 86, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/data_entry_flow.py", line 80, in async_configure
    flow, step_id, user_input)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/data_entry_flow.py", line 98, in _async_handle_step
    result = await getattr(flow, method)(user_input)  # type: Dict
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/tradfri/config_flow.py", line 52, in async_step_auth
    user_input[KEY_SECURITY_CODE])
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/tradfri/config_flow.py", line 151, in authenticate
    key = await api_factory.generate_psk(security_code)
  File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 195, in generate_psk
    self._psk = await self.request(command)
  File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 155, in request
    result = await self._execute(api_commands)
  File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 146, in _execute
    _, res = await self._get_response(msg)
  File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 95, in _get_response
    r = await pr.response
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/protocol.py", line 718, in _run_outer
    await cls._run(app_request, response, weak_observation, protocol, log)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/protocol.py", line 743, in _run
    await protocol.find_remote_and_interface(app_request)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/protocol.py", line 293, in find_remote_and_interface
    if await ri.fill_or_recognize_remote(message):
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/tokenmanager.py", line 179, in fill_or_recognize_remote
    return await self.token_interface.fill_or_recognize_remote(message)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/messagemanager.py", line 327, in fill_or_recognize_remote
    remote = await self.message_interface.determine_remote(message)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/transports/tinydtls.py", line 328, in determine_remote
    dtlsparams = self.ctx.client_credentials.credentials_from_request(request)
  File "/srv/homeassistant/lib/python3.6/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.0.48:5684/15011/9063

Did you figure this out? I am getting the same error

No, and I am really eager to get my pytradfri up and running, I have been dreaming about this for 6 months now. But I am still hoping, I have a feeling that its soon. :slight_smile:

I got mine going today!
I reset my gateway but I am not 100% sure that was needed. Here is what I did, not neccesarily in this order but this should prevent going back on yourself like I did!

I am not sure the first 3 steps were required:

  1. From Tradfri App, removed all devices.
  2. Hard reset gateway. (I think I did this 3 times as all the devices came back the first)
  3. Reinstalled lubuntu! (I dont think this was necessary. Probably removing the virtual environment would have been enough.
  4. Updated and Installed dependencies:
apt-get install python3 python3-pip python3-venv
apt-get install build-essential libssl-dev libffi-dev python3-dev
apt-get install autoconf
  1. Installed to virtual environment following instructions here: Manual Install

Fingers crossed.

Due to missing autoconf I did that after the hass install then manually installed the erroring components:

pip3 install pytradfri[async]==6.0.1

Hope this helps you.

Hmm, interesting that you made it work, did you have exactly the same error message? Can someone with more experience maybe assist in pinpointing where we should look for the problem, it seems that this could be fixed with checking some versions of libraries or dependencies?

If you don’t fancy a full rebuild just try these:

apt-get install build-essential libssl-dev libffi-dev python3-dev
apt-get install autoconf

Maybe uninstall home assistant before this one:

pip3 install pytradfri[async]==6.0.1

And watch for error messages on the home assistant reinstall.

Also here was my error message in the logs.
It was different on the ha install.

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/static.py", line 66, in staticresource_middleware
        return await handler(request)
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
        return await handler(request)
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 67, in ban_middleware
        return await handler(request)
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 99, in auth_middleware
        return await handler(request)
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/view.py", line 118, in handle
        result = await result
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/config/config_entries.py", line 136, in post
        return await super().post(request, flow_id)
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/data_validator.py", line 47, in wrapper
        result = await method(view, request, *args, **kwargs)
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/data_entry_flow.py", line 86, in post
        result = await self._flow_mgr.async_configure(flow_id, data)
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/data_entry_flow.py", line 80, in async_configure
        flow, step_id, user_input)
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/data_entry_flow.py", line 98, in _async_handle_step
        result = await getattr(flow, method)(user_input)  # type: Dict
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/tradfri/config_flow.py", line 52, in async_step_auth
        user_input[KEY_SECURITY_CODE])
      File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/tradfri/config_flow.py", line 151, in authenticate
        key = await api_factory.generate_psk(security_code)
      File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 195, in generate_psk
        self._psk = await self.request(command)
      File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 155, in request
        result = await self._execute(api_commands)
      File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 146, in _execute
        _, res = await self._get_response(msg)
      File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 95, in _get_response
        r = await pr.response
      File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/protocol.py", line 718, in _run_outer
        await cls._run(app_request, response, weak_observation, protocol, log)
      File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/protocol.py", line 743, in _run
        await protocol.find_remote_and_interface(app_request)
      File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/protocol.py", line 293, in find_remote_and_interface
        if await ri.fill_or_recognize_remote(message):
      File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/tokenmanager.py", line 179, in fill_or_recognize_remote
        return await self.token_interface.fill_or_recognize_remote(message)
      File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/messagemanager.py", line 327, in fill_or_recognize_remote
        remote = await self.message_interface.determine_remote(message)
      File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/transports/tinydtls.py", line 328, in determine_remote
        dtlsparams = self.ctx.client_credentials.credentials_from_request(request)
      File "/srv/homeassistant/lib/python3.6/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://a0-cc-2b-6f-8a-f5:5684/15011/9063

If this works, I am guessing that there is something wrong elsewhere, with dependencies or libraries?

I definitely missed off some of those installs the first time.
Give it a go. Uninstall HA from the virtual environment, install dependencies through apt-get, then do the pytradfri specifying the version before installing HA again.

You were completely right. It worked with a re-install. Thanks buddy! :grinning::grinning::grinning:

Argh, the problem came back with the 0.89 upgrade.

Log Details (ERROR)
Thu Mar 07 2019 21:38:01 GMT+0100 (Central European Standard Time)
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 33, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 68, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 98, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/view.py", line 112, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/config/config_entries.py", line 144, in post
    return await super().post(request, flow_id)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/data_validator.py", line 46, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/data_entry_flow.py", line 86, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/data_entry_flow.py", line 80, in async_configure
    flow, step_id, user_input)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/data_entry_flow.py", line 98, in _async_handle_step
    result = await getattr(flow, method)(user_input)  # type: Dict
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/tradfri/config_flow.py", line 52, in async_step_auth
    user_input[KEY_SECURITY_CODE])
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/tradfri/config_flow.py", line 151, in authenticate
    key = await api_factory.generate_psk(security_code)
  File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 195, in generate_psk
    self._psk = await self.request(command)
  File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 155, in request
    result = await self._execute(api_commands)
  File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 146, in _execute
    _, res = await self._get_response(msg)
  File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 95, in _get_response
    r = await pr.response
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/protocol.py", line 718, in _run_outer
    await cls._run(app_request, response, weak_observation, protocol, log)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/protocol.py", line 743, in _run
    await protocol.find_remote_and_interface(app_request)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/protocol.py", line 293, in find_remote_and_interface
    if await ri.fill_or_recognize_remote(message):
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/tokenmanager.py", line 179, in fill_or_recognize_remote
    return await self.token_interface.fill_or_recognize_remote(message)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/messagemanager.py", line 327, in fill_or_recognize_remote
    remote = await self.message_interface.determine_remote(message)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiocoap/transports/tinydtls.py", line 328, in determine_remote
    dtlsparams = self.ctx.client_credentials.credentials_from_request(request)
  File "/srv/homeassistant/lib/python3.6/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.0.48:5684/15011/9063

And I re-tried the trick, with no success!

I am still messing with this, and trying to be constructive, what might be the problem? It seems so simple, and when it worked the first time, it has to be a version incompatibility? Any hints?