home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.27k stars 29.86k forks source link

Ikea Tradfri 58.1 aiocoap.error.RequestTimedOut #10847

Closed GMFalka closed 6 years ago

GMFalka commented 6 years ago

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version): 58.1

Python release (python3 --version): Python 3.5.2

Component/platform: Ikea Tradfri gateway/lights

Description of problem: After a few commands, the gateway doesnt respond. It still works from official phone app or by using the tradfri remote. HASS error logs says "aiocoap.error.RequestTimedOut".

Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

tradfri:
  host: 192.168.0.26
  allow_tradfri_groups: false
  1. Reboot Tradfri Gateway
  2. Homeassistant
  3. From frontend or automation try turning on or off the lights a few times. Time between the commands doesnt matter.

Traceback (if applicable):

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py", line 92, in _get_response
    r = yield from pr.response
  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/aiocoap/protocol.py", line 814, in _run_outer
    yield from cls._run(app_request, response, weak_observation, protocol, log, exchange_monitor_factory)
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/aiocoap/protocol.py", line 863, in _run
    blockresponse = yield from blockrequest.response
  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, 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.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py", line 149, in request
    result = yield from self._execute(api_commands)
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py", line 107, in _execute
    yield from self._observe(api_command)
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py", line 167, in _observe
    pr, r = yield from self._get_response(msg)
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/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())

Additional info: Theres also two more error spam in the log when the gateway stops responding.

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py", line 149, in request
    result = yield from self._execute(api_commands)
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py", line 139, in _execute
    _, res = yield from self._get_response(msg)
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py", line 92, in _get_response
    r = yield from pr.response
  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/aiocoap/protocol.py", line 814, in _run_outer
    yield from cls._run(app_request, response, weak_observation, protocol, log, exchange_monitor_factory)
  File "/home/falkaub/.homeassistant/deps/lib/python3.5/site-packages/aiocoap/protocol.py", line 863, in _run
    blockresponse = yield from blockrequest.response
  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
OSError: [Errno -1] Unknown error -1

and

Exception CancelledError() can not be represented as errno, setting -1.
GMFalka commented 6 years ago

strangly, when the error occurs, i cant turn on or off the lights from the HASS GUI, but automations works about 75%. Also i can still control the brightness of the lights, altho the GUI will not save slider position (it will snap back, just like the turn/off switch)

ybizeul commented 6 years ago

Tradfri is clearly broken.

Lots of these messages :

