home-assistant-libs / pytradfri

IKEA Trådfri/Tradfri API. Control and observe your lights from Python. Examples available. On pypi. Sans-io.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pytradfri stopped working after latest gateway update

peltsippi opened this issue · comments

Mobile app requested to re-authenticate with gateway and homeassistant stopped working with the gateway completely.

Where are you using pytradfri (eg stand-alone, Home Assistant etc)

Both homeassistant version and standalone fails. Homeassistant with unknown error and standalone log below

Version of pytradfri

7.0.6

Backend used (aiocoap, libcoap)

libcoap (I think)

Expected behaviour

Gain access to gateway and control lights

Actual behaviour

python3 -i -m pytradfri 192.168.1 .100
DEBUG:pytradfri.util:JSON file not found: tradfri_standalone_psk.conf
Please provide the 'Security Code' on the back of your Tradfri gateway: ****************
DEBUG:pytradfri.util:JSON file not found: tradfri_standalone_psk.conf
DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.100 post ['15011', '9063']: {'9090': 'e4486b327ff24ed6b29adb01398b2804'}
DEBUG:pytradfri.api.libcoap_api:Received:
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.8/site-packages/pytradfri/main.py", l ine 50, in
identity = conf[args.host].get("identity")
KeyError: '192.168.1.100'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/srv/homeassistant/lib/python3.8/site-packages/pytradfri/main.py", l ine 58, in
psk = api_factory.generate_psk(args.key)
File "/srv/homeassistant/lib/python3.8/site-packages/pytradfri/api/libcoap_api .py", line 167, in generate_psk
self._psk = self.request(Gateway().generate_psk(existing_psk_id))
File "/srv/homeassistant/lib/python3.8/site-packages/pytradfri/api/libcoap_api .py", line 94, in request
return self._execute(api_commands, timeout=timeout)
File "/srv/homeassistant/lib/python3.8/site-packages/pytradfri/api/libcoap_api .py", line 88, in _execute
api_command.result = _process_output(return_value, parse_json)
File "/srv/homeassistant/lib/python3.8/site-packages/pytradfri/command.py", li ne 77, in result
self._result = self._process_result(value)
File "/srv/homeassistant/lib/python3.8/site-packages/pytradfri/gateway.py", li ne 43, in process_result
return result[ATTR_PSK]
TypeError: 'NoneType' object is not subscriptable

That test was inside homeassistant venv, just installed outside venv to other user and still same end result and error message.

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Still valid, does not work

commented

I'm unable to reproduce this with latest Gateway firmware (1.13.25).
However, someone has had similar problems (without solution) a few years ago: #131 (comment) , so it might be something else causing the issue than the new firmware.

My gateway FW is actually 1.1.0015 and home smart app says it is up to date. So this might be some strange error somewhere else.

commented

My gateway FW is actually 1.1.0015 and home smart app says it is up to date. So this might be some strange error somewhere else.

Actually that FW version may have had some problems, there seems to be a few Reddit discussions about Gateway being stuck on that version (for example https://www.reddit.com/r/tradfri/comments/7v15y1/gateway_will_not_update_firmware/).

Connecting Gateway directly to the router (instead of switch etc.) or to different network seems to have fixed that issue for some.

Thanks, some random combination of resetting gateway and/or switching between three different networks did the trick. Got updates applied and now all works just fine again!