mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Add retry limit for chromecast connection (#16471)
This commit is contained in:
parent
4efe86327d
commit
308b7fb385
@ -61,6 +61,10 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||||||
vol.All(cv.ensure_list, [cv.string]),
|
vol.All(cv.ensure_list, [cv.string]),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
CONNECTION_RETRY = 3
|
||||||
|
CONNECTION_RETRY_WAIT = 2
|
||||||
|
CONNECTION_TIMEOUT = 10
|
||||||
|
|
||||||
|
|
||||||
@attr.s(slots=True, frozen=True)
|
@attr.s(slots=True, frozen=True)
|
||||||
class ChromecastInfo:
|
class ChromecastInfo:
|
||||||
@ -368,15 +372,13 @@ class CastDevice(MediaPlayerDevice):
|
|||||||
return
|
return
|
||||||
await self._async_disconnect()
|
await self._async_disconnect()
|
||||||
|
|
||||||
# Failed connection will unfortunately never raise an exception, it
|
|
||||||
# will instead just try connecting indefinitely.
|
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
_LOGGER.debug("Connecting to cast device %s", cast_info)
|
_LOGGER.debug("Connecting to cast device %s", cast_info)
|
||||||
chromecast = await self.hass.async_add_job(
|
chromecast = await self.hass.async_add_job(
|
||||||
pychromecast._get_chromecast_from_host, (
|
pychromecast._get_chromecast_from_host, (
|
||||||
cast_info.host, cast_info.port, cast_info.uuid,
|
cast_info.host, cast_info.port, cast_info.uuid,
|
||||||
cast_info.model_name, cast_info.friendly_name
|
cast_info.model_name, cast_info.friendly_name
|
||||||
))
|
), CONNECTION_RETRY, CONNECTION_RETRY_WAIT, CONNECTION_TIMEOUT)
|
||||||
self._chromecast = chromecast
|
self._chromecast = chromecast
|
||||||
self._status_listener = CastStatusListener(self, chromecast)
|
self._status_listener = CastStatusListener(self, chromecast)
|
||||||
# Initialise connection status as connected because we can only
|
# Initialise connection status as connected because we can only
|
||||||
|
Loading…
x
Reference in New Issue
Block a user