Fix MQTT on_message trigger (#583)

Fixes https://github.com/esphome/issues/issues/363
Fixes https://github.com/esphome/issues/issues/364
This commit is contained in:
Otto Winter 2019-05-31 11:17:46 +02:00
parent 82dbacbee5
commit 6535b0966e
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
2 changed files with 4 additions and 2 deletions

View file

@ -87,7 +87,7 @@ void DeepSleepComponent::begin_sleep(bool manual) {
ESP.deepSleep(*this->sleep_duration_); ESP.deepSleep(*this->sleep_duration_);
#endif #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; } void DeepSleepComponent::prevent_deep_sleep() { this->prevent_ = true; }
} // namespace deep_sleep } // namespace deep_sleep

View file

@ -41,7 +41,8 @@ MQTTClientComponent = mqtt_ns.class_('MQTTClientComponent', cg.Component)
MQTTPublishAction = mqtt_ns.class_('MQTTPublishAction', automation.Action) MQTTPublishAction = mqtt_ns.class_('MQTTPublishAction', automation.Action)
MQTTPublishJsonAction = mqtt_ns.class_('MQTTPublishJsonAction', automation.Action) MQTTPublishJsonAction = mqtt_ns.class_('MQTTPublishJsonAction', automation.Action)
MQTTMessageTrigger = mqtt_ns.class_('MQTTMessageTrigger', MQTTMessageTrigger = mqtt_ns.class_('MQTTMessageTrigger',
automation.Trigger.template(cg.std_string)) automation.Trigger.template(cg.std_string),
cg.Component)
MQTTJsonMessageTrigger = mqtt_ns.class_('MQTTJsonMessageTrigger', MQTTJsonMessageTrigger = mqtt_ns.class_('MQTTJsonMessageTrigger',
automation.Trigger.template(cg.JsonObjectConstRef)) automation.Trigger.template(cg.JsonObjectConstRef))
MQTTComponent = mqtt_ns.class_('MQTTComponent', cg.Component) MQTTComponent = mqtt_ns.class_('MQTTComponent', cg.Component)
@ -217,6 +218,7 @@ def to_code(config):
cg.add(trig.set_qos(conf[CONF_QOS])) cg.add(trig.set_qos(conf[CONF_QOS]))
if CONF_PAYLOAD in conf: if CONF_PAYLOAD in conf:
cg.add(trig.set_payload(conf[CONF_PAYLOAD])) cg.add(trig.set_payload(conf[CONF_PAYLOAD]))
yield cg.register_component(trig, conf)
yield automation.build_automation(trig, [(cg.std_string, 'x')], conf) yield automation.build_automation(trig, [(cg.std_string, 'x')], conf)
for conf in config.get(CONF_ON_JSON_MESSAGE, []): for conf in config.get(CONF_ON_JSON_MESSAGE, []):