async def async_connect_to_chromecast(self): """Set the cast information and set up the chromecast object.""" _LOGGER.debug( "[%s %s] Connecting to cast device by service %s", "Dynamic group", self._cast_info.friendly_name, self.services, ) chromecast = await self.hass.async_add_executor_job( pychromecast.get_chromecast_from_cast_info, pychromecast.discovery.CastInfo( self.services, self._cast_info.uuid, self._cast_info.model_name, self._cast_info.friendly_name, None, None, ), ChromeCastZeroconf.get_zeroconf(), ) self._chromecast = chromecast if CAST_MULTIZONE_MANAGER_KEY not in self.hass.data: self.hass.data[CAST_MULTIZONE_MANAGER_KEY] = MultizoneManager() self.mz_mgr = self.hass.data[CAST_MULTIZONE_MANAGER_KEY] self._status_listener = CastStatusListener(self, chromecast, self.mz_mgr, True) self._chromecast.start()
async def async_connect_to_chromecast(self): """Set up the chromecast object.""" _LOGGER.debug( "[%s %s] Connecting to cast device by service %s", self.entity_id, self._cast_info.friendly_name, self._cast_info.cast_info.services, ) chromecast = await self.hass.async_add_executor_job( pychromecast.get_chromecast_from_cast_info, self._cast_info.cast_info, ChromeCastZeroconf.get_zeroconf(), ) self._chromecast = chromecast if CAST_MULTIZONE_MANAGER_KEY not in self.hass.data: self.hass.data[CAST_MULTIZONE_MANAGER_KEY] = MultizoneManager() self.mz_mgr = self.hass.data[CAST_MULTIZONE_MANAGER_KEY] self._status_listener = CastStatusListener(self, chromecast, self.mz_mgr) self._attr_available = False self.cast_status = chromecast.status self.media_status = chromecast.media_controller.status self._chromecast.start() self.async_write_ha_state()
async def async_set_dynamic_group(self, cast_info): """Set the cast information and set up the chromecast object.""" import pychromecast _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: from pychromecast.controllers.multizone import MultizoneManager self.hass.data[CAST_MULTIZONE_MANAGER_KEY] = MultizoneManager() mz_mgr = self.hass.data[CAST_MULTIZONE_MANAGER_KEY] self._dynamic_group_status_listener = DynamicGroupCastStatusListener( self, chromecast, mz_mgr) self._dynamic_group_available = False self.dynamic_group_media_status = chromecast.media_controller.status self._dynamic_group_cast.start() self.async_schedule_update_ha_state()
async def async_connect_to_chromecast(self): """Set the cast information and set up the chromecast object.""" _LOGGER.debug( "[%s %s] Connecting to cast device by service %s", "Dynamic group", self._cast_info.friendly_name, self._cast_info.cast_info.services, ) chromecast = await self.hass.async_add_executor_job( pychromecast.get_chromecast_from_cast_info, self._cast_info.cast_info, ChromeCastZeroconf.get_zeroconf(), ) chromecast.media_controller.app_id = CAST_APP_ID_HOMEASSISTANT_MEDIA self._chromecast = chromecast if CAST_MULTIZONE_MANAGER_KEY not in self.hass.data: self.hass.data[CAST_MULTIZONE_MANAGER_KEY] = MultizoneManager() self.mz_mgr = self.hass.data[CAST_MULTIZONE_MANAGER_KEY] self._status_listener = CastStatusListener(self, chromecast, self.mz_mgr, True) self._chromecast.start()
async def async_set_cast_info(self, cast_info): """Set the cast information and set up the chromecast object.""" self._cast_info = cast_info if self.services is not None: if cast_info.service not in self.services: _LOGGER.debug( "[%s %s (%s:%s)] Got new service: %s (%s)", self.entity_id, self._cast_info.friendly_name, self._cast_info.host, self._cast_info.port, cast_info.service, self.services, ) self.services.add(cast_info.service) if self._chromecast is not None: # Only setup the chromecast once, added elements to services # will automatically be picked up. return # pylint: disable=protected-access _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, ) chromecast = await self.hass.async_add_executor_job( pychromecast._get_chromecast_from_service, ( self.services, ChromeCastZeroconf.get_zeroconf(), cast_info.uuid, cast_info.model_name, cast_info.friendly_name, ), ) self._chromecast = chromecast if CAST_MULTIZONE_MANAGER_KEY not in self.hass.data: self.hass.data[CAST_MULTIZONE_MANAGER_KEY] = MultizoneManager() self.mz_mgr = self.hass.data[CAST_MULTIZONE_MANAGER_KEY] self._status_listener = CastStatusListener(self, chromecast, self.mz_mgr) self._available = False self.cast_status = chromecast.status self.media_status = chromecast.media_controller.status self._chromecast.start() self.async_write_ha_state()
async def _async_connect_to_chromecast(self): """Set up the chromecast object.""" _LOGGER.debug( "[%s %s] Connecting to cast device by service %s", self._name, self._cast_info.friendly_name, self._cast_info.cast_info.services, ) chromecast = await self.hass.async_add_executor_job( pychromecast.get_chromecast_from_cast_info, self._cast_info.cast_info, ChromeCastZeroconf.get_zeroconf(), ) self._chromecast = chromecast if CAST_MULTIZONE_MANAGER_KEY not in self.hass.data: self.hass.data[CAST_MULTIZONE_MANAGER_KEY] = MultizoneManager() self.mz_mgr = self.hass.data[CAST_MULTIZONE_MANAGER_KEY] self._status_listener = CastStatusListener(self, chromecast, self.mz_mgr, self._mz_only) self._chromecast.start()
def __init__(self, *args, **kwargs): """Initialize.""" self.mz_mgr = MultizoneManager() self._listener = None self._browser = None super().__init__(*args, **kwargs)