1 #include "automation.h" 7 static const char *
const TAG =
"number.automation";
15 float local_min = this->min_.value(0.0);
16 float local_max = this->max_.value(0.0);
17 convert hash = {.from = (local_max - local_min)};
18 uint32_t myhash = hash.to ^ this->parent_->get_object_id_hash();
21 if (this->rtc_.load(&initial_state)) {
22 this->previous_in_range_ = initial_state;
25 this->parent_->add_on_state_callback([
this](
float state) { this->on_state_(state); });
30 if (std::isnan(state))
33 float local_min = this->min_.value(state);
34 float local_max = this->max_.value(state);
37 if (std::isnan(local_min) && std::isnan(local_max)) {
38 in_range = this->previous_in_range_;
39 }
else if (std::isnan(local_min)) {
40 in_range = state <= local_max;
41 }
else if (std::isnan(local_max)) {
42 in_range = state >= local_min;
44 in_range = local_min <= state && state <= local_max;
47 if (in_range != this->previous_in_range_ && in_range) {
51 this->previous_in_range_ = in_range;
52 this->rtc_.save(&in_range);
float get_setup_priority() const override
ESPPreferences * global_preferences
void on_state_(float state)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
Implementation of SPI Controller mode.