Cannot add Tradfri Gateway

Hi,

I’m using HASSIO 0.62.1 and Im trying to configure IKEA Tradfri Gateway with latest firmware - 1.3.14

I’ve assigned static IP in the DHCP server for the gateway, configured the remote control and bulbs. Even got Alexa (Echo Dot) to work with it. I’m encountering problems connecting it to HA. I’ve tried rebooting HA, rebooting GW, resetting GW (both from iOS app and from reset button). Still no luck.

This is the HA log file:

2018-02-07 21:08:16 ERROR (MainThread) [coap] Exception CancelledError() can not be represented as errno, setting -1.
2018-02-07 21:08:16 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall configurator.configure: configure_id=ID_PLACED_HERE-1, fields=security_code=SECURITY_CODE_PLACED_HERE>
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 92, in _get_response
    r = yield from pr.response
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/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 "/usr/lib/python3.6/site-packages/aiocoap/protocol.py", line 865, in _run
    blockresponse = yield from blockrequest.response
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
aiocoap.error.RequestTimedOut

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/tradfri.py", line 70, in configuration_callback
    key = yield from api_factory.generate_psk(security_code)
  File "/usr/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 196, in generate_psk
    self._psk = yield from self.request(command)
  File "/usr/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 152, in request
    result = yield from self._execute(api_commands)
  File "/usr/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 142, in _execute
    _, res = yield from self._get_response(msg)
  File "/usr/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 98, in _get_response
    raise RequestTimeout('Request timed out.', e)
pytradfri.error.RequestTimeout: ('Request timed out.', RequestTimedOut())

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/configurator.py", line 224, in async_handle_service_call
    call.data.get(ATTR_FIELDS, {}))
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/tradfri.py", line 73, in configuration_callback
    "Security Code not accepted.")
TypeError: async_notify_errors() takes 3 positional arguments but 4 were given

Also noticed that after hitting the ‘Configure’ button in HA and this is thrown at the logs, I cannot connect from iOS to GW. I’m succeeding after power-cycle the GW. I guess when I try to configure HA it is stalling the GW…

1 Like

I am having exactly the same problem. Did you figure out a solution?

Hi @alvar0rodrig0, sadly, I’m still unable to connect HA to Tradfri GW. :frowning:
There is an update in the ‘pytradfri’ module on github (HA is using it in this plugin). If I’m not wrong HA is using version <4.something> of pytradfri and on github there is 5.3.1 and it says ‘NB: Latest Gateway version tested and working - 1.3.14’. So I guess it is a matter of time to be updated on HA.

Bumping the thread - still have the problem with Hass.IO 0.65.6 and Tradfri 1.3.14:
https://pastebin.com/e2krEVvc
:frowning:

And again bumping because in latest Hass.IO - 0.67 there is ‘Update tradfri v5’ in the changelog but again receiving same error when entering security code and hitting ‘Submit’

HA log:

2018-04-15 10:37:02 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall configurator.configure: configure_id=IDHERE-1, fields=security_code=SECURITYCODEHERE>
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 92, in _get_response
    r = yield from pr.response
  File "/usr/lib/python3.6/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 "/usr/lib/python3.6/site-packages/aiocoap/protocol.py", line 865, in _run
    blockresponse = yield from blockrequest.response
aiocoap.error.RequestTimedOut

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/tradfri.py", line 68, in configuration_callback
    key = await api_factory.generate_psk(security_code)
  File "/usr/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 196, in generate_psk
    self._psk = yield from self.request(command)
  File "/usr/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 152, in request
    result = yield from self._execute(api_commands)
  File "/usr/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 142, in _execute
    _, res = yield from self._get_response(msg)
  File "/usr/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 98, in _get_response
    raise RequestTimeout('Request timed out.', e)
pytradfri.error.RequestTimeout: ('Request timed out.', RequestTimedOut())

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1002, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/configurator.py", line 224, in async_handle_service_call
    call.data.get(ATTR_FIELDS, {}))
  File "/usr/lib/python3.6/site-packages/homeassistant/components/tradfri.py", line 71, in configuration_callback
    "Security Code not accepted.")
TypeError: async_notify_errors() takes 3 positional arguments but 4 were given

Hi!

Got the same problem after HASS update. Did you get it working?

Reseting the gateway didnt fix it for me.

Hi, actually I’ve reset my Tradfri Gateway like 10 times - at one period it looked like bricked - keeped flashing and could not get network address. Left it like this for few days and almost forgot about it. Then one morning I had ‘Configure Tradfri’ in Home Assistant and since then it is working fine. But really cannot reproduce how it got fixed…

Just in case someone else is having issues with the discovery-based Tradfri setup, I managed to correct the problem as follows:

  1. Log in to SSH
  2. Navigate to /config
  3. rm -rf .tradfri_psk.conf
  4. Re-add security key in web UI. -> Profit.

Why this works? In my case I had tried doing the setup once and it didn’t seem to work. I then realized I had the gateway on a dynamic DHCP lease, and added a fixed IP on my router. This changed the IP, and caused the psk file to get all goofed up.

Home Assistant 0.75.1
removing .tradfri_psk.conf results in having to re-enter key
error:-

2018-08-07 21:17:27 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall configurator.configure (c:8045f64fc1914c3591298f385d7f892c): configure_id=1724628560-1, fields=security_code=BunXugA5ZrTzv4Tv>
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1115, in _event_to_service_call
await service_handler.func(service_call)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/configurator.py”, line 224, in async_handle_service_call
call.data.get(ATTR_FIELDS, {}))
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/tradfri.py”, line 68, in configuration_callback
key = await api_factory.generate_psk(security_code)
File “/srv/homeassistant/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py”, line 196, in generate_psk
self._psk = yield from self.request(command)
File “/srv/homeassistant/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py”, line 152, in request
result = yield from self._execute(api_commands)
File “/srv/homeassistant/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py”, line 144, in _execute
api_command.result = _process_output(res, parse_json)
File “/srv/homeassistant/lib/python3.5/site-packages/pytradfri/command.py”, line 68, in result
self._result = self._process_result(value)
File “/srv/homeassistant/lib/python3.5/site-packages/pytradfri/gateway.py”, line 29, in process_result
return result[ATTR_PSK]
TypeError: ‘NoneType’ object is not subscriptable

Solved [maybe]
see _https://www.home-assistant.io/blog/2017/11/04/release-57/
my Tradfri Gateway has not updated, is version 1.0.0008 whereas the latest version is 1.4.15 (release v. 1.6.0)
so, maybe the new api calls are not in the older version(s) of the firmware, which would explain why the gateway won’t connect?
next problem - update the gateway, despite the version being very old, check for updates says up to date!

Update of Tradfri gateway solved.
From phone app - clear all settings, that reboots the gateway.
Reset gateway (pin in top)
It updated (took about 10 mins)
then reinstall all devices.
Now up-to-date
And the configuration from the main screen of HA now works.