def new_service_found(service, info): """Handle a new service if one is found.""" if service in ignored_platforms: logger.info("Ignoring service: %s %s", service, info) return comp_plat = SERVICE_HANDLERS.get(service) # We do not know how to handle this service. if not comp_plat: return discovery_hash = json.dumps([service, info], sort_keys=True) if discovery_hash in already_discovered: return already_discovered.add(discovery_hash) logger.info("Found new service: %s %s", service, info) component, platform = comp_plat if platform is None: yield from async_discover(hass, service, info, component, config) else: yield from async_load_platform( hass, component, platform, info, config)
def new_service_found(service, info): """Called when a new service is found.""" if service in ignored_platforms: logger.info("Ignoring service: %s %s", service, info) return comp_plat = SERVICE_HANDLERS.get(service) # We do not know how to handle this service. if not comp_plat: return discovery_hash = json.dumps([service, info], sort_keys=True) if discovery_hash in already_discovered: return already_discovered.add(discovery_hash) logger.info("Found new service: %s %s", service, info) component, platform = comp_plat if platform is None: yield from async_discover(hass, service, info, component, config) else: yield from async_load_platform( hass, component, platform, info, config)
def new_service_found(service, info): """Called when a new service is found.""" if service in ignored_platforms: logger.info("Ignoring service: %s %s", service, info) return logger.info("Found new service: %s %s", service, info) comp_plat = SERVICE_HANDLERS.get(service) # We do not know how to handle this service. if not comp_plat: return component, platform = comp_plat if platform is None: yield from async_discover(hass, service, info, component, config) else: yield from async_load_platform(hass, component, platform, info, config)
def test_discover_forbids_config(): """Test you cannot setup config component with load_platform.""" with pytest.raises(HomeAssistantError): yield from discovery.async_discover(None, None, None, 'config')