Fix scripts circular dependency (#591)

Fixes https://github.com/esphome/issues/issues/370
This commit is contained in:
Otto Winter 2019-06-01 12:00:10 +02:00 committed by GitHub
parent f921997ee6
commit 420c8b49e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,8 +16,13 @@ CONFIG_SCHEMA = automation.validate_automation({
def to_code(config):
# Register all variables first, so that scripts can use other scripts
triggers = []
for conf in config:
trigger = cg.new_Pvariable(conf[CONF_ID])
triggers.append((trigger, conf))
for trigger, conf in triggers:
yield automation.build_automation(trigger, [], conf)