Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tradfri integration breaks if updating to v0.99.0 #26673

Closed
ggravlingen opened this issue Sep 16, 2019 · 38 comments · Fixed by #26731
Closed

Tradfri integration breaks if updating to v0.99.0 #26673

ggravlingen opened this issue Sep 16, 2019 · 38 comments · Fixed by #26731
Assignees

Comments

@ggravlingen
Copy link
Contributor

ggravlingen commented Sep 16, 2019

#f03c15 If it's not working, roll back to the 0.98.5 docker image (confirmed to be working) until we've fixed the issue.

Home Assistant release with the issue:

0.99.x (reported in Discord/Beta group)

Last working Home Assistant release (if known):
0.99.x (reported by another user to be a working version in Discord/Beta group)

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

Component/platform:

https://www.home-assistant.io/components/tradfri/

Description of problem:

Anecdotal evidence in Home Assistant's forums and Discord channels suggests tradfri is not working in version 1.9 of the gateway.

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

Traceback (if applicable):

Error setting up entry 10.0.100.5 for tradfri
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 190, in async_setup
    hass, self
  File "/usr/src/homeassistant/homeassistant/components/tradfri/__init__.py", line 114, in async_setup_entry
    gateway_info = await api(gateway.get_gateway_info())
  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://10.0.100.5:5684/15011/15012

Additional information:
Related issue for upstream dependency: home-assistant-libs/pytradfri#246

@rechena
Copy link

rechena commented Sep 17, 2019

Which version of HA? I have it with working with 0.98.5 and TRADFRI 1.9.27 (latest version)

Oh I see on the commit, that you're using 0.99? So I think it would be fair to say its on the HA side?

@ggravlingen
Copy link
Contributor Author

Interesting! The reports are from people running the latest beta.

@balloob
Copy link
Member

balloob commented Sep 17, 2019

The only changes to Tradfri has been this. But that's only internal facing and should not make a difference.

@Jocke67
Copy link

Jocke67 commented Sep 18, 2019

I have been trying to get Home Assistant working with the IKEA gateway for a couple of days now.
Unfortunatley I get the same "aiocoap.credentials.CredentialsMissingError: No suitable credentials for coaps:..." error when I try to register the gateways security key in the web interface.

I am running a fresh install of Home Assistant 0.98.5 on a RaspberryPi 3 and an IKEA Gateway 1.9.27.

@ggravlingen
Copy link
Contributor Author

@Jocke67 did you use one of the docker images or did you do a stand-alone install?

@Jocke67
Copy link

Jocke67 commented Sep 18, 2019

@ggravlingen I have tried both Hassbian and a manual install following these guides:

https://www.home-assistant.io/docs/installation/hassbian/installation/

https://www.home-assistant.io/docs/installation/raspberry-pi/

Both installations gave me the same error.

@ggravlingen
Copy link
Contributor Author

Then you are most likely missing dependencies as suggested above. I would strongly advise using this method: https://github.com/home-assistant/hassio-installer

@ggravlingen
Copy link
Contributor Author

@balloob agree, that’s not it. I’ll keep this issue open over the next release and if the comments don’t pour in, I’ll close it and the issue on the status page.

@erikpuntnl
Copy link

Hi, i'm at work at this moment so I can't give any details but wanted to let you know that I've got also a problem with it. It worked before, gave a faillure so I tried to add it again but now it gives an "unknown error". I'm running Home Assistant on a RPi 4 with the Hass.io supervisor 188 (beta) and HassOS 3.5.
Can't acces the log from my location, if more info is needed I can give it later today (local time) .

Erik

@mhalden
Copy link

mhalden commented Sep 18, 2019

I see the same error after upgrading to the 0.99 beta. It used to work fine with 0.98. I'm not sure what version my Ikea trådfri hub is and I'm unfortunately not able to check at the moment.

@VanFlipsen
Copy link

VanFlipsen commented Sep 18, 2019

I have the same problem, don't know if it is a problem with 0.99b* or the new firmware on the gateway 1.9.27. Updated them simultaneously.

Error while trying to add the integration

Log Details (ERROR)

Wed Sep 18 2019 20:26:26 GMT+0200 (Midden-Europese zomertijd)
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.2.12:5684/15011/9063

@ge2rt
Copy link

ge2rt commented Sep 18, 2019

Confirmation that HA 0.98.5 with Tradfri GW 1.9.27 still appears to work. No weird log entries (also after HA restart), automations and interactions still work. Running on RPi3B+, Hass.io v188, HassOS v2.12

@BeardedTinker
Copy link

