ESPHome 2026.8.0b4
Loading...
Searching...
No Matches
filter.cpp
Go to the documentation of this file.
2#ifdef USE_SENSOR_FILTER
3
4#include "filter.h"
5#include <cmath>
7#include "esphome/core/hal.h"
9#include "esphome/core/log.h"
10#include "sensor.h"
11
12namespace esphome::sensor {
13
14static const char *const TAG = "sensor.filter";
15
16// Filter
17void Filter::input(float value) {
18 ESP_LOGVV(TAG, "Filter(%p)::input(%f)", this, value);
19 optional<float> out = this->new_value(value);
20 if (out.has_value())
21 this->output(*out);
22}
23void Filter::output(float value) {
24 if (this->next_ == nullptr) {
25 ESP_LOGVV(TAG, "Filter(%p)::output(%f) -> SENSOR", this, value);
27 } else {
28 ESP_LOGVV(TAG, "Filter(%p)::output(%f) -> %p", this, value, this->next_);
29 this->next_->input(value);
30 }
31}
32void Filter::initialize(Sensor *parent, Filter *next) {
33 ESP_LOGVV(TAG, "Filter(%p)::initialize(parent=%p next=%p)", this, parent, next);
34 this->parent_ = parent;
35 this->next_ = next;
36}
37
38// SlidingWindowFilter
39SlidingWindowFilter::SlidingWindowFilter(uint16_t window_size, uint16_t send_every, uint16_t send_first_at)
40 : send_every_(send_every), send_at_(send_every - send_first_at) {
41 this->window_.init(window_size);
42}
43
44optional<float> SlidingWindowFilter::new_value(float value) {
45 // Add value to ring buffer (overwrites oldest when full)
46 this->window_.push_overwrite(value);
47
48 // Check if we should send a result
49 if (++this->send_at_ >= this->send_every_) {
50 this->send_at_ = 0;
51 float result = this->compute_result();
52 ESP_LOGVV(TAG, "SlidingWindowFilter(%p)::new_value(%f) SENDING %f", this, value, result);
53 return result;
54 }
55 return {};
57
58// SortedWindowFilter
60 // Copy window without NaN values using FixedVector (no heap allocation)
61 // Returns unsorted values - caller will use std::nth_element for partial sorting as needed
62 FixedVector<float> values;
63 values.init(this->window_.size());
64 for (float v : this->window_) {
65 if (!std::isnan(v)) {
66 values.push_back(v);
67 }
68 }
69 return values;
70}
71
72// MedianFilter
75 if (values.empty())
76 return NAN;
77
78 size_t size = values.size();
79 size_t mid = size / 2;
80
81 if (size % 2) {
82 // Odd number of elements - use nth_element to find middle element
83 std::nth_element(values.begin(), values.begin() + mid, values.end());
84 return values[mid];
85 }
86 // Even number of elements - need both middle elements
87 // Use nth_element to find upper middle element
88 std::nth_element(values.begin(), values.begin() + mid, values.end());
89 float upper = values[mid];
90 // Find the maximum of the lower half (which is now everything before mid)
91 float lower = *std::max_element(values.begin(), values.begin() + mid);
92 return (lower + upper) / 2.0f;
93}
94
95// SkipInitialFilter
96SkipInitialFilter::SkipInitialFilter(size_t num_to_ignore) : num_to_ignore_(num_to_ignore) {}
97optional<float> SkipInitialFilter::new_value(float value) {
98 if (num_to_ignore_ > 0) {
100 ESP_LOGV(TAG, "SkipInitialFilter(%p)::new_value(%f) SKIPPING, %zu left", this, value, num_to_ignore_);
101 return {};
102 }
103
104 ESP_LOGV(TAG, "SkipInitialFilter(%p)::new_value(%f) SENDING", this, value);
105 return value;
106}
107
108// QuantileFilter
109QuantileFilter::QuantileFilter(size_t window_size, size_t send_every, size_t send_first_at, float quantile)
110 : SortedWindowFilter(window_size, send_every, send_first_at), quantile_(quantile) {}
111
113 FixedVector<float> values = this->get_window_values_();
114 if (values.empty())
115 return NAN;
116
117 size_t position = ceilf(values.size() * this->quantile_) - 1;
118 ESP_LOGVV(TAG, "QuantileFilter(%p)::position: %zu/%zu", this, position + 1, values.size());
119
120 // Use nth_element to find the quantile element (O(n) instead of O(n log n))
121 std::nth_element(values.begin(), values.begin() + position, values.end());
122 return values[position];
123}
124
125// MinFilter
127
128// MaxFilter
130
131// SlidingWindowMovingAverageFilter
133 float sum = 0;
134 size_t valid_count = 0;
135 for (float v : this->window_) {
136 if (!std::isnan(v)) {
137 sum += v;
138 valid_count++;
139 }
140 }
141 return valid_count ? sum / valid_count : NAN;
142}
143
144// ExponentialMovingAverageFilter
145ExponentialMovingAverageFilter::ExponentialMovingAverageFilter(float alpha, uint16_t send_every, uint16_t send_first_at)
146 : alpha_(alpha), send_every_(send_every), send_at_(send_every - send_first_at) {}
147optional<float> ExponentialMovingAverageFilter::new_value(float value) {
148 if (!std::isnan(value)) {
149 if (this->first_value_) {
150 this->accumulator_ = value;
151 this->first_value_ = false;
152 } else {
153 this->accumulator_ = (this->alpha_ * value) + (1.0f - this->alpha_) * this->accumulator_;
154 }
155 }
156
157 const float average = std::isnan(value) ? value : this->accumulator_;
158 ESP_LOGVV(TAG, "ExponentialMovingAverageFilter(%p)::new_value(%f) -> %f", this, value, average);
159
160 if (++this->send_at_ >= this->send_every_) {
161 ESP_LOGVV(TAG, "ExponentialMovingAverageFilter(%p)::new_value(%f) SENDING %f", this, value, average);
162 this->send_at_ = 0;
163 return average;
164 }
165 return {};
166}
167void ExponentialMovingAverageFilter::set_send_every(uint16_t send_every) { this->send_every_ = send_every; }
168void ExponentialMovingAverageFilter::set_alpha(float alpha) { this->alpha_ = alpha; }
169
170// ThrottleAverageFilter
171ThrottleAverageFilter::ThrottleAverageFilter(uint32_t time_period) : time_period_(time_period) {}
172
173optional<float> ThrottleAverageFilter::new_value(float value) {
174 ESP_LOGVV(TAG, "ThrottleAverageFilter(%p)::new_value(value=%f)", this, value);
175 if (std::isnan(value)) {
176 this->have_nan_ = true;
177 } else {
178 this->sum_ += value;
179 this->n_++;
180 }
181 return {};
182}
184 Filter::initialize(parent, next);
185 App.scheduler.set_interval(this, this->time_period_, [this]() {
186 ESP_LOGVV(TAG, "ThrottleAverageFilter(%p)::interval(sum=%f, n=%i)", this, this->sum_, this->n_);
187 if (this->n_ == 0) {
188 if (this->have_nan_)
189 this->output(NAN);
190 } else {
191 this->output(this->sum_ / this->n_);
192 this->sum_ = 0.0f;
193 this->n_ = 0;
194 }
195 this->have_nan_ = false;
196 });
197}
198
199// LambdaFilter
200LambdaFilter::LambdaFilter(lambda_filter_t lambda_filter) : lambda_filter_(std::move(lambda_filter)) {}
202void LambdaFilter::set_lambda_filter(const lambda_filter_t &lambda_filter) { this->lambda_filter_ = lambda_filter; }
203
204optional<float> LambdaFilter::new_value(float value) {
205 auto it = this->lambda_filter_(value);
206 ESP_LOGVV(TAG, "LambdaFilter(%p)::new_value(%f) -> %f", this, value, it.value_or(INFINITY));
207 return it;
208}
209
210// OffsetFilter
212
213optional<float> OffsetFilter::new_value(float value) { return value + this->offset_.value(); }
214
215// MultiplyFilter
216MultiplyFilter::MultiplyFilter(TemplatableFn<float> multiplier) : multiplier_(multiplier) {}
217
218optional<float> MultiplyFilter::new_value(float value) { return value * this->multiplier_.value(); }
219
220// ValueListFilter helper (non-template, shared by all ValueListFilter<N> instantiations)
221bool value_list_matches_any(Sensor *parent, float sensor_value, const TemplatableFn<float> *values, size_t count) {
222 int8_t accuracy = parent->get_accuracy_decimals();
223 float accuracy_mult = pow10_int(accuracy);
224 float rounded_sensor = roundf(accuracy_mult * sensor_value);
225
226 for (size_t i = 0; i < count; i++) {
227 float fv = values[i].value();
228
229 // Handle NaN comparison
230 if (std::isnan(fv)) {
231 if (std::isnan(sensor_value))
232 return true;
233 continue;
234 }
235
236 // Compare rounded values
237 if (roundf(accuracy_mult * fv) == rounded_sensor)
238 return true;
239 }
240
241 return false;
242}
243
244// ThrottleFilter
245ThrottleFilter::ThrottleFilter(uint32_t min_time_between_inputs) : min_time_between_inputs_(min_time_between_inputs) {}
246optional<float> ThrottleFilter::new_value(float value) {
248 if (this->last_input_ == 0 || now - this->last_input_ >= min_time_between_inputs_) {
249 this->last_input_ = now;
250 return value;
251 }
252 return {};
253}
254
255// ThrottleWithPriorityFilter helper (non-template, keeps App access in .cpp)
256optional<float> throttle_with_priority_new_value(Sensor *parent, float value, const TemplatableFn<float> *values,
257 size_t count, uint32_t &last_input, uint32_t min_time_between_inputs) {
259 if (last_input == 0 || now - last_input >= min_time_between_inputs ||
260 value_list_matches_any(parent, value, values, count)) {
261 last_input = now;
262 return value;
263 }
264 return {};
265}
266
267// ThrottleWithPriorityNanFilter
269 : min_time_between_inputs_(min_time_between_inputs) {}
270optional<float> ThrottleWithPriorityNanFilter::new_value(float value) {
272 if (this->last_input_ == 0 || now - this->last_input_ >= this->min_time_between_inputs_ || std::isnan(value)) {
273 this->last_input_ = now;
274 return value;
275 }
276 return {};
277}
278
279// DeltaFilter
280DeltaFilter::DeltaFilter(float min_a0, float min_a1, float max_a0, float max_a1)
281 : min_a0_(min_a0), min_a1_(min_a1), max_a0_(max_a0), max_a1_(max_a1) {}
282
283void DeltaFilter::set_baseline(float (*fn)(float)) { this->baseline_ = fn; }
284
285optional<float> DeltaFilter::new_value(float value) {
286 const bool no_value = std::isnan(value);
287 const bool no_reference = std::isnan(this->last_value_);
288 if (no_value && no_reference)
289 return {};
290 if (no_value || no_reference) {
291 this->last_value_ = value;
292 return value;
293 }
294 // calculate min and max using the linear equation
295 float ref = this->baseline_(this->last_value_);
296 float min = fabsf(this->min_a0_ + ref * this->min_a1_);
297 float max = fabsf(this->max_a0_ + ref * this->max_a1_);
298 float delta = fabsf(value - ref);
299 // accept only if within range
300 if (delta > min && delta <= max) {
301 this->last_value_ = value;
302 return value;
303 }
304 return {};
305}
306
307// OrFilter helpers
308void or_filter_initialize(Filter **filters, size_t count, Sensor *parent, Filter *phi) {
309 for (size_t i = 0; i < count; i++) {
310 filters[i]->initialize(parent, phi);
311 }
312 phi->initialize(parent, nullptr);
313}
314
315optional<float> or_filter_new_value(Filter **filters, size_t count, float value, bool &has_value) {
316 has_value = false;
317 for (size_t i = 0; i < count; i++)
318 filters[i]->input(value);
319 return {};
320}
321
322// TimeoutFilterBase - shared loop logic
324 // Check if timeout period has elapsed
325 // Use cached loop start time to avoid repeated millis() calls
327 if (now - this->timeout_start_time_ >= this->time_period_) {
328 // Timeout fired - get output value from derived class and output it
329 this->output(this->get_output_value());
330
331 // Disable loop until next value arrives
332 this->disable_loop();
333 }
334}
335
337
338// TimeoutFilterLast - "last" mode implementation
339optional<float> TimeoutFilterLast::new_value(float value) {
340 // Store the value to output when timeout fires
341 this->pending_value_ = value;
342
343 // Record when timeout started and enable loop
344 this->timeout_start_time_ = millis();
345 this->enable_loop();
346
347 return value;
348}
349
350// TimeoutFilterConfigured - configured value mode implementation
351optional<float> TimeoutFilterConfigured::new_value(float value) {
352 // Record when timeout started and enable loop
353 // Note: we don't store the incoming value since we have a configured value
354 this->timeout_start_time_ = millis();
355 this->enable_loop();
356
357 return value;
358}
359
360// DebounceFilter
361optional<float> DebounceFilter::new_value(float value) {
362 App.scheduler.set_timeout(this, this->time_period_, [this, value]() { this->output(value); });
363
364 return {};
365}
366
367DebounceFilter::DebounceFilter(uint32_t time_period) : time_period_(time_period) {}
368
369// HeartbeatFilter
370HeartbeatFilter::HeartbeatFilter(uint32_t time_period) : time_period_(time_period), last_input_(NAN) {}
371
372optional<float> HeartbeatFilter::new_value(float value) {
373 ESP_LOGVV(TAG, "HeartbeatFilter(%p)::new_value(value=%f)", this, value);
374 this->last_input_ = value;
375 this->has_value_ = true;
376
377 if (this->optimistic_) {
378 return value;
379 }
380 return {};
381}
382
384 Filter::initialize(parent, next);
385 App.scheduler.set_interval(this, this->time_period_, [this]() {
386 ESP_LOGVV(TAG, "HeartbeatFilter(%p)::interval(has_value=%s, last_input=%f)", this, YESNO(this->has_value_),
387 this->last_input_);
388 if (!this->has_value_)
389 return;
390
391 this->output(this->last_input_);
392 });
393}
394
395optional<float> calibrate_linear_compute(const std::array<float, 3> *functions, size_t count, float value) {
396 for (size_t i = 0; i < count; i++) {
397 if (!std::isfinite(functions[i][2]) || value < functions[i][2])
398 return (value * functions[i][0]) + functions[i][1];
399 }
400 return NAN;
401}
402
403optional<float> calibrate_polynomial_compute(const float *coefficients, size_t count, float value) {
404 float res = 0.0f;
405 float x = 1.0f;
406 for (size_t i = 0; i < count; i++) {
407 res += x * coefficients[i];
408 x *= value;
409 }
410 return res;
411}
412
413ClampFilter::ClampFilter(float min, float max, bool ignore_out_of_range)
414 : min_(min), max_(max), ignore_out_of_range_(ignore_out_of_range) {}
415optional<float> ClampFilter::new_value(float value) {
416 if (std::isfinite(this->min_) && !(value >= this->min_)) {
417 if (this->ignore_out_of_range_) {
418 return {};
419 }
420 return this->min_;
421 }
422
423 if (std::isfinite(this->max_) && !(value <= this->max_)) {
424 if (this->ignore_out_of_range_) {
425 return {};
426 }
427 return this->max_;
428 }
429 return value;
430}
431
432RoundFilter::RoundFilter(uint8_t precision) : precision_(precision) {}
433optional<float> RoundFilter::new_value(float value) {
434 if (std::isfinite(value)) {
435 float accuracy_mult = pow10_int(this->precision_);
436 return roundf(accuracy_mult * value) / accuracy_mult;
437 }
438 return value;
439}
440
441RoundMultipleFilter::RoundMultipleFilter(float multiple) : multiple_(multiple) {}
442optional<float> RoundMultipleFilter::new_value(float value) {
443 if (std::isfinite(value)) {
444 return value - remainderf(value, this->multiple_);
445 }
446 return value;
447}
448
449optional<float> ToNTCResistanceFilter::new_value(float value) {
450 if (!std::isfinite(value)) {
451 return NAN;
452 }
453 double k = 273.15;
454 // https://de.wikipedia.org/wiki/Steinhart-Hart-Gleichung#cite_note-stein2_s4-3
455 double t = value + k;
456 double y = (this->a_ - 1 / (t)) / (2 * this->c_);
457 double x = sqrt(pow(this->b_ / (3 * this->c_), 3) + y * y);
458 double resistance = exp(pow(x - y, 1 / 3.0) - pow(x + y, 1 / 3.0));
459 return resistance;
460}
461
462optional<float> ToNTCTemperatureFilter::new_value(float value) {
463 if (!std::isfinite(value)) {
464 return NAN;
465 }
466 double lr = log(double(value));
467 double v = this->a_ + this->b_ * lr + this->c_ * lr * lr * lr;
468 double temp = float(1.0 / v - 273.15);
469 return temp;
470}
471
472// StreamingFilter (base class)
473StreamingFilter::StreamingFilter(uint16_t window_size, uint16_t send_first_at)
474 : window_size_(window_size), send_first_at_(send_first_at) {}
475
476optional<float> StreamingFilter::new_value(float value) {
477 // Process the value (child class tracks min/max/sum/etc)
478 this->process_value(value);
479
480 this->count_++;
481
482 // Check if we should send (handle send_first_at for first value)
483 bool should_send = false;
484 if (this->first_send_ && this->count_ >= this->send_first_at_) {
485 should_send = true;
486 this->first_send_ = false;
487 } else if (!this->first_send_ && this->count_ >= this->window_size_) {
488 should_send = true;
489 }
490
491 if (should_send) {
492 float result = this->compute_batch_result();
493 // Reset for next batch
494 this->count_ = 0;
495 this->reset_batch();
496 ESP_LOGVV(TAG, "StreamingFilter(%p)::new_value(%f) SENDING %f", this, value, result);
497 return result;
498 }
499
500 return {};
501}
502
503// StreamingMinFilter
505 // Update running minimum (ignore NaN values)
506 if (!std::isnan(value)) {
507 this->current_min_ = std::isnan(this->current_min_) ? value : std::min(this->current_min_, value);
508 }
509}
510
512
514
515// StreamingMaxFilter
517 // Update running maximum (ignore NaN values)
518 if (!std::isnan(value)) {
519 this->current_max_ = std::isnan(this->current_max_) ? value : std::max(this->current_max_, value);
520 }
521}
522
524
526
527// StreamingMovingAverageFilter
529 // Accumulate sum (ignore NaN values)
530 if (!std::isnan(value)) {
531 this->sum_ += value;
532 this->valid_count_++;
533 }
534}
535
537 return this->valid_count_ > 0 ? this->sum_ / this->valid_count_ : NAN;
538}
539
541 this->sum_ = 0.0f;
542 this->valid_count_ = 0;
543}
544
545} // namespace esphome::sensor
546
547#endif // USE_SENSOR_FILTER
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
void enable_loop()
Enable this component's loop.
Definition component.h:246
void disable_loop()
Disable this component's loop.
void push_overwrite(const T &value)
Push a value, overwriting the oldest if full.
Definition helpers.h:477
void init(index_type capacity)
Allocate capacity - can only be called once.
Definition helpers.h:455
index_type size() const
Definition helpers.h:498
Fixed-capacity vector - allocates once at runtime, never reallocates This avoids std::vector template...
Definition helpers.h:544
bool empty() const
Definition helpers.h:711
size_t size() const
Definition helpers.h:710
void push_back(const T &value)
Add element without bounds checking Caller must ensure sufficient capacity was allocated via init() S...
Definition helpers.h:661
void init(size_t n)
Definition helpers.h:634
Function-pointer-only templatable storage (4 bytes on 32-bit).
Definition automation.h:19
T value(X... x) const
Definition automation.h:58
ClampFilter(float min, float max, bool ignore_out_of_range)
Definition filter.cpp:413
optional< float > new_value(float value) override
Definition filter.cpp:415
optional< float > new_value(float value) override
Definition filter.cpp:361
DebounceFilter(uint32_t time_period)
Definition filter.cpp:367
void set_baseline(float(*fn)(float))
Definition filter.cpp:283
DeltaFilter(float min_a0, float min_a1, float max_a0, float max_a1)
Definition filter.cpp:280
optional< float > new_value(float value) override
Definition filter.cpp:285
float(* baseline_)(float)
Definition filter.h:522
optional< float > new_value(float value) override
Definition filter.cpp:147
ExponentialMovingAverageFilter(float alpha, uint16_t send_every, uint16_t send_first_at)
Definition filter.cpp:145
Apply a filter to sensor values such as moving average.
Definition filter.h:22
virtual optional< float > new_value(float value)=0
This will be called every time the filter receives a new value.
void output(float value)
Definition filter.cpp:23
virtual void initialize(Sensor *parent, Filter *next)
Initialize this filter, please note this can be called more than once.
Definition filter.cpp:32
void input(float value)
Definition filter.cpp:17
HeartbeatFilter(uint32_t time_period)
Definition filter.cpp:370
optional< float > new_value(float value) override
Definition filter.cpp:372
void initialize(Sensor *parent, Filter *next) override
Definition filter.cpp:383
const lambda_filter_t & get_lambda_filter() const
Definition filter.cpp:201
LambdaFilter(lambda_filter_t lambda_filter)
Definition filter.cpp:200
lambda_filter_t lambda_filter_
Definition filter.h:294
void set_lambda_filter(const lambda_filter_t &lambda_filter)
Definition filter.cpp:202
optional< float > new_value(float value) override
Definition filter.cpp:204
float compute_result() override
Definition filter.cpp:129
float compute_result() override
Definition filter.cpp:73
float compute_result() override
Definition filter.cpp:126
float find_extremum_()
Helper to find min or max value in window, skipping NaN values Usage: find_extremum_<std::less<float>...
Definition filter.h:81
TemplatableFn< float > multiplier_
Definition filter.h:330
optional< float > new_value(float value) override
Definition filter.cpp:218
MultiplyFilter(TemplatableFn< float > multiplier)
Definition filter.cpp:216
optional< float > new_value(float value) override
Definition filter.cpp:213
TemplatableFn< float > offset_
Definition filter.h:320
OffsetFilter(TemplatableFn< float > offset)
Definition filter.cpp:211
float compute_result() override
Definition filter.cpp:112
QuantileFilter(size_t window_size, size_t send_every, size_t send_first_at, float quantile)
Construct a QuantileFilter.
Definition filter.cpp:109
RoundFilter(uint8_t precision)
Definition filter.cpp:432
optional< float > new_value(float value) override
Definition filter.cpp:433
optional< float > new_value(float value) override
Definition filter.cpp:442
Base-class for all sensors.
Definition sensor.h:47
void internal_send_state_to_frontend(float state)
Definition sensor.cpp:122
int8_t get_accuracy_decimals()
Get the accuracy in decimals, using the manual override if set.
Definition sensor.cpp:48
SkipInitialFilter(size_t num_to_ignore)
Construct a SkipInitialFilter.
Definition filter.cpp:96
optional< float > new_value(float value) override
Definition filter.cpp:97
FixedRingBuffer< float > window_
Sliding window ring buffer - automatically overwrites oldest values when full.
Definition filter.h:65
optional< float > new_value(float value) final
Definition filter.cpp:44
SlidingWindowFilter(uint16_t window_size, uint16_t send_every, uint16_t send_first_at)
Definition filter.cpp:39
uint16_t send_every_
Send result every N values.
Definition filter.h:66
virtual float compute_result()=0
Called by new_value() to compute the filtered result from the current window.
uint16_t send_at_
Counter for send_every.
Definition filter.h:67
Base class for filters that need a sorted window (Median, Quantile).
Definition filter.h:98
FixedVector< float > get_window_values_()
Helper to get non-NaN values from the window (not sorted - caller will use nth_element) Returns empty...
Definition filter.cpp:59
StreamingFilter(uint16_t window_size, uint16_t send_first_at)
Definition filter.cpp:473
virtual void process_value(float value)=0
Called by new_value() to process each value in the batch.
virtual float compute_batch_result()=0
Called by new_value() to compute the result after collecting window_size values.
virtual void reset_batch()=0
Called by new_value() to reset internal state after sending a result.
optional< float > new_value(float value) final
Definition filter.cpp:476
void process_value(float value) override
Definition filter.cpp:516
float compute_batch_result() override
Definition filter.cpp:523
float compute_batch_result() override
Definition filter.cpp:511
void process_value(float value) override
Definition filter.cpp:504
void process_value(float value) override
Definition filter.cpp:528
optional< float > new_value(float value) override
Definition filter.cpp:173
ThrottleAverageFilter(uint32_t time_period)
Definition filter.cpp:171
void initialize(Sensor *parent, Filter *next) override
Definition filter.cpp:183
ThrottleFilter(uint32_t min_time_between_inputs)
Definition filter.cpp:245
optional< float > new_value(float value) override
Definition filter.cpp:246
optional< float > new_value(float value) override
Definition filter.cpp:270
ThrottleWithPriorityNanFilter(uint32_t min_time_between_inputs)
Definition filter.cpp:268
float get_setup_priority() const override
Definition filter.cpp:336
optional< float > new_value(float value) override
Definition filter.cpp:351
optional< float > new_value(float value) override
Definition filter.cpp:339
optional< float > new_value(float value) override
Definition filter.cpp:449
optional< float > new_value(float value) override
Definition filter.cpp:462
float position
Definition cover.h:0
optional< float > throttle_with_priority_new_value(Sensor *parent, float value, const TemplatableFn< float > *values, size_t count, uint32_t &last_input, uint32_t min_time_between_inputs)
Non-template helper for ThrottleWithPriorityFilter (implementation in filter.cpp)
Definition filter.cpp:256
void or_filter_initialize(Filter **filters, size_t count, Sensor *parent, Filter *phi)
Non-template helpers for OrFilter (implementation in filter.cpp)
Definition filter.cpp:308
bool value_list_matches_any(Sensor *parent, float sensor_value, const TemplatableFn< float > *values, size_t count)
Non-template helper for value matching (implementation in filter.cpp)
Definition filter.cpp:221
optional< float > calibrate_polynomial_compute(const float *coefficients, size_t count, float value)
Non-template helper for polynomial calibration (implementation in filter.cpp)
Definition filter.cpp:403
optional< float > calibrate_linear_compute(const std::array< float, 3 > *functions, size_t count, float value)
Non-template helper for linear calibration (implementation in filter.cpp)
Definition filter.cpp:395
std::function< optional< float >(float)> lambda_filter_t
Definition filter.h:275
optional< float > or_filter_new_value(Filter **filters, size_t count, float value, bool &has_value)
Definition filter.cpp:315
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.h:43
uint16_t size
Definition helpers.cpp:25
uint32_t IRAM_ATTR HOT millis()
Definition hal.cpp:28
Application App
Global storage of Application pointer - only one Application can exist.
float pow10_int(int8_t exp)
Compute 10^exp using iterative multiplication/division.
Definition helpers.h:776
STL namespace.
static void uint32_t
uint32_t lr
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6