ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
opentherm_number.cpp
Go to the documentation of this file.
1#include "opentherm_number.h"
2
3namespace esphome::opentherm {
4
5static const char *const TAG = "opentherm.number";
6
7void OpenthermNumber::control(float value) {
8 this->publish_state(value);
9
10 if (this->restore_value_)
11 this->pref_.save(&value);
12}
13
15 float value;
16 if (!this->restore_value_) {
17 value = this->initial_value_;
18 } else {
20 if (!this->pref_.load(&value)) {
21 if (!std::isnan(this->initial_value_)) {
22 value = this->initial_value_;
23 } else {
24 value = this->traits.get_min_value();
25 }
26 }
27 }
28 this->publish_state(value);
29}
30
32 LOG_NUMBER("", "OpenTherm Number", this);
33 ESP_LOGCONFIG(TAG,
34 " Restore value: %d\n"
35 " Initial value: %.2f\n"
36 " Current value: %.2f",
37 this->restore_value_, this->initial_value_, this->state);
38}
39
40} // namespace esphome::opentherm
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
void publish_state(float state)
Definition number.cpp:22
NumberTraits traits
Definition number.h:41
void control(float value) override