diff --git a/homeassistant/components/default_config/__init__.py b/homeassistant/components/default_config/__init__.py new file mode 100644 index 00000000000..3a99757b54b --- /dev/null +++ b/homeassistant/components/default_config/__init__.py @@ -0,0 +1,23 @@ +"""Component providing default configuration for new users.""" + +DOMAIN = 'default_config' +DEPENDENCIES = ( + 'automation', + 'cloud', + 'config', + 'conversation', + 'discovery', + 'frontend', + 'history', + 'logbook', + 'map', + 'script', + 'sun', + 'system_health', + 'updater', +) + + +async def async_setup(hass, config): + """Initialize default configuration.""" + return True diff --git a/homeassistant/components/discovery/__init__.py b/homeassistant/components/discovery/__init__.py index d8198ba3033..87b89ddb44c 100644 --- a/homeassistant/components/discovery/__init__.py +++ b/homeassistant/components/discovery/__init__.py @@ -105,7 +105,7 @@ CONF_IGNORE = 'ignore' CONF_ENABLE = 'enable' CONFIG_SCHEMA = vol.Schema({ - vol.Required(DOMAIN): vol.Schema({ + vol.Optional(DOMAIN): vol.Schema({ vol.Optional(CONF_IGNORE, default=[]): vol.All(cv.ensure_list, [ vol.In(list(CONFIG_ENTRY_HANDLERS) + list(SERVICE_HANDLERS))]), @@ -126,11 +126,15 @@ async def async_setup(hass, config): # Disable zeroconf logging, it spams logging.getLogger('zeroconf').setLevel(logging.CRITICAL) - # Platforms ignore by config - ignored_platforms = config[DOMAIN][CONF_IGNORE] + if DOMAIN in config: + # Platforms ignore by config + ignored_platforms = config[DOMAIN][CONF_IGNORE] - # Optional platforms enabled by config - enabled_platforms = config[DOMAIN][CONF_ENABLE] + # Optional platforms enabled by config + enabled_platforms = config[DOMAIN][CONF_ENABLE] + else: + ignored_platforms = [] + enabled_platforms = [] async def new_service_found(service, info): """Handle a new service if one is found.""" diff --git a/homeassistant/components/script/__init__.py b/homeassistant/components/script/__init__.py index 15df6907468..e337a2ec251 100644 --- a/homeassistant/components/script/__init__.py +++ b/homeassistant/components/script/__init__.py @@ -124,7 +124,7 @@ async def _async_process_config(hass, config, component): scripts = [] - for object_id, cfg in config[DOMAIN].items(): + for object_id, cfg in config.get(DOMAIN, {}).items(): alias = cfg.get(CONF_ALIAS, object_id) script = ScriptEntity(hass, object_id, alias, cfg[CONF_SEQUENCE]) scripts.append(script) diff --git a/homeassistant/config.py b/homeassistant/config.py index 5dbf226ca25..3310cd3e160 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -65,49 +65,16 @@ DEFAULT_CORE_CONFIG = ( (CONF_CUSTOMIZE, '!include customize.yaml', None, 'Customization file'), ) # type: Tuple[Tuple[str, Any, Any, Optional[str]], ...] DEFAULT_CONFIG = """ -# Show links to resources in log and frontend +# Configure a default setup of Home Assistant (frontend, api, etc) +default_config: + +# Show the introduction message on startup. introduction: -# Enables the frontend -frontend: - -# Enables configuration UI -config: - # Uncomment this if you are using SSL/TLS, running in Docker container, etc. # http: # base_url: example.duckdns.org:8123 -# Checks for available updates -# Note: This component will send some information about your system to -# the developers to assist with development of Home Assistant. -# For more information, please see: -# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/ -updater: - # Optional, allows Home Assistant developers to focus on popular components. - # include_used_components: true - -# Discover some devices automatically -discovery: - -# Allows you to issue voice commands from the frontend in enabled browsers -conversation: - -# Enables support for tracking state changes over time -history: - -# View all events in a logbook -logbook: - -# Enables a map showing the location of tracked devices -map: - -# Track the sun -sun: - -# Allow diagnosing system problems -system_health: - # Sensors sensor: # Weather prediction @@ -117,9 +84,6 @@ sensor: tts: - platform: google -# Cloud -cloud: - group: !include groups.yaml automation: !include automations.yaml script: !include scripts.yaml diff --git a/homeassistant/setup.py b/homeassistant/setup.py index 33c5d5311b1..29c8e22d45d 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -63,7 +63,7 @@ async def _async_process_dependencies( blacklisted = [dep for dep in dependencies if dep in loader.DEPENDENCY_BLACKLIST] - if blacklisted: + if blacklisted and name != 'default_config': _LOGGER.error("Unable to set up dependencies of %s: " "found blacklisted dependencies: %s", name, ', '.join(blacklisted)) diff --git a/tests/components/default_config/__init__.py b/tests/components/default_config/__init__.py new file mode 100644 index 00000000000..7ee4658fed5 --- /dev/null +++ b/tests/components/default_config/__init__.py @@ -0,0 +1 @@ +"""Tests for the default config component.""" diff --git a/tests/components/default_config/test_init.py b/tests/components/default_config/test_init.py new file mode 100644 index 00000000000..94adf53cb2d --- /dev/null +++ b/tests/components/default_config/test_init.py @@ -0,0 +1,27 @@ +"""Test the default_config init.""" +from unittest.mock import patch + +from homeassistant.setup import async_setup_component + +import pytest + +from tests.common import MockDependency + + +@pytest.fixture(autouse=True) +def netdisco_mock(): + """Mock netdisco.""" + with MockDependency('netdisco', 'discovery'): + yield + + +@pytest.fixture(autouse=True) +def recorder_url_mock(): + """Mock recorder url.""" + with patch('homeassistant.components.recorder.DEFAULT_URL', 'sqlite://'): + yield + + +async def test_setup(hass): + """Test setup.""" + assert await async_setup_component(hass, 'default_config', {})