ESPHome  2024.12.2
automation.h
Go to the documentation of this file.
1 #pragma once
2 #include "ota_http_request.h"
3 
5 
6 namespace esphome {
7 namespace http_request {
8 
9 template<typename... Ts> class OtaHttpRequestComponentFlashAction : public Action<Ts...> {
10  public:
12  TEMPLATABLE_VALUE(std::string, md5_url)
13  TEMPLATABLE_VALUE(std::string, md5)
14  TEMPLATABLE_VALUE(std::string, password)
15  TEMPLATABLE_VALUE(std::string, url)
16  TEMPLATABLE_VALUE(std::string, username)
17 
18  void play(Ts... x) override {
19  if (this->md5_url_.has_value()) {
20  this->parent_->set_md5_url(this->md5_url_.value(x...));
21  }
22  if (this->md5_.has_value()) {
23  this->parent_->set_md5(this->md5_.value(x...));
24  }
25  if (this->password_.has_value()) {
26  this->parent_->set_password(this->password_.value(x...));
27  }
28  if (this->username_.has_value()) {
29  this->parent_->set_username(this->username_.value(x...));
30  }
31  this->parent_->set_url(this->url_.value(x...));
32 
33  this->parent_->flash();
34  // Normally never reached due to reboot
35  }
36 
37  protected:
38  OtaHttpRequestComponent *parent_;
39 };
40 
41 } // namespace http_request
42 } // namespace esphome
OtaHttpRequestComponentFlashAction(OtaHttpRequestComponent *parent)
Definition: automation.h:11
uint16_t x
Definition: tt21100.cpp:17
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
virtual void play(Ts... x)=0