ESPHome
2024.10.2
esphome
esphome
components
update
update_entity.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/automation.h
"
4
#include "
esphome/core/component.h
"
5
#include "
esphome/core/entity_base.h
"
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 {
23
UPDATE_STATE_UNKNOWN
,
24
UPDATE_STATE_NO_UPDATE
,
25
UPDATE_STATE_AVAILABLE
,
26
UPDATE_STATE_INSTALLING
,
27
};
28
29
class
UpdateEntity
:
public
EntityBase
,
public
EntityBase_DeviceClass
{
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
:
45
UpdateState
state_{
UPDATE_STATE_UNKNOWN
};
46
UpdateInfo
update_info_
;
47
bool
has_state_{
false
};
48
49
CallbackManager<void()>
state_callback_{};
50
};
51
52
}
// namespace update
53
}
// namespace esphome
esphome::update::UpdateInfo::progress
float progress
Definition:
update_entity.h:19
esphome::EntityBase_DeviceClass
Definition:
entity_base.h:66
esphome::update::UpdateInfo
Definition:
update_entity.h:10
esphome::update::UpdateEntity::perform
void perform()
Definition:
update_entity.h:35
automation.h
esphome::update::UpdateInfo::latest_version
std::string latest_version
Definition:
update_entity.h:11
esphome::update::UpdateInfo::current_version
std::string current_version
Definition:
update_entity.h:12
esphome::update::UpdateInfo::has_progress
bool has_progress
Definition:
update_entity.h:18
esphome::update::UPDATE_STATE_INSTALLING
Definition:
update_entity.h:26
entity_base.h
esphome::update::UpdateState
UpdateState
Definition:
update_entity.h:22
esphome::update::UpdateEntity
Definition:
update_entity.h:29
esphome::update::UPDATE_STATE_NO_UPDATE
Definition:
update_entity.h:24
esphome::EntityBase
Definition:
entity_base.h:16
esphome::update::UpdateInfo::summary
std::string summary
Definition:
update_entity.h:14
esphome::update::UpdateEntity::add_on_state_callback
void add_on_state_callback(std::function< void()> &&callback)
Definition:
update_entity.h:42
esphome::CallbackManager< void()>
esphome::update::UpdateInfo::firmware_url
std::string firmware_url
Definition:
update_entity.h:16
esphome::update::UpdateEntity::has_state
bool has_state() const
Definition:
update_entity.h:31
esphome::update::UpdateEntity::update_info_
UpdateInfo update_info_
Definition:
update_entity.h:46
esphome::update::UpdateInfo::release_url
std::string release_url
Definition:
update_entity.h:15
esphome::update::UpdateInfo::title
std::string title
Definition:
update_entity.h:13
esphome::update::UpdateInfo::md5
std::string md5
Definition:
update_entity.h:17
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
component.h
esphome::update::UPDATE_STATE_AVAILABLE
Definition:
update_entity.h:25
esphome::update::UPDATE_STATE_UNKNOWN
Definition:
update_entity.h:23
state
bool state
Definition:
fan.h:34
Generated by
1.8.13