ESPHome 2026.5.3
Loading...
Searching...
No Matches
esphome::sensor::ValueListFilter< N > Class Template Reference

Base class for filters that compare sensor values against a fixed list of configured values. More...

#include <filter.h>

Inheritance diagram for esphome::sensor::ValueListFilter< N >:
esphome::sensor::Filter esphome::sensor::FilterOutValueFilter< N > esphome::sensor::ThrottleWithPriorityFilter< N >

Protected Member Functions

 ValueListFilter (std::initializer_list< TemplatableFn< float > > values)
 
bool value_matches_any_ (float sensor_value)
 Check if sensor value matches any configured value (with accuracy rounding)
 

Protected Attributes

std::array< TemplatableFn< float >, N > values_ {}
 
- Protected Attributes inherited from esphome::sensor::Filter
friend Sensor
 
Filternext_ {nullptr}
 
Sensorparent_ {nullptr}
 

Additional Inherited Members

- Public Member Functions inherited from esphome::sensor::Filter
virtual optional< float > new_value (float value)=0
 This will be called every time the filter receives a new value.
 
virtual void initialize (Sensor *parent, Filter *next)
 Initialize this filter, please note this can be called more than once.
 
void input (float value)
 
void output (float value)
 

Detailed Description

template<size_t N>
class esphome::sensor::ValueListFilter< N >

Base class for filters that compare sensor values against a fixed list of configured values.

Templated on N (the number of values) so the list is stored inline in a std::array, avoiding heap allocation and the overhead of FixedVector.

Template Parameters
NNumber of values in the filter list, set by code generation to match the exact number of values configured in YAML.

Definition at line 344 of file filter.h.

Constructor & Destructor Documentation

◆ ValueListFilter()

template<size_t N>
esphome::sensor::ValueListFilter< N >::ValueListFilter ( std::initializer_list< TemplatableFn< float > > values)
inlineexplicitprotected

Definition at line 346 of file filter.h.

Member Function Documentation

◆ value_matches_any_()

template<size_t N>
bool esphome::sensor::ValueListFilter< N >::value_matches_any_ ( float sensor_value)
inlineprotected

Check if sensor value matches any configured value (with accuracy rounding)

Definition at line 351 of file filter.h.

Field Documentation

◆ values_

template<size_t N>
std::array<TemplatableFn<float>, N> esphome::sensor::ValueListFilter< N >::values_ {}
protected

Definition at line 355 of file filter.h.


The documentation for this class was generated from the following file: