From 91fe83507b3f674b9591649d503b4701aae18d81 Mon Sep 17 00:00:00 2001 From: "Michael \"Chishm\" Chisholm" Date: Sun, 11 Oct 2020 15:06:47 +1100 Subject: [PATCH] Apply all entity_controller configs in setup Allow multiple `entity_controller:` keys in the HA configuration YAML by applying all that are found. This adds support for using `packages` to separate the EC config into multiple files. --- .../entity_controller/__init__.py | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/custom_components/entity_controller/__init__.py b/custom_components/entity_controller/__init__.py index 86389e4..46376c3 100644 --- a/custom_components/entity_controller/__init__.py +++ b/custom_components/entity_controller/__init__.py @@ -164,14 +164,11 @@ async def async_setup(hass, config): component = EntityComponent(_LOGGER, DOMAIN, hass) - myconfig = config[DOMAIN][0] - _LOGGER.info( "If you have ANY issues with EntityController (v" + VERSION + "), please enable DEBUG logging under the logger component and kindly report the issue on Github. https://github.com/danobot/entity-controller/issues" ) - _LOGGER.info("Domain Configuration: " + str(myconfig)) async_setup_entity_services(component) @@ -330,17 +327,19 @@ async def async_setup(hass, config): # Enter blocked state when component is enabled and entity is on machine.add_transition(trigger="blocked", source="constrained", dest="blocked") - for key, config in myconfig.items(): - if not config: - config = {} - - # _LOGGER.info("Config Item %s: %s", str(key), str(config)) - config["name"] = key - m = None - m = EntityController(hass, config, machine) - # machine.add_model(m.model) - # m.model.after_model(config) - devices.append(m) + for myconfig in config[DOMAIN]: + _LOGGER.info("Domain Configuration: " + str(myconfig)) + for key, config in myconfig.items(): + if not config: + config = {} + + # _LOGGER.info("Config Item %s: %s", str(key), str(config)) + config["name"] = key + m = None + m = EntityController(hass, config, machine) + # machine.add_model(m.model) + # m.model.after_model(config) + devices.append(m) await component.async_add_entities(devices)