forked from home-assistant/core
Add support for lists when using config_per_platform helper.
With the recent change to YAML, it is now easier to support lists by default. Any config section that previous relied on the "domain", "domain 1", "domain 2" format can now use YAML lists instead. The old format is also still supported.
This commit is contained in:
@@ -98,14 +98,17 @@ def config_per_platform(config, domain, logger):
|
|||||||
|
|
||||||
while config_key in config:
|
while config_key in config:
|
||||||
platform_config = config[config_key]
|
platform_config = config[config_key]
|
||||||
|
if not isinstance(platform_config, list):
|
||||||
|
platform_config = [platform_config]
|
||||||
|
|
||||||
platform_type = platform_config.get(CONF_PLATFORM)
|
for item in platform_config:
|
||||||
|
platform_type = item.get(CONF_PLATFORM)
|
||||||
|
|
||||||
if platform_type is None:
|
if platform_type is None:
|
||||||
logger.warning('No platform specified for %s', config_key)
|
logger.warning('No platform specified for %s', config_key)
|
||||||
break
|
continue
|
||||||
|
|
||||||
yield platform_type, platform_config
|
yield platform_type, item
|
||||||
|
|
||||||
found += 1
|
found += 1
|
||||||
config_key = "{} {}".format(domain, found)
|
config_key = "{} {}".format(domain, found)
|
||||||
|
Reference in New Issue
Block a user