38 template<
typename V>
void set_min(V min) { this->
min_ = min; }
39 template<
typename V>
void set_max(V max) { this->
max_ = max; }
44 if (this->
rtc_.
load(&initial_state)) {
54 if (std::isnan(
state))
57 float local_min = this->
min_.
value(state);
58 float local_max = this->
max_.
value(state);
61 if (std::isnan(local_min) && std::isnan(local_max)) {
63 }
else if (std::isnan(local_min)) {
64 in_range =
state <= local_max;
65 }
else if (std::isnan(local_max)) {
66 in_range =
state >= local_min;
68 in_range = local_min <=
state &&
state <= local_max;
92 bool check(
const Ts &...
x)
override {
94 if (std::isnan(this->
min_)) {
95 return state <= this->
max_;
96 }
else if (std::isnan(this->
max_)) {
97 return state >= this->
min_;
virtual void play(const 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_preference_hash()
Get a unique hash for storing preferences/settings for this entity.
void trigger(const Ts &...x)
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.
SensorInRangeCondition(Sensor *parent)
bool check(const Ts &...x) override
TEMPLATABLE_VALUE(float, state) void play(const 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.
ESPPreferences * global_preferences