mirror of
https://github.com/esphome/esphome.git
synced 2025-09-17 18:52:19 +01:00
[update, http_request_update] Implement update available trigger (#9174)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/entity_base.h"
|
||||
@@ -38,12 +39,19 @@ class UpdateEntity : public EntityBase, public EntityBase_DeviceClass {
|
||||
const UpdateState &state = state_;
|
||||
|
||||
void add_on_state_callback(std::function<void()> &&callback) { this->state_callback_.add(std::move(callback)); }
|
||||
Trigger<const UpdateInfo &> *get_update_available_trigger() {
|
||||
if (!update_available_trigger_) {
|
||||
update_available_trigger_ = std::make_unique<Trigger<const UpdateInfo &>>();
|
||||
}
|
||||
return update_available_trigger_.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
UpdateState state_{UPDATE_STATE_UNKNOWN};
|
||||
UpdateInfo update_info_;
|
||||
|
||||
CallbackManager<void()> state_callback_{};
|
||||
std::unique_ptr<Trigger<const UpdateInfo &>> update_available_trigger_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace update
|
||||
|
Reference in New Issue
Block a user