ESPHome 2026.6.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::update {
9
10struct 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
28
30
31class UpdateEntity : public EntityBase {
32 public:
33 void publish_state();
34
35 void perform() { this->perform(false); }
36 virtual void perform(bool force) = 0;
37 virtual void check() = 0;
38
41
42 template<typename F> void add_on_state_callback(F &&callback) {
43 this->state_callback_.add(std::forward<F>(callback));
44 }
47 update_available_trigger_ = std::make_unique<Trigger<const UpdateInfo &>>();
48 }
49 return update_available_trigger_.get();
50 }
51
52 protected:
55
57 std::unique_ptr<Trigger<const UpdateInfo &>> update_available_trigger_{nullptr};
58};
59
60} // namespace esphome::update
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)