From 06ad3987ba430ec738eb36c5b99bdf7b21992f07 Mon Sep 17 00:00:00 2001 From: andythigpen Date: Tue, 10 Mar 2015 18:16:53 -0500 Subject: [PATCH] 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. --- homeassistant/helpers/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/homeassistant/helpers/__init__.py b/homeassistant/helpers/__init__.py index d156e321cda..e05bcbc8b47 100644 --- a/homeassistant/helpers/__init__.py +++ b/homeassistant/helpers/__init__.py @@ -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)