-
-
Notifications
You must be signed in to change notification settings - Fork 36.3k
Fix Sonos speaker async_offline assertion failure #158764
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
Fix Sonos speaker async_offline assertion failure #158764
Conversation
|
Hey there @jjlawren, @PeteRager, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
8fff783 to
45ae553
Compare
PeteRager
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests should not access internals
0fbc440 to
f601acd
Compare
Handle the case where async_offline() is called before async_subscribe() has been invoked, which would leave _subscription_lock as None. This can happen during shutdown when a speaker was discovered but no activity was detected yet. Instead of asserting, create the lock if it doesn't exist, matching the existing pattern in async_subscribe().
Tests the fix for the AssertionError when async_offline() is called on a speaker where _subscription_lock is None (e.g., when a speaker is discovered but no activity was detected before shutdown).
f601acd to
5a464bc
Compare
Ensure all background tasks complete before checking results in the async_offline_without_subscription_lock test.
Patching async_setup ensures the subscription lock is never created, since async_subscribe (which creates the lock) is called from async_setup.
Instead of patching the integration, configure the SoCo mock's play_mode property to raise SoCoException. This causes setup() to fail early (before scheduling async_setup), leaving the speaker in discovered without _subscription_lock being created.
PeteRager
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Handle the case where async_offline() is called before async_subscribe() has been invoked, which would leave _subscription_lock as None. This can happen during shutdown when a speaker was discovered but no activity was detected yet. Instead of asserting, create the lock if it doesn't exist, matching the existing pattern in async_subscribe().
Failed in: https://github.com/home-assistant/core/actions/runs/20151776328/job/57846433236
Breaking change
Proposed change
Root cause: In SonosSpeaker:
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: