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.pull/58/head
parent
c46e27928f
commit
06ad3987ba
|
@ -98,14 +98,17 @@ def config_per_platform(config, domain, logger):
|
|||
|
||||
while config_key in config:
|
||||
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:
|
||||
logger.warning('No platform specified for %s', config_key)
|
||||
break
|
||||
if platform_type is None:
|
||||
logger.warning('No platform specified for %s', config_key)
|
||||
continue
|
||||
|
||||
yield platform_type, platform_config
|
||||
yield platform_type, item
|
||||
|
||||
found += 1
|
||||
config_key = "{} {}".format(domain, found)
|
||||
|
|
Loading…
Reference in New Issue