mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-26 15:48:28 +02:00
8ef4aaa70e
Co-authored-by: Keith Burzinski <kbx81x@gmail.com> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Edward Firmo <94725493+edwardtfn@users.noreply.github.com>
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#pragma once
|
|
#include "ota_http_request.h"
|
|
|
|
#include "esphome/core/automation.h"
|
|
|
|
namespace esphome {
|
|
namespace http_request {
|
|
|
|
template<typename... Ts> class OtaHttpRequestComponentFlashAction : public Action<Ts...> {
|
|
public:
|
|
OtaHttpRequestComponentFlashAction(OtaHttpRequestComponent *parent) : parent_(parent) {}
|
|
TEMPLATABLE_VALUE(std::string, md5_url)
|
|
TEMPLATABLE_VALUE(std::string, md5)
|
|
TEMPLATABLE_VALUE(std::string, password)
|
|
TEMPLATABLE_VALUE(std::string, url)
|
|
TEMPLATABLE_VALUE(std::string, username)
|
|
|
|
void play(Ts... x) override {
|
|
if (this->md5_url_.has_value()) {
|
|
this->parent_->set_md5_url(this->md5_url_.value(x...));
|
|
}
|
|
if (this->md5_.has_value()) {
|
|
this->parent_->set_md5(this->md5_.value(x...));
|
|
}
|
|
if (this->password_.has_value()) {
|
|
this->parent_->set_password(this->password_.value(x...));
|
|
}
|
|
if (this->username_.has_value()) {
|
|
this->parent_->set_username(this->username_.value(x...));
|
|
}
|
|
this->parent_->set_url(this->url_.value(x...));
|
|
|
|
this->parent_->flash();
|
|
// Normally never reached due to reboot
|
|
}
|
|
|
|
protected:
|
|
OtaHttpRequestComponent *parent_;
|
|
};
|
|
|
|
} // namespace http_request
|
|
} // namespace esphome
|