3 #include "binary_sensor.h" 10 static const char *
const TAG =
"sensor.filter";
16 if (this->
next_ ==
nullptr) {
23 auto b = this->
new_value(value, is_initial);
25 this->
output(*b, is_initial);
31 this->set_timeout(
"ON_OFF", this->on_delay_.value(), [
this, is_initial]() { this->
output(
true, is_initial); });
33 this->set_timeout(
"ON_OFF", this->off_delay_.value(), [
this, is_initial]() { this->
output(
false, is_initial); });
42 this->set_timeout(
"ON", this->delay_.value(), [
this, is_initial]() { this->
output(
true, is_initial); });
45 this->cancel_timeout(
"ON");
54 this->set_timeout(
"OFF", this->delay_.value(), [
this, is_initial]() { this->
output(
false, is_initial); });
57 this->cancel_timeout(
"OFF");
89 if (this->active_timing_ < this->
timings_.size())
92 if (this->active_timing_ <= this->
timings_.size()) {
115 if (!this->steady_) {
116 this->set_timeout(
"SETTLE", this->delay_.value(), [
this, value, is_initial]() {
117 this->steady_ =
true;
118 this->
output(value, is_initial);
122 this->steady_ =
false;
123 this->
output(value, is_initial);
124 this->set_timeout(
"SETTLE", this->delay_.value(), [
this]() { this->steady_ =
true; });
LambdaFilter(std::function< optional< bool >(bool)> f)
float get_setup_priority() const override
optional< bool > new_value(bool value, bool is_initial) override
std::vector< AutorepeatFilterTiming > timings_
bool cancel_timeout(const std::string &name)
Cancel a timeout function.
std::function< optional< bool >bool)> f_
bool next(T value)
Feeds the next item in the series to the deduplicator and returns whether this is a duplicate...
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
virtual optional< bool > new_value(bool value, bool is_initial)=0
void next_value_(bool val)
optional< bool > new_value(bool value, bool is_initial) override
void send_state_internal(bool state, bool is_initial)
void input(bool value, bool is_initial)
optional< bool > new_value(bool value, bool is_initial) override
void output(bool value, bool is_initial)
Deduplicator< bool > dedup_
esphome::binary_sensor::BinarySensor * binary_sensor
AutorepeatFilter(std::vector< AutorepeatFilterTiming > timings)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
optional< bool > new_value(bool value, bool is_initial) override
float get_setup_priority() const override
Implementation of SPI Controller mode.
optional< bool > new_value(bool value, bool is_initial) override
float get_setup_priority() const override
optional< bool > new_value(bool value, bool is_initial) override
float get_setup_priority() const override
void IRAM_ATTR HOT delay(uint32_t ms)
float get_setup_priority() const override
optional< bool > new_value(bool value, bool is_initial) override