mirror of
https://github.com/esphome/esphome.git
synced 2024-12-26 07:24:54 +01:00
Sensor filter_out rounded (#765)
Fixes https://github.com/esphome/issues/issues/741
This commit is contained in:
parent
8292024306
commit
ee0b6e835f
1 changed files with 5 additions and 1 deletions
|
@ -166,7 +166,11 @@ optional<float> FilterOutValueFilter::new_value(float value) {
|
|||
else
|
||||
return value;
|
||||
} else {
|
||||
if (value == this->value_to_filter_out_)
|
||||
int8_t accuracy = this->parent_->get_accuracy_decimals();
|
||||
float accuracy_mult = pow10f(accuracy);
|
||||
float rounded_filter_out = roundf(accuracy_mult * this->value_to_filter_out_);
|
||||
float rounded_value = roundf(accuracy_mult * value);
|
||||
if (rounded_filter_out == rounded_value)
|
||||
return {};
|
||||
else
|
||||
return value;
|
||||
|
|
Loading…
Reference in a new issue