ESPHome  2024.8.3
update_entity.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace update {
9 
10 struct UpdateInfo {
11  std::string latest_version;
12  std::string current_version;
13  std::string title;
14  std::string summary;
15  std::string release_url;
16  std::string firmware_url;
17  std::string md5;
18  bool has_progress{false};
19  float progress;
20 };
21 
22 enum UpdateState : uint8_t {
27 };
28 
30  public:
31  bool has_state() const { return this->has_state_; }
32 
33  void publish_state();
34 
35  void perform() { this->perform(false); }
36  virtual void perform(bool force) = 0;
37  virtual void check() = 0;
38 
39  const UpdateInfo &update_info = update_info_;
40  const UpdateState &state = state_;
41 
42  void add_on_state_callback(std::function<void()> &&callback) { this->state_callback_.add(std::move(callback)); }
43 
44  protected:
47  bool has_state_{false};
48 
49  CallbackManager<void()> state_callback_{};
50 };
51 
52 } // namespace update
53 } // namespace esphome
void add_on_state_callback(std::function< void()> &&callback)
Definition: update_entity.h:42
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool state
Definition: fan.h:34