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 groups iteration TypeError with async #9778

Closed
infernix opened this issue Oct 9, 2017 · 5 comments · Fixed by #9875
Closed

Tradfri groups iteration TypeError with async #9778

infernix opened this issue Oct 9, 2017 · 5 comments · Fixed by #9875

Comments

@infernix
Copy link
Contributor

infernix commented Oct 9, 2017

Home Assistant release (hass --version):

0.55.0

Python release (python3 --version):

3.5.3

Component/platform:

Tradfri

Description of problem:

Upgrading to 0.55 with new async code results in TypeError on tradfri light init:

Oct 09 13:21:18 spirit hass[8169]: Traceback (most recent call last):
Oct 09 13:21:18 spirit hass[8169]:   File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
Oct 09 13:21:18 spirit hass[8169]:     SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
Oct 09 13:21:18 spirit hass[8169]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
Oct 09 13:21:18 spirit hass[8169]:     return fut.result()
Oct 09 13:21:18 spirit hass[8169]:   File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
Oct 09 13:21:18 spirit hass[8169]:     raise self._exception
Oct 09 13:21:18 spirit hass[8169]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
Oct 09 13:21:18 spirit hass[8169]:     result = coro.send(None)
Oct 09 13:21:18 spirit hass[8169]:   File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/light/tradfri.py", line 54, in async_setup_platform
Oct 09 13:21:18 spirit hass[8169]:     async_add_devices(TradfriGroup(group, api) for group in groups)
Oct 09 13:21:18 spirit hass[8169]: TypeError: 'Group' object is not iterable

Expected:

Group iteration should not result in a TypeError with the new async code introduced in 8db4641#diff-459bd622c1c30fd9674062a6d7b78a99

Theoretical workaround is to set allow_tradfri_groups: False, but cannot test due to new error:

Oct 09 13:34:36 spirit hass[8169]: 2017-10-09 13:34:36 ERROR (Dummy-46) [coap] Exception RuntimeError('Event loop is closed',) can not be represented as errno, setting -1.
Oct 09 13:34:36 spirit hass[8169]: 2017-10-09 13:34:36 WARNING (Dummy-46) [coap] Error received in UDP connection under DTLS: [Errno 9] Bad file descriptor

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

tradfri:
        host: 192.168.0.18
        api_key: !secret tradfri_api_key
  1. Install new aiocoap libs
  2. (Re)start HASS
  3. See error in log

Traceback (if applicable):
See above

Additional info:

@balloob
Copy link
Member

balloob commented Oct 10, 2017

CC @lwis

@lwis
Copy link
Member

lwis commented Oct 10, 2017

I think this will be solved by home-assistant-libs/pytradfri#61, once I find some time to polish it off.

I'm not sure what's causing your Bad file descriptor error.

@infernix
Copy link
Contributor Author

I spent a bit of time testing aiocoap standalone and reproduced the file descriptor error; link to aiocoap issue report above.

@lwis
Copy link
Member

lwis commented Oct 10, 2017

Can you try to test against https://pypi.python.org/pypi/DTLSSocket/0.1.3 instead?

@infernix
Copy link
Contributor Author

@lwis runtime error still persists on 0.1.3, e.g.

./aiocoap-client -v coaps://192.168.0.18:5684/.well-known/core
decrypt_verify(): found 24 bytes cleartext
decrypt_verify(): found 770 bytes cleartext
<//15001/65536>;ct=0;obs,<//15001/65540>;ct=0;obs,<//15001/65538>;ct=0;obs,<//15001/65537>;ct=0;obs,<//15001/65541>;ct=0;obs,<//15001/65539>;ct=0;obs,<//15001/65542>;ct=0;obs,<//15004/138319>;ct=0;obs,<//15005/138319>;ct=0;obs,<//15005/138319/200548>;ct=0;obs,<//15005/138319/201928>;ct=0;obs,<//15005/138319/210846>;ct=0;obs,<//15005/138319/196836>;ct=0;obs,<//15005/138319/228499>;ct=0;obs,<//15005/138319/207315>;ct=0;obs,<//15005/138319/228341>;ct=0;obs,<//15001>;ct=0;obs,<//15001/reset>;ct=0,<//status>;ct=0;obs,<//15005>;ct=0;obs,<//15004>;ct=0;obs,<//15004/add>;ct=0,<//15004/remove>;ct=0,<//15006>;ct=0;obs,<//15011/15012>;ct=0;obs,<//15011/9034>;ct=0,<//15011/9030>;ct=0,<//15011/9031>;ct=0,<//15011/9063>;ct=0,<//15011/9033>;ct=0,<//15010>;ct=0;obs
(No newline at end of message)
ERROR:asyncio:Task was destroyed but it is pending!
task: <Task pending coro=<DTLSClientConnection._run() running at /usr/src/aiocoap/aiocoap/transports/tinydtls.py:160> wait_for=<Future pending cb=[Task._wakeup()]>>
ERROR:coap:Exception RuntimeError('Event loop is closed',) can not be represented as errno, setting -1.
WARNING:coap:Error received in UDP connection under DTLS: [Errno 9] Bad file descriptor
Exception ignored in: <generator object DTLSClientConnection._run at 0x7f54889d1200>
Traceback (most recent call last):
  File "/usr/src/aiocoap/aiocoap/transports/tinydtls.py", line 180, in _run
  File "/usr/lib/python3.5/asyncio/selector_events.py", line 622, in close
  File "/usr/lib/python3.5/asyncio/base_events.py", line 572, in call_soon
  File "/usr/lib/python3.5/asyncio/base_events.py", line 357, in _check_closed
RuntimeError: Event loop is closed

and that seems to be the same error HASS is throwing

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

Successfully merging a pull request may close this issue.

3 participants