On 0.99 release, HA in docker, Tradfri GW 1.9.27 Tradfri no longer works. "No suitable credentials..."

@scho0ck
Copy link

scho0ck commented Sep 19, 2019

Same issue doesn‘t work on docker

@Jocke67
Copy link

Jocke67 commented Sep 19, 2019

@ggravlingen Did a new fresh install, according to your advice I followed this method: https://github.com/home-assistant/hassio-installer

This gave me a Home Assistant ver. 0.99 installation with the same "No suitable credentials for coaps" problem when I try to register the IKEA gateway security key.

@johanvanderkuijl
Copy link

Just updated to 0.99.0 on Raspberry Pi with docker and Ikea tradfri gateway Firmware: 1.9.27, got:

Error setting up entry x.x.x.x for tradfri
No suitable credentials for coaps:

@Jocke67
Copy link

Jocke67 commented Sep 19, 2019

According to the IKEA release notes the Gateway 1.9.27 version contains connectivity issues involving CoAP.
IKEA_release_notes

@ggravlingen
Copy link
Contributor Author

It seems an upstream dependency has changed so this is a possible solution: home-assistant-libs/pytradfri#248.

Other than that, nothing has changed in pytradfri since 0.98. I just read the release log of HA and as @balloob has already stated above, there is nothing obvious in there that would cause this.

@ggravlingen
Copy link
Contributor Author

I've pushed pytradfri 6.3.1 to pypi, holding a posible fix. Can someone please bump the version in their HA and test if it works?

@magnusoverli
Copy link

I've pushed pytradfri 6.3.1 to pypi, holding a posible fix. Can someone please bump the version in their HA and test if it works?

I can, if you let me know how...

@nicx
Copy link
Contributor

nicx commented Sep 19, 2019

I have not updated my Tradfri gateway firmware for months... but HA to 0.99. With this new HA version I have this problem, too. With the last HA version 0.98 its still working fine. So this bug has nothing to do with the Tradfri firmware ;)

@magnusoverli
Copy link

@nicx Can you confirm the version on your Tradfri GW? Mine updates itself if it has internet connectivity...

@nicx
Copy link
Contributor

nicx commented Sep 19, 2019

@magnusoverli I am at work so I can confirm it this evening ;) But mine is not auto updating, only when using the Tradfri app (which I dont use). I will get back to your question when I am at home.

@Masteroshi430
Copy link

Masteroshi430 commented Sep 19, 2019

Same here, gateway version 1.9.27 (it auto updates without opening the tradfri app) HA version 0.99

Error setting up entry 192.168.0.13 for tradfri
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 190, in async_setup
    hass, self
  File "/usr/src/homeassistant/homeassistant/components/tradfri/__init__.py", line 114, in async_setup_entry
    gateway_info = await api(gateway.get_gateway_info())
  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.0.13:5684/15011/15012

@efauske
Copy link

efauske commented Sep 19, 2019

I updated from HA 0.98.5 to 0.99 today, and the same occurred for me.
I reverted to a snapshot of HA 0.98.5 and the Tradfri devices were available again. Gateway version 1.9.27 in both cases.

@johanvanderkuijl
Copy link

I rolled back to docker image 0.98.5 and the problem went away immediately.

@ggravlingen
Copy link
Contributor Author

The theory I'm working on is that upstream dependency DTLSSocket has introduced a change that is breaking for us since the last Home Assistant image was built. We have not been strict with what versions of DTLSSocket to use, which introduces this problem.

image

In pytradfri 6.3.1 we're being more strict, also using a version that seems to be working.

I don't know how to test this using HA docker images. I believe someone testing the new code for the blinds was using the custom component technique, but I'm not sure how that works.

@thinkl33t
Copy link
Contributor

Can confirm, same error happened to me overnight last night:

2019-09-19 09:19:06 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 172.16.32.58 for tradfri
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 190, in async_setup
    hass, self
  File "/usr/src/homeassistant/homeassistant/components/tradfri/__init__.py", line 114, in async_setup_entry
    gateway_info = await api(gateway.get_gateway_info())
  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://172.16.32.58:5684/15011/15012

@thinkl33t
Copy link
Contributor

thinkl33t commented Sep 19, 2019

Horrible hack but:

docker exec -ti home-assistant /bin/bash
> apk install autoconf gcc libc-dev
> pip install pytradfri==6.3.1 pytradfri[async]=6.3.1
> exit
docker restart home-assistant

Has gotten mine working again (using docker), so i can confirm that bumping pytradfri to 6.3.1. fixes the issue.

@ggravlingen
Copy link
Contributor Author

