13 template<
typename V>
void set_min(V min) { this->
min_ = min; }
14 template<
typename V>
void set_max(V max) { this->
max_ = max; }
19 if (this->
rtc_.
load(&initial_state)) {
29 if (std::isnan(
state))
32 float local_min = this->
min_.
value(state);
33 float local_max = this->
max_.
value(state);
36 if (std::isnan(local_min) && std::isnan(local_max)) {
38 }
else if (std::isnan(local_min)) {
39 in_range =
state <= local_max;
40 }
else if (std::isnan(local_max)) {
41 in_range =
state >= local_min;
43 in_range = local_min <=
state &&
state <= local_max;
67 bool check(
const Ts &...
x)
override {
69 if (std::isnan(this->
min_)) {
70 return state <= this->
max_;
71 }
else if (std::isnan(this->
max_)) {
72 return state >= this->
min_;
Base class for all automation conditions.
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
Function-pointer-only templatable storage (4 bytes on 32-bit).
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Base-class for all sensors.
void add_on_state_callback(F &&callback)
Add a callback that will be called every time a filtered value arrives.
float state
This member variable stores the last state that has passed through all filters.
SensorInRangeCondition(Sensor *parent)
bool check(const Ts &...x) override
float get_setup_priority() const override
ValueRangeTrigger(Sensor *parent)
void on_state_(float state)
TemplatableFn< float, float > max_
TemplatableFn< float, float > min_
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.