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

Russound_Rio reconnect after power cycle amp #124996

Closed
horbye opened this issue Aug 31, 2024 · 16 comments · Fixed by #126774
Closed

Russound_Rio reconnect after power cycle amp #124996

horbye opened this issue Aug 31, 2024 · 16 comments · Fixed by #126774

Comments

@horbye
Copy link

horbye commented Aug 31, 2024

The problem

After the amp has been turned off and later turned on again, HA has to be restarted or the integration has to be reloaded to reconnect the Russound_Rio entities.

What version of Home Assistant Core has the issue?

core-2024.8.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

russound_rio

Link to integration documentation on our website

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

Diagnostics information

home-assistant.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Due to standby power consumption of the MCA-C5 (nearly 20W), I keep it turned off by a smartswitch, when it is not in use.

@home-assistant
Copy link

Hey there @noahhusby, mind taking a look at this issue as it has been labeled with an integration (russound_rio) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of russound_rio can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign russound_rio Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


russound_rio documentation
russound_rio source
(message by IssueLinks)

@noahhusby
Copy link
Contributor

How much time are you giving the unit from power up to sending the first command?

@horbye
Copy link
Author

horbye commented Sep 4, 2024

That could be within a minute, it takes approx 30 seconds for it to boot up

@noahhusby
Copy link
Contributor

Have you given it up to 15 minutes to reconnect? It's supposed to be pretty quick, but there is a cycle that occurs 15 minutes that might force a reconnection.

The reconnection will never be instant, but I might be able to make that cycle a configuration option that you can lower for your use-case.

@horbye
Copy link
Author

horbye commented Sep 13, 2024

Turned it off last night, and 20ish hours later, I turned it on and let it run 30 minutes.
Nothing in the log about Russound for those 30 minutes.

These are the last logs from the integration:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiorussound/connection.py", line 147, in _ioloop
    response = net_future.result()
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 568, in readline
    line = await self.readuntil(sep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 660, in readuntil
    await self._wait_for_data('readuntil')
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 545, in _wait_for_data
    await self._waiter
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1003, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 113] Host is unreachable
2024-09-12 19:51:52.629 WARNING (MainThread) [homeassistant.components.russound_rio] Disconnected from controller at 192.168.16.250:9621
2024-09-12 19:51:52.633 DEBUG (MainThread) [aiorussound] Cancelling all tasks...
2024-09-12 19:51:52.633 WARNING (MainThread) [homeassistant.components.russound_rio] Disconnected from controller at 192.168.16.250:9621
2024-09-12 19:51:52.634 INFO (MainThread) [aiorussound] Retrying connection to Russound client in 5s
2024-09-12 19:51:57.635 INFO (MainThread) [aiorussound] Connecting to 192.168.16.250:9621

After that, nothing about russound_rio and only this error, which I amd not sure is related:

2024-09-13 08:59:08.040 WARNING (Thread-12 (_listen)) [homeconnect.sseclient] Exception while reading event: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/homeconnect/sseclient.py", line 82, in __next__
    next_chunk = next(self.resp_iterator)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

Sometimes the amp is left off for days and I noticed that reloading the interface does not work, HA has to be restarted

@iprowell
Copy link

I have the same issue. I have tried a number of things including re-starting the Russound integration when the amp is powered on. The only thing that seems to work reliably is to restart Home Assistant.

@noahhusby
Copy link
Contributor

@horbye So that error was from around the time that you powered the unit off? If you open the logs, do you continue to see "Connecting to 192.168.16.250:9621" consistently?

@horbye
Copy link
Author

horbye commented Sep 13, 2024

Amp was turned off 19:32, this is all that was logged before and after

2024-09-12 19:29:51.712 DEBUG (MainThread) [aiorussound] Cache store S[2].songname = WE PRAY / Coldplay, Little Simz, Burna Boy, Elyanna, TINI 2024-09-12 19:36:25.710 DEBUG (MainThread) [aiorussound] Sending keep alive to device 2024-09-12 19:36:25.710 DEBUG (MainThread) [aiorussound] Sending command 'VERSION' to Russound client 2024-09-12 19:51:52.620 ERROR (MainThread) [aiorussound] Unhandled exception in IO loop Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiorussound/connection.py", line 147, in _ioloop response = net_future.result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/streams.py", line 568, in readline line = await self.readuntil(sep) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/streams.py", line 660, in readuntil await self._wait_for_data('readuntil') File "/usr/local/lib/python3.12/asyncio/streams.py", line 545, in _wait_for_data await self._waiter File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1003, in _read_ready__data_received data = self._sock.recv(self.max_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [Errno 113] Host is unreachable 2024-09-12 19:51:52.629 WARNING (MainThread) [homeassistant.components.russound_rio] Disconnected from controller at 192.168.16.250:9621 2024-09-12 19:51:52.633 DEBUG (MainThread) [aiorussound] Cancelling all tasks... 2024-09-12 19:51:52.633 WARNING (MainThread) [homeassistant.components.russound_rio] Disconnected from controller at 192.168.16.250:9621 2024-09-12 19:51:52.634 INFO (MainThread) [aiorussound] Retrying connection to Russound client in 5s 2024-09-12 19:51:57.635 INFO (MainThread) [aiorussound] Connecting to 192.168.16.250:9621 2024-09-12 23:27:36.417 WARNING (MainThread) [custom_components.localtuya.common] [bfc...ds0] Disconnected - waiting for discovery broadcast

