diff --git a/esphome/components/http_request/update/http_request_update.h b/esphome/components/http_request/update/http_request_update.h index 197a1b5e1c..cf34ace18e 100644 --- a/esphome/components/http_request/update/http_request_update.h +++ b/esphome/components/http_request/update/http_request_update.h @@ -1,7 +1,6 @@ #pragma once #include "esphome/core/component.h" -#include "esphome/core/defines.h" #include "esphome/core/helpers.h" #include "esphome/components/http_request/http_request.h" diff --git a/esphome/components/ota/automation.h b/esphome/components/ota/automation.h index 520cb293f0..ded8378ff2 100644 --- a/esphome/components/ota/automation.h +++ b/esphome/components/ota/automation.h @@ -14,17 +14,21 @@ class OTAStateChangeTrigger final : public Trigger, public OTAStateLis void on_ota_state(OTAState state, float progress, uint8_t error) override { this->trigger(state); } }; -class OTAStartTrigger final : public Trigger<>, public OTAStateListener { +template class OTAStateTrigger final : public Trigger<>, public OTAStateListener { public: - explicit OTAStartTrigger(OTAComponent *parent) { parent->add_state_listener(this); } + explicit OTAStateTrigger(OTAComponent *parent) { parent->add_state_listener(this); } void on_ota_state(OTAState state, float progress, uint8_t error) override { - if (state == OTA_STARTED) { + if (state == State) { this->trigger(); } } }; +using OTAStartTrigger = OTAStateTrigger; +using OTAEndTrigger = OTAStateTrigger; +using OTAAbortTrigger = OTAStateTrigger; + class OTAProgressTrigger final : public Trigger, public OTAStateListener { public: explicit OTAProgressTrigger(OTAComponent *parent) { parent->add_state_listener(this); } @@ -36,28 +40,6 @@ class OTAProgressTrigger final : public Trigger, public OTAStateListener } }; -class OTAEndTrigger final : public Trigger<>, public OTAStateListener { - public: - explicit OTAEndTrigger(OTAComponent *parent) { parent->add_state_listener(this); } - - void on_ota_state(OTAState state, float progress, uint8_t error) override { - if (state == OTA_COMPLETED) { - this->trigger(); - } - } -}; - -class OTAAbortTrigger final : public Trigger<>, public OTAStateListener { - public: - explicit OTAAbortTrigger(OTAComponent *parent) { parent->add_state_listener(this); } - - void on_ota_state(OTAState state, float progress, uint8_t error) override { - if (state == OTA_ABORT) { - this->trigger(); - } - } -}; - class OTAErrorTrigger final : public Trigger, public OTAStateListener { public: explicit OTAErrorTrigger(OTAComponent *parent) { parent->add_state_listener(this); }