Add default_config component (#20799)

* Add default config component

* Add default_config to default config

* Fix comments
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-02-07 20:07:15 -08:00
1 parent 222c4ea6f3
commit e59240fa00
7 files changed
+66 -47

No files matched your search

@@ -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
@@ -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."""
+1 -1
View File
@@ -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)