ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
update_entity.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
7
8namespace esphome {
9namespace update {
10
11struct UpdateInfo {
12 std::string latest_version;
13 std::string current_version;
14 std::string title;
15 std::string summary;
16 std::string release_url;
17 std::string firmware_url;
18 std::string md5;
19 bool has_progress{false};
20 float progress;
21};
22
29
31
32class UpdateEntity : public EntityBase {
33 public:
34 void publish_state();
35
36 void perform() { this->perform(false); }
37 virtual void perform(bool force) = 0;
38 virtual void check() = 0;
39
42
43 template<typename F> void add_on_state_callback(F &&callback) {
44 this->state_callback_.add(std::forward<F>(callback));
45 }
48 update_available_trigger_ = std::make_unique<Trigger<const UpdateInfo &>>();
49 }
50 return update_available_trigger_.get();
51 }
52
53 protected:
56
58 std::unique_ptr<Trigger<const UpdateInfo &>> update_available_trigger_{nullptr};
59};
60
61} // namespace update
62} // namespace esphome
std::unique_ptr< Trigger< const UpdateInfo & > > update_available_trigger_
const UpdateState & state
Trigger< const UpdateInfo & > * get_update_available_trigger()
virtual void perform(bool force)=0
void add_on_state_callback(F &&callback)
LazyCallbackManager< void()> state_callback_
const UpdateInfo & update_info
bool state
Definition fan.h:2
const LogString * update_state_to_string(UpdateState state)
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7