How to use the pychromecast._get_chromecast_from_host function in PyChromecast

To help you get started, we’ve selected a few PyChromecast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fondberg / spotcast / custom_components / spotcast / __init__.py View on Github external
# HA below 0.113
            cast_info = next((x for x in known_devices if x.friendly_name == device_name), None)
        except:
            cast_info = next(
                (
                    known_devices[x]
                    for x in known_devices
                    if known_devices[x].friendly_name == device_name
                ),
                None,
            )

        _LOGGER.debug("cast info: %s", cast_info)

        if cast_info:
            return pychromecast._get_chromecast_from_host(
                (
                    cast_info.host,
                    cast_info.port,
                    cast_info.uuid,
                    cast_info.model_name,
                    cast_info.friendly_name,
                )
            )
        _LOGGER.error(
            "Could not find device %s from hass.data, falling back to pychromecast scan",
            device_name,
        )

        # Discover devices manually
        chromecasts = pychromecast.get_chromecasts()
        for _cast in chromecasts:
github home-assistant / home-assistant / homeassistant / components / cast / media_player.py View on Github external
_LOGGER.debug(
            "[%s %s (%s:%s)] Connecting to dynamic group by host %s",
            self.entity_id,
            self._cast_info.friendly_name,
            self._cast_info.host,
            self._cast_info.port,
            cast_info,
        )

        await self.async_del_dynamic_group()
        self._dynamic_group_cast_info = cast_info

        # pylint: disable=protected-access
        chromecast = await self.hass.async_add_executor_job(
            pychromecast._get_chromecast_from_host,
            (
                cast_info.host,
                cast_info.port,
                cast_info.uuid,
                cast_info.model_name,
                cast_info.friendly_name,
            ),
        )

        self._dynamic_group_cast = chromecast

        if CAST_MULTIZONE_MANAGER_KEY not in self.hass.data:
            self.hass.data[CAST_MULTIZONE_MANAGER_KEY] = MultizoneManager()

        mz_mgr = self.hass.data[CAST_MULTIZONE_MANAGER_KEY]
github home-assistant / home-assistant / homeassistant / components / cast / media_player.py View on Github external
# Only setup the chromecast once, added elements to services
            # will automatically be picked up.
            return

        # pylint: disable=protected-access
        if self.services is None:
            _LOGGER.debug(
                "[%s %s (%s:%s)] Connecting to cast device by host %s",
                self.entity_id,
                self._cast_info.friendly_name,
                self._cast_info.host,
                self._cast_info.port,
                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,
                ),
            )
        else:
            _LOGGER.debug(
                "[%s %s (%s:%s)] Connecting to cast device by service %s",
                self.entity_id,
                self._cast_info.friendly_name,
                self._cast_info.host,
                self._cast_info.port,
                self.services,