Thank you @thinkl33t! I’ve mentioned this fix to @balloob and unless he or someone else beats me to it, I’ll have time to provide a fix tonight or tomorrow night.

If you want to do it, look at my PR for the blinds here and see what files I’ve changed where pytradfri 6.3.1 is mentioned.

@Mariusthvdb
Copy link
Contributor

According to the IKEA release notes the Gateway 1.9.27 version contains connectivity issues involving CoAP.
IKEA_release_notes

do you have a link for these Ikea release notes please? really nice to be able to read these to know what updated

@Jocke67
Copy link

Jocke67 commented Sep 19, 2019

@Mariusthvdb I googled "ikea trådfri release notes" and found this link:

https://ww8.ikea.com/ikeahomesmart/releasenotes/releasenotes.html

@ggravlingen ggravlingen changed the title Tradfri integration breaks if updating to version 1.9 of gateway? Tradfri integration breaks if updating to v0.99 Sep 19, 2019
@ggravlingen ggravlingen changed the title Tradfri integration breaks if updating to v0.99 Tradfri integration breaks if updating to v0.99.0 Sep 19, 2019
@ggravlingen
Copy link
Contributor Author

@Mariusthvdb this is not on IKEA's side but due to a bug in pytradfri. The bug has been fixed and now needs to be released to Home Assistant.

@Mariusthvdb
Copy link
Contributor

@Mariusthvdb I googled "ikea trådfri release notes" and found this link:

https://ww8.ikea.com/ikeahomesmart/releasenotes/releasenotes.html

duh, that was easy. sorry for that...

@hfurubotten
Copy link
Contributor

The horrible hack over by @thinkl33t didn't work for me, but I can then come with my own horrible hack.. Downgrading to 0.89.5 would still probably be best for everyone until the release with fix is out :)

Did the install commands, but when I restarted the docker container, HA took over and downloaded the "old" pypi package again that was marked in the manifest.json file, but can also do this which fixed it for me:

docker exec -ti homeassistant /bin/bash
> vi usr/src/homeassistant/homeassistant/components/tradfri/manifest.json
# edit as shown below
docker restart homeassistant

Editing the file in vi from

"requirements": [
    "pytradfri[async]==6.0.1"
  ],

to

"requirements": [
    "pytradfri[async]==6.3.1"
  ],

@lipadeus
Copy link

The horrible hack over by @thinkl33t didn't work for me, but I can then come with my own horrible hack.. Downgrading to 0.89.5 would still probably be best for everyone until the release with fix is out :)

Did the install commands, but when I restarted the docker container, HA took over and downloaded the "old" pypi package again that was marked in the manifest.json file, but can also do this which fixed it for me:

docker exec -ti homeassistant /bin/bash
> vi usr/src/homeassistant/homeassistant/components/tradfri/manifest.json
# edit as shown below
docker restart homeassistant

Editing the file in vi from

"requirements": [
    "pytradfri[async]==6.0.1"
  ],

to

"requirements": [
    "pytradfri[async]==6.3.1"
  ],

Worked for me! Thx!

@balloob balloob mentioned this issue Sep 19, 2019
9 tasks
@kisst
Copy link

kisst commented Aug 25, 2020

This error looks like to be back in the current versions:

File "/usr/local/lib/python3.8/site-packages/aiocoap/credentials.py", line 274, in credentials_from_request
    raise CredentialsMissingError("No suitable credentials for %s" % uri)

More info about the setup:

bash-5.0# cat /usr/src/homeassistant/homeassistant/components/tradfri/manifest.json
{
  "domain": "tradfri",
  "name": "IKEA TRÅDFRI",
  "config_flow": true,
  "documentation": "https://www.home-assistant.io/integrations/tradfri",
  "requirements": ["pytradfri[async]==6.4.0"],
  "homekit": {
    "models": ["TRADFRI"]
  },
  "codeowners": ["@ggravlingen"]
}

with Hass running in a container homeassistant/raspberrypi3-homeassistant:

bash-5.0# cat .HA_VERSION 
0.115.0.dev20200825

Latest container:

$ docker pull homeassistant/raspberrypi3-homeassistant
Using default tag: latest
latest: Pulling from homeassistant/raspberrypi3-homeassistant
Digest: sha256:998533704d578fe935f72e2ad67e03304a7c299617a206d1699a487be3f59e98
Status: Image is up to date for homeassistant/raspberrypi3-homeassistant:latest
docker.io/homeassistant/raspberrypi3-homeassistant:latest

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Aug 25, 2020
@balloob
Copy link
Member

balloob commented Aug 25, 2020

This is an old issue. Please open a new issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.