From 420c8b49e27b73ecba06a9ba5d18d4112082f039 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sat, 1 Jun 2019 12:00:10 +0200 Subject: [PATCH] Fix scripts circular dependency (#591) Fixes https://github.com/esphome/issues/issues/370 --- esphome/components/script/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/esphome/components/script/__init__.py b/esphome/components/script/__init__.py index 962e2d56ca..e1983689a6 100644 --- a/esphome/components/script/__init__.py +++ b/esphome/components/script/__init__.py @@ -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)