@horbye
Copy link
Author

horbye commented Sep 13, 2024

Between 19:51:57.635 and 23:27:36.417 nothing is logged

@noahhusby
Copy link
Contributor

Sorry for the delay, I've been rewriting the connection handler to be more resilient.

The issue is that OSError is not handled in the code causing the execution to end after a reconnection is attempted thus preventing the reconnection from succeeding. This behavior is being changed in a future version of the library and should resolve this issue.

I'll keep you posted on the status of the fix. Until then, I'll leave this issue open.

@horbye
Copy link
Author

horbye commented Sep 24, 2024

Thanks :)

@noahhusby
Copy link
Contributor

noahhusby commented Sep 25, 2024

The issue is resolved and will be included in the new release of Home Assistant 2024.10 (comes out next week Wed).

It takes roughly 1 minute (at most) to detect that the controller is no longer connected and to run the reconnect handler. From there, reconnect is properly attempted every 30 seconds.

The entire IO loop was rewritten and handles errors much better now. All errors will get logged and the reconnect handler will take over to try to re-establish connection

@noahhusby
Copy link
Contributor

@horbye The fix was released in the update today. Can you give it a try to confirm that it's functioning properly?

@iprowell
Copy link

iprowell commented Oct 3, 2024

I upgraded and it looks like the fixes are working. I was also having some issues with source switching which seem to be resolved. @noahhusby I really appreciate all your work. My Russound stuff is working way better in Home Assistant. THANKS!!!!!

@horbye
Copy link
Author

horbye commented Oct 11, 2024

Hi

I left the amp off for a few days and when I turned it on today, somthing went wrong, had to reconnect the rj45 cable in my switch, as not event eh russound app would connect, after reconnecting the cable, russound app was could connect, but not HA
Found this error in the log:

2024-10-10 17:18:47.137 ERROR (MainThread) [aiorussound] [Errno 113] Connect call failed ('192.168.16.250', 9621) Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiorussound/rio.py", line 158, in _connect_handler await self.connection_handler.connect() File "/usr/local/lib/python3.12/site-packages/aiorussound/connection.py", line 41, in connect reader, writer = await asyncio.open_connection(self.host, self.port) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/streams.py", line 48, in open_connection transport, _ = await 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}') OSError: [Errno 113] Connect call failed ('192.168.16.250', 9621) 2024-10-10 17:18:47.175 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry MCA-C5 for russound_rio Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/russound_rio/__init__.py", line 44, in async_setup_entry await client.connect() File "/usr/local/lib/python3.12/site-packages/aiorussound/rio.py", line 116, in connect return await self.connect_result ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiorussound/rio.py", line 158, in _connect_handler await self.connection_handler.connect() File "/usr/local/lib/python3.12/site-packages/aiorussound/connection.py", line 41, in connect reader, writer = await asyncio.open_connection(self.host, self.port) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/streams.py", line 48, in open_connection transport, _ = await 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}') OSError: [Errno 113] Connect call failed ('192.168.16.250', 9621) 2024-10-10 17:18:47.196 WARNING (MainThread) [homeassistant.components.russound_rio] Disconnected from device at 192.168.16.250

Besides that It was working nicely just after teh update, was happy to see that HA was able to reconnect, even though amp was turned off when HA was restarted also

@horbye
Copy link
Author

horbye commented Oct 11, 2024

This is from the Switch log, showing, I disconnected the cable 30 minutes after interface crashed

MCAC5-003D0E
 connected to 
Multimedia
 on 
Rack Switch Port 4
. Connection Info: Link Speed FE, 192.168.16.250. Today at 5:56 PM

@noahhusby Thanks for rebuilding the interface and looking into this.
I can't wait to see how the XSource in source mode will work in HA , suddenly having this system is a whole new experience

@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants