fix safe_mode (#1421)

* Deprioritize automations

Ensures safe mode is loaded before any automations are ran

* Fix lint
This commit is contained in:
Alex 2021-01-08 13:11:42 -06:00 committed by GitHub
parent a269098a0e
commit 93e35a53ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,11 +209,8 @@ def _esp8266_add_lwip_type():
cg.add_build_flag('-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH')
@coroutine_with_priority(100.0)
def to_code(config):
cg.add_global(cg.global_ns.namespace('esphome').using)
cg.add(cg.App.pre_setup(config[CONF_NAME], cg.RawExpression('__DATE__ ", " __TIME__')))
@coroutine_with_priority(30.0)
def _add_automations(config):
for conf in config.get(CONF_ON_BOOT, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], conf.get(CONF_PRIORITY))
yield cg.register_component(trigger, conf)
@ -229,6 +226,14 @@ def to_code(config):
yield cg.register_component(trigger, conf)
yield automation.build_automation(trigger, [], conf)
@coroutine_with_priority(100.0)
def to_code(config):
cg.add_global(cg.global_ns.namespace('esphome').using)
cg.add(cg.App.pre_setup(config[CONF_NAME], cg.RawExpression('__DATE__ ", " __TIME__')))
CORE.add_job(_add_automations, config)
# Set LWIP build constants for ESP8266
if CORE.is_esp8266:
CORE.add_job(_esp8266_add_lwip_type)