diff --git a/homeassistant/components/sonos/media_player.py b/homeassistant/components/sonos/media_player.py index 681a5f1c9e2..e30dff2edc5 100644 --- a/homeassistant/components/sonos/media_player.py +++ b/homeassistant/components/sonos/media_player.py @@ -77,6 +77,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): hass.data[DATA_SONOS] = SonosData(hass) config = hass.data[SONOS_DOMAIN].get('media_player', {}) + _LOGGER.debug("async_setup_entry, config=%s", config) advertise_addr = config.get(CONF_ADVERTISE_ADDR) if advertise_addr: @@ -89,35 +90,43 @@ async def async_setup_entry(hass, config_entry, async_add_entities): def _discovered_player(soco): """Handle a (re)discovered player.""" try: + _LOGGER.debug("_discovered_player, soco=%s", soco) entity = _get_entity_from_soco_uid(hass, soco.uid) if not entity: + _LOGGER.debug("adding new entity") hass.add_job(async_add_entities, [SonosEntity(soco)]) else: + _LOGGER.debug("seen %s", entity) hass.add_job(entity.async_seen()) - except SoCoException: - pass + except SoCoException as ex: + _LOGGER.debug("SoCoException, ex=%s") if hosts: for host in hosts: try: + _LOGGER.debug("testing %s", host) player = pysonos.SoCo(socket.gethostbyname(host)) if player.is_visible: # Make sure that the player is available _ = player.volume _discovered_player(player) - except (OSError, SoCoException): + except (OSError, SoCoException) as ex: + _LOGGER.debug("exception %s", ex) if now is None: _LOGGER.warning("Failed to initialize '%s'", host) + _LOGGER.debug("tested all hosts") hass.helpers.event.call_later(DISCOVERY_INTERVAL, _discovery) else: + _LOGGER.debug("starting discovery thread") pysonos.discover_thread( _discovered_player, interval=DISCOVERY_INTERVAL, interface_addr=config.get(CONF_INTERFACE_ADDR)) + _LOGGER.debug("adding discovery job") hass.async_add_executor_job(_discovery) async def async_service_handle(service, data):