Skip to content
Snippets Groups Projects
Commit 308b7fb3 authored by Jason Hu's avatar Jason Hu Committed by Paulus Schoutsen
Browse files

Add retry limit for chromecast connection (#16471)

parent 4efe8632
No related branches found
No related tags found
No related merge requests found
......@@ -61,6 +61,10 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.All(cv.ensure_list, [cv.string]),
})
CONNECTION_RETRY = 3
CONNECTION_RETRY_WAIT = 2
CONNECTION_TIMEOUT = 10
@attr.s(slots=True, frozen=True)
class ChromecastInfo:
......@@ -368,15 +372,13 @@ class CastDevice(MediaPlayerDevice):
return
await self._async_disconnect()
# Failed connection will unfortunately never raise an exception, it
# will instead just try connecting indefinitely.
# 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)
self._chromecast = chromecast
self._status_listener = CastStatusListener(self, chromecast)
# Initialise connection status as connected because we can only
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment