ESPHome 2026.5.0b1
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 // Always yield the first value.
287 if (std::isnan(this->last_value_)) {
288 this->last_value_ = value;
289 return value;
290 }
291 // calculate min and max using the linear equation
292 float ref = this->baseline_(this->last_value_);
293 float min = fabsf(this->min_a0_ + ref * this->min_a1_);
294 float max = fabsf(this->max_a0_ + ref * this->max_a1_);
295 float delta = fabsf(value - ref);
296 // if there is no reference, e.g. for the first value, just accept this one,
297 // otherwise accept only if within range.
298 if (delta > min && delta <= max) {
299 this->last_value_ = value;
300 return value;
301 }
302 return {};
303}
304
305// OrFilter helpers
306void or_filter_initialize(Filter **filters, size_t count, Sensor *parent, Filter *phi) {
307 for (size_t i = 0; i < count; i++) {
308 filters[i]->initialize(parent, phi);
309 }
310 phi->initialize(parent, nullptr);
311}
312
313optional<float> or_filter_new_value(Filter **filters, size_t count, float value, bool &has_value) {
314 has_value = false;
315 for (size_t i = 0; i < count; i++)
316 filters[i]->input(value);
317 return {};
318}
319
320// TimeoutFilterBase - shared loop logic
322 // Check if timeout period has elapsed
323 // Use cached loop start time to avoid repeated millis() calls
325 if (now - this->timeout_start_time_ >= this->time_period_) {
326 // Timeout fired - get output value from derived class and output it
327 this->output(this->get_output_value());
328
329 // Disable loop until next value arrives
330 this->disable_loop();
331 }
332}
333
335
336// TimeoutFilterLast - "last" mode implementation
337optional<float> TimeoutFilterLast::new_value(float value) {
338 // Store the value to output when timeout fires
339 this->pending_value_ = value;
340
341 // Record when timeout started and enable loop
342 this->timeout_start_time_ = millis();
343 this->enable_loop();
344
345 return value;
346}
347
348// TimeoutFilterConfigured - configured value mode implementation
349optional<float> TimeoutFilterConfigured::new_value(float value) {
350 // Record when timeout started and enable loop
351 // Note: we don't store the incoming value since we have a configured value
352 this->timeout_start_time_ = millis();
353 this->enable_loop();
354
355 return value;
356}
357
358// DebounceFilter
359optional<float> DebounceFilter::new_value(float value) {
360 App.scheduler.set_timeout(this, this->time_period_, [this, value]() { this->output(value); });
361
362 return {};
363}
364
365DebounceFilter::DebounceFilter(uint32_t time_period) : time_period_(time_period) {}
366
367// HeartbeatFilter
368HeartbeatFilter::HeartbeatFilter(uint32_t time_period) : time_period_(time_period), last_input_(NAN) {}
369
370optional<float> HeartbeatFilter::new_value(float value) {
371 ESP_LOGVV(TAG, "HeartbeatFilter(%p)::new_value(value=%f)", this, value);
372 this->last_input_ = value;
373 this->has_value_ = true;
374
375 if (this->optimistic_) {
376 return value;
377 }
378 return {};
379}
380
382 Filter::initialize(parent, next);
383 App.scheduler.set_interval(this, this->time_period_, [this]() {
384 ESP_LOGVV(TAG, "HeartbeatFilter(%p)::interval(has_value=%s, last_input=%f)", this, YESNO(this->has_value_),
385 this->last_input_);
386 if (!this->has_value_)
387 return;
388
389 this->output(this->last_input_);
390 });
391}
392
393optional<float> calibrate_linear_compute(const std::array<float, 3> *functions, size_t count, float value) {
394 for (size_t i = 0; i < count; i++) {
395 if (!std::isfinite(functions[i][2]) || value < functions[i][2])
396 return (value * functions[i][0]) + functions[i][1];
397 }
398 return NAN;
399}
400
401optional<float> calibrate_polynomial_compute(const float *coefficients, size_t count, float value) {
402 float res = 0.0f;
403 float x = 1.0f;
404 for (size_t i = 0; i < count; i++) {
405 res += x * coefficients[i];
406 x *= value;
407 }
408 return res;
409}
410
411ClampFilter::ClampFilter(float min, float max, bool ignore_out_of_range)
412 : min_(min), max_(max), ignore_out_of_range_(ignore_out_of_range) {}
413optional<float> ClampFilter::new_value(float value) {
414 if (std::isfinite(this->min_) && !(value >= this->min_)) {
415 if (this->ignore_out_of_range_) {
416 return {};
417 }
418 return this->min_;
419 }
420
421 if (std::isfinite(this->max_) && !(value <= this->max_)) {
422 if (this->ignore_out_of_range_) {
423 return {};
424 }
425 return this->max_;
426 }
427 return value;
428}
429
430RoundFilter::RoundFilter(uint8_t precision) : precision_(precision) {}
431optional<float> RoundFilter::new_value(float value) {
432 if (std::isfinite(value)) {
433 float accuracy_mult = pow10_int(this->precision_);
434 return roundf(accuracy_mult * value) / accuracy_mult;
435 }
436 return value;
437}
438
439RoundMultipleFilter::RoundMultipleFilter(float multiple) : multiple_(multiple) {}
440optional<float> RoundMultipleFilter::new_value(float value) {
441 if (std::isfinite(value)) {
442 return value - remainderf(value, this->multiple_);
443 }
444 return value;
445}
446
447optional<float> ToNTCResistanceFilter::new_value(float value) {
448 if (!std::isfinite(value)) {
449 return NAN;
450 }
451 double k = 273.15;
452 // https://de.wikipedia.org/wiki/Steinhart-Hart-Gleichung#cite_note-stein2_s4-3
453 double t = value + k;
454 double y = (this->a_ - 1 / (t)) / (2 * this->c_);
455 double x = sqrt(pow(this->b_ / (3 * this->c_), 3) + y * y);
456 double resistance = exp(pow(x - y, 1 / 3.0) - pow(x + y, 1 / 3.0));
457 return resistance;
458}
459
460optional<float> ToNTCTemperatureFilter::new_value(float value) {
461 if (!std::isfinite(value)) {
462 return NAN;
463 }
464 double lr = log(double(value));
465 double v = this->a_ + this->b_ * lr + this->c_ * lr * lr * lr;
466 double temp = float(1.0 / v - 273.15);
467 return temp;
468}
469
470// StreamingFilter (base class)
471StreamingFilter::StreamingFilter(uint16_t window_size, uint16_t send_first_at)
472 : window_size_(window_size), send_first_at_(send_first_at) {}
473
474optional<float> StreamingFilter::new_value(float value) {
475 // Process the value (child class tracks min/max/sum/etc)
476 this->process_value(value);
477
478 this->count_++;
479
480 // Check if we should send (handle send_first_at for first value)
481 bool should_send = false;
482 if (this->first_send_ && this->count_ >= this->send_first_at_) {
483 should_send = true;
484 this->first_send_ = false;
485 } else if (!this->first_send_ && this->count_ >= this->window_size_) {
486 should_send = true;
487 }
488
489 if (should_send) {
490 float result = this->compute_batch_result();
491 // Reset for next batch
492 this->count_ = 0;
493 this->reset_batch();
494 ESP_LOGVV(TAG, "StreamingFilter(%p)::new_value(%f) SENDING %f", this, value, result);
495 return result;
496 }
497
498 return {};
499}
500
501// StreamingMinFilter
503 // Update running minimum (ignore NaN values)
504 if (!std::isnan(value)) {
505 this->current_min_ = std::isnan(this->current_min_) ? value : std::min(this->current_min_, value);
506 }
507}
508
510
512
513// StreamingMaxFilter
515 // Update running maximum (ignore NaN values)
516 if (!std::isnan(value)) {
517 this->current_max_ = std::isnan(this->current_max_) ? value : std::max(this->current_max_, value);
518 }
519}
520
522
524
525// StreamingMovingAverageFilter
527 // Accumulate sum (ignore NaN values)
528 if (!std::isnan(value)) {
529 this->sum_ += value;
530 this->valid_count_++;
531 }
532}
533
535 return this->valid_count_ > 0 ? this->sum_ / this->valid_count_ : NAN;
536}
537
539 this->sum_ = 0.0f;
540 this->valid_count_ = 0;
541}
542
543} // namespace esphome::sensor
544
545#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:258
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:462
void init(index_type capacity)
Allocate capacity - can only be called once.
Definition helpers.h:440
index_type size() const
Definition helpers.h:483
Fixed-capacity vector - allocates once at runtime, never reallocates This avoids std::vector template...
Definition helpers.h:529
bool empty() const
Definition helpers.h:687
size_t size() const
Definition helpers.h:686
void push_back(const T &value)
Add element without bounds checking Caller must ensure sufficient capacity was allocated via init() S...
Definition helpers.h:646
void init(size_t n)
Definition helpers.h:619
Function-pointer-only templatable storage (4 bytes on 32-bit).
Definition automation.h:40
T value(X... x) const
Definition automation.h:79
ClampFilter(float min, float max, bool ignore_out_of_range)
Definition filter.cpp:411
optional< float > new_value(float value) override
Definition filter.cpp:413
optional< float > new_value(float value) override
Definition filter.cpp:359
DebounceFilter(uint32_t time_period)
Definition filter.cpp:365
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:368
optional< float > new_value(float value) override
Definition filter.cpp:370
void initialize(Sensor *parent, Filter *next) override
Definition filter.cpp:381
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:430
optional< float > new_value(float value) override
Definition filter.cpp:431
optional< float > new_value(float value) override
Definition filter.cpp:440
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:471
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:474
void process_value(float value) override
Definition filter.cpp:514
float compute_batch_result() override
Definition filter.cpp:521
float compute_batch_result() override
Definition filter.cpp:509
void process_value(float value) override
Definition filter.cpp:502
void process_value(float value) override
Definition filter.cpp:526
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:334
optional< float > new_value(float value) override
Definition filter.cpp:349
optional< float > new_value(float value) override
Definition filter.cpp:337
optional< float > new_value(float value) override
Definition filter.cpp:447
optional< float > new_value(float value) override
Definition filter.cpp:460
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:306
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:401
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:393
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:313
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.h:41
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:752
static void uint32_t
uint32_t lr
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6