Dec 01 01:39:40 raspberrypi hass[26801]: 2017-12-01 01:39:40 INFO (MainThread) [coap] Retransmission, Message ID: 45465.
[...]
Dec 01 01:40:24 raspberrypi hass[26801]: 2017-12-01 01:40:24 ERROR (MainThread) [homeassistant.components.light] Setup of platform tradfri is taking longer than 60 seconds. Startup will proceed without waiting any longer.
[...]
Dec 01 01:40:57 raspberrypi hass[26801]: Traceback (most recent call last):
Dec 01 01:40:57 raspberrypi hass[26801]:   File "/srv/homeassistant/venv/lib/python3.5/site-packages/pytradfri/api/aiocoap_api.py", line 92, in _get_response
Dec 01 01:40:57 raspberrypi hass[26801]:     r = yield from pr.response
Dec 01 01:40:57 raspberrypi hass[26801]:   File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
Dec 01 01:40:57 raspberrypi hass[26801]:     yield self  # This tells Task to wait for completion.
Dec 01 01:40:57 raspberrypi hass[26801]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
Dec 01 01:40:57 raspberrypi hass[26801]:     future.result()
Dec 01 01:40:57 raspberrypi hass[26801]:   File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
Dec 01 01:40:57 raspberrypi hass[26801]:     raise self._exception
Dec 01 01:40:57 raspberrypi hass[26801]:   File "/srv/homeassistant/venv/lib/python3.5/site-packages/aiocoap/protocol.py", line 814, in _run_outer
Dec 01 01:40:57 raspberrypi hass[26801]:     yield from cls._run(app_request, response, weak_observation, protocol, log, exchange_monitor_factory)
Dec 01 01:40:57 raspberrypi hass[26801]:   File "/srv/homeassistant/venv/lib/python3.5/site-packages/aiocoap/protocol.py", line 863, in _run
Dec 01 01:40:57 raspberrypi hass[26801]:     blockresponse = yield from blockrequest.response
Dec 01 01:40:57 raspberrypi hass[26801]:   File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
Dec 01 01:40:57 raspberrypi hass[26801]:     yield self  # This tells Task to wait for completion.
Dec 01 01:40:57 raspberrypi hass[26801]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
Dec 01 01:40:57 raspberrypi hass[26801]:     future.result()
Dec 01 01:40:57 raspberrypi hass[26801]:   File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
Dec 01 01:40:57 raspberrypi hass[26801]:     raise self._exception
Dec 01 01:40:57 raspberrypi hass[26801]: aiocoap.error.RequestTimedOut
(venv) homeassistant@raspberrypi:/srv/homeassistant$ pip freeze
aiocoap==0.3
aiohttp==2.3.2
astral==1.4
async-timeout==2.0.0
certifi==2017.11.5
chardet==3.0.4
colorlog==3.0.1
Cython==0.27.2
DTLSSocket==0.1.4
enum-compat==0.0.2
home-assistant-frontend==20171121.0
homeassistant==0.58.1
idna==2.6
Jinja2==2.10
MarkupSafe==1.0
multidict==3.3.2
netdisco==1.2.3
netifaces==0.10.6
PlexAPI==3.0.3
PyDispatcher==2.0.5
python-openzwave==0.4.0.35
pytradfri==4.0.1
pytz==2017.3
PyYAML==3.12
requests==2.18.4
six==1.11.0
SQLAlchemy==1.1.15
tinyDTLS==0.0.0
typing==3.6.2
urllib3==1.22
voluptuous==0.10.5
websocket-client==0.44.0
yarl==0.14.0
zeroconf==0.19.1
ferdydek commented 6 years ago

Does removing .tradfri_psk.conf file and re-configuring the component (restart HA) solve the issue?

GMFalka commented 6 years ago

Sadly, it doesn't!

ferdydek commented 6 years ago

I cant dig back to the threat I've seen it in, but (this also worked for me after the Tradfri firmware was upgraded) the issue may be with the authentication token being already "used" on the Tradfri GW, and to reset it you will need to reset the GW to factory settings and reconfigure all devices from scratch.

@ybizeul In my case the tradfri library is in higher version than yours, but I'm already on 0.59. Can you please check if you have pytradfri==4.1.0 now ?

ginkel commented 6 years ago

Deleting .tradfri_psk.conf and reconfiguring Tradfri helps until I toggle a light using Ikea's Tradfri app. From that moment on Home Assistant starts getting timeouts again.

GMFalka commented 6 years ago

Same here. Strange part is, that despite HASS spitting out errors every minutes and unable to manually control the lights from GUI, the automations (which triggered by PIRs) works about 70% of time.

GMFalka commented 6 years ago

I cut back on my lights automation commands "spam" to the tradfri gateway and in the past 3 days it works flawesly, without a hickup. BUT only the automations works! HASS gui says, last updated 3days ago and i cant controll the lights from there. Only from automation. Edit: The GUI is configured as properly as it could be. Sometimes the lights entity icon updates, other times the slider... maybe the light level. The GUI still says updated 1,2,3 days ago.

Brumhilde commented 6 years ago

Same issue here. Tradfri lights are working fine after HA restart until I use tradfri app or dimmer. After I have used the tradfri dimmer HA can toggle the state once but then it is stuck. Also it doesn't have to be the same light that I control from dimmer and HA. If I dim light A on/off with dimmer then light B state will also stop updating in HA.

GMFalka commented 6 years ago

Seems like they fixed it in 0.60 Thanks guys!!!