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
74.06k stars 31.08k forks source link

Onkyo integration fails to connect and then fails to sleep after upgrade to 2024.7 #121882

Open bakerkj opened 4 months ago

bakerkj commented 4 months ago

The problem

The Onkyo integration is no longer able to connect to my Pioneer receiver in 2024.7. It was able to do so in 2024.6. The receiver is on, pingable, and unchanged. I am suspicious of the new Onkyo driver implementation implemented and merged into 2024.7 here (https://github.com/home-assistant/core/commit/a4ba346dfc1308f8ab961ed151a7865958e945f4).

This is the first error:

    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.9.158', 60128)

In the process of handling that failed exception, it subsequently produces an additional exception:

    await asyncio.sleep(interval, loop=self._loop)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: sleep() got an unexpected keyword argument 'loop'

What version of Home Assistant Core has the issue?

core-2024.7.2

What was the last working version of Home Assistant Core?

core-2024.6

What type of installation are you running?

Home Assistant OS

Integration causing the issue

onkyo

Link to integration documentation on our website

https://www.home-assistant.io/integrations/onkyo/

Diagnostics information

No response

Example YAML snippet

media_player:
  - platform: onkyo
    host: host.domain.org
    name: Receiver

Anything in the logs that might be useful for us?

2024-07-12 19:47:32.148 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up onkyo platform for media_player
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyeiscp/connection.py", line 350, in _reconnect
    await self._loop.create_connection(
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1122, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1104, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1007, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.9.158', 60128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/usr/src/homeassistant/homeassistant/components/onkyo/media_player.py", line 229, in async_setup_platform
    receiver = await pyeiscp.Connection.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyeiscp/connection.py", line 188, in create
    await conn._reconnect()
  File "/usr/local/lib/python3.12/site-packages/pyeiscp/connection.py", line 369, in _reconnect
    await asyncio.sleep(interval, loop=self._loop)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: sleep() got an unexpected keyword argument 'loop'

Additional information

No response

zelezni commented 1 month ago

May I ask somebody for more detailed instructions on how to setup legacy version, please? I installed it through HACS, expecting that I will be able to configure it in devices. But nothing changed. Sure, I restarted Home Assistant. There is still official version and it still doesn't work.

Thanks!

Jim-Noble commented 2 weeks ago

The change will not be reverted.

I am not sure it is that common. I would assume a typical person would just turn it off using the remote, which just puts it in stand-by mode, and not yank it out of the power completely. In my testing the power draw in stand-by is negligible. But if that is what you want to do, I am not here to convince you otherwise, it is a bug and it needs to be fixed.

The PR to the upstream library was already submitted, there is not much more I can do for now.

My TX-NR807 takes 75W in standby. Needless to say, when not it use it's unpowered...

(Edited to add: it seems I'm not alone in this situation: https://www.avforums.com/threads/onkyo-tx-sr607-standby-power-consumption.1066887/ )

arturpragacz commented 2 weeks ago

@Jim-Noble Yes, in that case I understand, but to be fair that is a really old receiver. I'm not actually sure whether we even support such old equipment in this integration. Does it actually work at all?

Jim-Noble commented 2 weeks ago

@Jim-Noble Yes, in that case I understand, but to be fair that is a really old receiver. I'm not actually sure whether we even support such old equipment in this integration. Does it actually work at all?

Yep, was working perfectly well (with HA) before (thanks!) :-)

It's a bit long in the tooth, but then so am I ;-)

arturpragacz commented 2 weeks ago

But does it work now? We did change the library and the way it is used in the meantime, so if it doesn't work at all now, then I'm afraid it is not supported.

This issue is only about the problem with reconnects. Other than that the receivers should work correctly.

Jim-Noble commented 2 weeks ago

But does it work now? We did change the library and the way it is used in the meantime, so if it doesn't work at all now, then I'm afraid it is not supported.

This issue is only about the problem with reconnects. Other than that the receivers should work correctly.

It started failing to connect with the update to 2024.11.1 (I skipped .0) I've switched to the onkyo-legacy repo via HACS.

Swimmer71 commented 2 weeks ago

Same problem here with my TX-NR616 (I know, also very old :-)) and also don't want to use network standby. But I found out, reloading the entity media_player.tx_nr616 reconnects the entity to the receiver. So I could make an automation whenever my router changes the state "home" to "not_home" and then start the reload. Unforunately (or luckily) I have a fritzbox with Firmware 8, which also broke the Fritzbox Tools integration, bad time... :-)

action: homeassistant.reload_config_entry target: entity_id: media_player.tx_nr616

Sorry, formatting does not work: Zwischenablage_11-12-2024_01

darek203 commented 2 weeks ago

I have exactly the same problem with my Onkyo 636 :-( and trying to use action as you have suggested above but it throws following error: There were no matching config entries to reload

@Swimmer71 how did you manage to cope with that?

Same problem here with my TX-NR616 (I know, also very old :-)) and also don't want to use network standby. But I found out, reloading the entity media_player.tx_nr616 reconnects the entity to the receiver. So I could make an automation whenever my router changes the state "home" to "not_home" and then start the reload. Unforunately (or luckily) I have a fritzbox with Firmware 8, which also broke the Fritzbox Tools integration, bad time... :-)

action: homeassistant.reload_config_entry target: entity_id: media_player.tx_nr616

Sorry, formatting does not work: Zwischenablage_11-12-2024_01

Swimmer71 commented 2 weeks ago

I guess, you changed the entity_id to your name, right? First I also tried to use the config_id which you can find in the file core.config_entries in folder config/.storage. then I found out it works for me only with entity_id which is easier to remember

Swimmer71 commented 2 weeks ago

Sorry, I ment entry_id (not config_id), but as mentioned, it works for me also with entity_id.