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

Add retry limit for chromecast connection #16471

Merged
merged 1 commit into from
Sep 12, 2018

Conversation

awarecan
Copy link
Contributor

@awarecan awarecan commented Sep 7, 2018

Description:

Connect to chromecast fail will block whole HA startup

_get_chromecast_from_host method accept tries, retry_wait, timeout and blocking parameters. But above code doesn't provided any one of them. timeout default is 30s, and tries default is infinite.

I don't have chromecast, need someone help to test this PR

Related issue (if applicable): fixes #14956

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

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

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

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 Sep 12, 2018

Tried it locally and it works.

@balloob balloob added this to the 0.78.0 milestone Sep 12, 2018
@balloob balloob merged commit 308b7fb into home-assistant:dev Sep 12, 2018
@ghost ghost removed the in progress label Sep 12, 2018
@balloob balloob mentioned this pull request Sep 17, 2018
# pylint: disable=protected-access
_LOGGER.debug("Connecting to cast device %s", cast_info)
chromecast = await self.hass.async_add_job(
pychromecast._get_chromecast_from_host, (
cast_info.host, cast_info.port, cast_info.uuid,
cast_info.model_name, cast_info.friendly_name
))
), CONNECTION_RETRY, CONNECTION_RETRY_WAIT, CONNECTION_TIMEOUT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw this PR while working through my mailbox. Before a chromecast rewrite it was done like with your new code. However, the problem with this change is that if the retry limit is exceeded (for example by plugging the CC out for a while), hass will no longer attempt to reconnect.

Anyway, I guess the only way to get rid of all these CC issues is to make pychromecast a bit more async aware. Either by converting it to asyncio (lots of work, trust me I tried) or by making use of the blocking parameter.

awarecan added a commit to awarecan/home-assistant that referenced this pull request Sep 23, 2018
awarecan added a commit to awarecan/home-assistant that referenced this pull request Sep 23, 2018
@awarecan awarecan mentioned this pull request Sep 23, 2018
2 tasks
balloob pushed a commit that referenced this pull request Sep 23, 2018
* Revert changes of #16471, and fix the platform setup issue

* Fix unit test

* Fix

* Fix comment

* Fix test

* Address review comment

* Address review comment
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
@awarecan awarecan deleted the fix-chromecast-startup branch March 12, 2019 05:59
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.

Chromecast causing startup issues
4 participants