39 template<
typename V>
void set_min(V min) { this->
min_ = min; }
40 template<
typename V>
void set_max(V max) { this->
max_ = max; }
45 if (this->
rtc_.
load(&initial_state)) {
55 if (std::isnan(
state))
58 float local_min = this->
min_.
value(state);
59 float local_max = this->
max_.
value(state);
62 if (std::isnan(local_min) && std::isnan(local_max)) {
64 }
else if (std::isnan(local_min)) {
65 in_range =
state <= local_max;
66 }
else if (std::isnan(local_max)) {
67 in_range =
state >= local_min;
69 in_range = local_min <=
state &&
state <= local_max;
95 if (std::isnan(this->
min_)) {
96 return state <= this->
max_;
97 }
else if (std::isnan(this->
max_)) {
98 return state >= this->
min_;
virtual void play(Ts... x)=0
Base class for all automation conditions.
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
uint32_t get_object_id_hash()
Base-class for all sensors.
void publish_state(float state)
Publish a new state to the front-end.
void add_on_state_callback(std::function< void(float)> &&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.
void add_on_raw_state_callback(std::function< void(float)> &&callback)
Add a callback that will be called every time the sensor sends a raw value.
bool check(Ts... x) override
SensorInRangeCondition(Sensor *parent)
TEMPLATABLE_VALUE(float, state) void play(Ts... x) override
SensorPublishAction(Sensor *sensor)
SensorRawStateTrigger(Sensor *parent)
SensorStateTrigger(Sensor *parent)
float get_setup_priority() const override
ValueRangeTrigger(Sensor *parent)
void on_state_(float state)
TemplatableValue< float, float > max_
TemplatableValue< float, float > min_
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Providing packet encoding functions for exchanging data with a remote host.
ESPPreferences * global_preferences