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

Improve chromecast disconnection logic #14190

Merged
merged 2 commits into from Apr 30, 2018
Merged

Conversation

OttoWinter
Copy link
Member

Description:

The latest cleanup to the cast platform introduced a weird bug where disconnecting from the old leader of a cast audio group was not handled correctly.

In particular, cast group leaders don't like accepting connections as long as there are open sockets to the old leader. In the old code, we would do a non-blocking disconnect and not join the socket client thread. So we tried connecting to the new leader before the old leader was disconnected. This prevented us from connecting to cast groups on every second leader change.

Apparently, async_will_remove_from_hass is not called on EVENT_HOMEASSISTANT_STOP. With the assumption that this seems to be intended (feels weird to me), I manually added a listener to the event bus.

If there's a 68.1 release, it might be good to maybe include this PR. It's not a huge code change and I spent the last few days testing this change.

Related issue (if applicable): fixes #13530

Example entry for configuration.yaml (if applicable):

media_player:
  - platform: cast

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@balloob
Copy link
Member

balloob commented Apr 30, 2018

I think that registering a HOME_ASSISTANT_STOP event listener, like you did, is a better approach than using the removed from hass hook. Because cleanup during runtime is different than cleanup during shutdown.

@balloob balloob merged commit 76c9c01 into home-assistant:dev Apr 30, 2018
balloob pushed a commit that referenced this pull request Apr 30, 2018
@balloob balloob mentioned this pull request Apr 30, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Sep 5, 2018
@OttoWinter OttoWinter deleted the cast-fix branch September 29, 2018 10:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cast groups unavailable
3 participants