From 8be733efee993fe992de14c27ce8b88838c81c76 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Fri, 31 May 2019 11:17:46 +0200 Subject: [PATCH] Fix MQTT on_message trigger (#583) Fixes https://github.com/esphome/issues/issues/363 Fixes https://github.com/esphome/issues/issues/364 --- esphome/components/deep_sleep/deep_sleep_component.cpp | 2 +- esphome/components/mqtt/__init__.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/components/deep_sleep/deep_sleep_component.cpp b/esphome/components/deep_sleep/deep_sleep_component.cpp index 217c0cbf0d..684d7e12bf 100644 --- a/esphome/components/deep_sleep/deep_sleep_component.cpp +++ b/esphome/components/deep_sleep/deep_sleep_component.cpp @@ -87,7 +87,7 @@ void DeepSleepComponent::begin_sleep(bool manual) { ESP.deepSleep(*this->sleep_duration_); #endif } -float DeepSleepComponent::get_setup_priority() const { return -100.0f; } +float DeepSleepComponent::get_setup_priority() const { return setup_priority::LATE; } void DeepSleepComponent::prevent_deep_sleep() { this->prevent_ = true; } } // namespace deep_sleep diff --git a/esphome/components/mqtt/__init__.py b/esphome/components/mqtt/__init__.py index c1305d8422..d30e25c187 100644 --- a/esphome/components/mqtt/__init__.py +++ b/esphome/components/mqtt/__init__.py @@ -41,7 +41,8 @@ MQTTClientComponent = mqtt_ns.class_('MQTTClientComponent', cg.Component) MQTTPublishAction = mqtt_ns.class_('MQTTPublishAction', automation.Action) MQTTPublishJsonAction = mqtt_ns.class_('MQTTPublishJsonAction', automation.Action) MQTTMessageTrigger = mqtt_ns.class_('MQTTMessageTrigger', - automation.Trigger.template(cg.std_string)) + automation.Trigger.template(cg.std_string), + cg.Component) MQTTJsonMessageTrigger = mqtt_ns.class_('MQTTJsonMessageTrigger', automation.Trigger.template(cg.JsonObjectConstRef)) MQTTComponent = mqtt_ns.class_('MQTTComponent', cg.Component) @@ -217,6 +218,7 @@ def to_code(config): cg.add(trig.set_qos(conf[CONF_QOS])) if CONF_PAYLOAD in conf: cg.add(trig.set_payload(conf[CONF_PAYLOAD])) + yield cg.register_component(trig, conf) yield automation.build_automation(trig, [(cg.std_string, 'x')], conf) for conf in config.get(CONF_ON_JSON_MESSAGE, []):