Skip to content

Await the controller callback in LinkPlayPlayer.update_status - #136

Open
ccristal wants to merge 1 commit into
velbus:mainfrom
ccristal:fix/await-controller-callback
Open

ccristal wants to merge 1 commit into
velbus:mainfrom
ccristal:fix/await-controller-callback

Conversation

@ccristal

Copy link
Copy Markdown

Fixes #135

Problem

LinkPlayPlayer.update_status() calls self.bridge.device.controller() when a player moves into or out of follower mode. That callback comes from LinkPlayController.get_bridge_callback() and is async, so calling it without await only creates a coroutine object. discover_multirooms() never runs, and Python logs:

RuntimeWarning: coroutine 'LinkPlayController.get_bridge_callback.<locals>.callback' was never awaited

In Home Assistant this shows up as group_members not updating after a join until a linkplay config entry is reloaded.

Changes

  • bridge.py: await self.bridge.device.controller(). update_status() is already async, so no other changes are needed.
  • bridge.py: annotate LinkPlayDevice.controller and set_callback() as Callable[[], Awaitable[None]], matching what the controller actually passes.
  • tests/linkplay/test_bridge.py: the three update_status controller tests used a sync Mock(), which worked whether or not the call was awaited and so hid the bug. They now use AsyncMock() with assert_awaited_once() / assert_not_awaited().

Testing

  • With the old bridge.py, the two "triggers controller" tests fail as expected. With the fix, the full suite passes: 290 passed, 1 skipped.
  • The controller tests also pass with -W error::RuntimeWarning.
  • mypy src reports the same result before and after: one existing error, missing stubs for an import in utils.py.
  • I couldn't run ruff in my environment. The only lint rule enabled is I; the import line stays sorted, and the longest changed line is 78 characters.

🤖 Generated with Claude Code

The callback set by LinkPlayController.get_bridge_callback() is async, but
update_status() called it without awaiting, so discover_multirooms() never
ran when a player moved into or out of follower mode ("coroutine ... was
never awaited"). Await it and annotate the callback as returning an
Awaitable. The tests mocked it with a sync Mock, which hid the bug; use
AsyncMock and assert it is awaited.

Fixes velbus#135

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Controller callback in update_status() is never awaited, so multiroom changes aren't picked up

2 participants