Revert "Cast automatically drop connection (#12635)" (#13094)

This reverts commit e14893416f.
pull/13100/merge
Otto Winter 2018-03-11 20:42:58 +01:00 committed by Paulus Schoutsen
parent dff4f6ce48
commit 1dc5fa145f
2 changed files with 4 additions and 7 deletions

View File

@ -7,7 +7,6 @@ https://home-assistant.io/components/media_player.cast/
# pylint: disable=import-error # pylint: disable=import-error
import logging import logging
import threading import threading
import functools
import voluptuous as vol import voluptuous as vol
@ -35,7 +34,6 @@ CONF_IGNORE_CEC = 'ignore_cec'
CAST_SPLASH = 'https://home-assistant.io/images/cast/splash.png' CAST_SPLASH = 'https://home-assistant.io/images/cast/splash.png'
DEFAULT_PORT = 8009 DEFAULT_PORT = 8009
SOCKET_CLIENT_RETRIES = 10
SUPPORT_CAST = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \ SUPPORT_CAST = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PREVIOUS_TRACK | \ SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PREVIOUS_TRACK | \
@ -78,7 +76,7 @@ def _setup_internal_discovery(hass: HomeAssistantType) -> None:
try: try:
# pylint: disable=protected-access # pylint: disable=protected-access
chromecast = pychromecast._get_chromecast_from_host( chromecast = pychromecast._get_chromecast_from_host(
mdns, blocking=True, tries=SOCKET_CLIENT_RETRIES) mdns, blocking=True)
except pychromecast.ChromecastConnectionError: except pychromecast.ChromecastConnectionError:
_LOGGER.debug("Can't set up cast with mDNS info %s. " _LOGGER.debug("Can't set up cast with mDNS info %s. "
"Assuming it's not a Chromecast", mdns) "Assuming it's not a Chromecast", mdns)
@ -183,9 +181,8 @@ async def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
else: else:
# Manually add a "normal" Chromecast, we can do that without discovery. # Manually add a "normal" Chromecast, we can do that without discovery.
try: try:
func = functools.partial(pychromecast.Chromecast, *want_host, chromecast = await hass.async_add_job(
tries=SOCKET_CLIENT_RETRIES) pychromecast.Chromecast, *want_host)
chromecast = await hass.async_add_job(func)
except pychromecast.ChromecastConnectionError as err: except pychromecast.ChromecastConnectionError as err:
_LOGGER.warning("Can't set up chromecast on %s: %s", _LOGGER.warning("Can't set up chromecast on %s: %s",
want_host[0], err) want_host[0], err)

View File

@ -123,7 +123,7 @@ def test_internal_discovery_callback_only_generates_once(hass):
return_value=chromecast) as gen_chromecast: return_value=chromecast) as gen_chromecast:
discover_cast('the-service', chromecast) discover_cast('the-service', chromecast)
mdns = (chromecast.host, chromecast.port, chromecast.uuid, None, None) mdns = (chromecast.host, chromecast.port, chromecast.uuid, None, None)
gen_chromecast.assert_called_once_with(mdns, blocking=True, tries=10) gen_chromecast.assert_called_once_with(mdns, blocking=True)
discover_cast('the-service', chromecast) discover_cast('the-service', chromecast)
gen_chromecast.reset_mock() gen_chromecast.reset_mock()