HEOS: Mark players unavailable on controller disconnection#4068
HEOS: Mark players unavailable on controller disconnection#4068MarvinSchenkel wants to merge 1 commit into
Conversation
Subscribe to pyheos add_on_disconnected to propagate the availability change to MA players when the HEOS controller loses its connection (e.g. after a full AVR power cycle). Without this, players stayed visible as available in MA until a restart even though pyheos had already marked them unavailable internally. Fixes: music-assistant/support#5565 https://claude.ai/code/session_01RCxBC9UUetxpuHWMZv8vF1
|
@Tommatheussen my issues agent came up with this fix, could you sanity check this please? |
There was a problem hiding this comment.
Pull request overview
This PR improves the HEOS player provider’s connection lifecycle handling by reacting to pyheos controller disconnection events so Music Assistant immediately reflects HEOS players as unavailable after an AVR power-cycle/disconnect.
Changes:
- Subscribes to pyheos
add_on_disconnectedduring controller setup. - Adds a disconnection callback that refreshes each HEOS player’s device info and pushes an updated state so availability is propagated promptly.
|
LGTM, I can test on phyiscal devices later today if you want |
|
Would be great since I do not have any :) |
|
@MarvinSchenkel technically, the changes are correct, the problem is a bit deeper though. pyheos doesn't invoke the _on_disconnected all that often, seems to happen mainly when we programmatically disconnect (so a known disconnection), or when the device gets rebooted. Basically when the connection really gets cleanly closed. |
What does this implement/fix?
When a HEOS-connected AVR is fully power-cycled, pyheos internally marks the device as unavailable, but Music Assistant was not listening for the disconnection event. This left the player showing as available in MA while the underlying transport connection was gone, causing every playback command to fail with
CommandError: Not connected to deviceuntil the MA addon was restarted.The fix subscribes to pyheos's
add_on_disconnectedcallback in_setup_controllers. When the callback fires,set_device_info()is called on each registered HEOS player, which reads the (now-False)availableattribute from the pyheos device object and propagates it viaupdate_state(). Recovery on reconnection was already handled correctly: pyheos firesEVENT_PLAYERS_CHANGEDwith aPlayerUpdateResultafter reloading players, which triggers the existing_handle_controller_event→discover_players()path.Related issue (if applicable):
Types of changes
bugfixChecklist
pre-commit run --all-filespasses.pytestpasses, and tests have been added/updated undertests/where applicable.music-assistant/modelsis linked.music-assistant/frontendis linked.Generated by Claude Code