mirror of
https://github.com/esphome/esphome.git
synced 2025-08-02 00:17:48 +00:00
[sensor] Fix bug in percentage based delta filter (#8157)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
f13e742bd5
commit
0954a6185c
@ -375,13 +375,11 @@ optional<float> DeltaFilter::new_value(float value) {
|
||||
if (std::isnan(this->last_value_)) {
|
||||
return {};
|
||||
} else {
|
||||
if (this->percentage_mode_) {
|
||||
this->current_delta_ = fabsf(value * this->delta_);
|
||||
}
|
||||
return this->last_value_ = value;
|
||||
}
|
||||
}
|
||||
if (std::isnan(this->last_value_) || fabsf(value - this->last_value_) >= this->current_delta_) {
|
||||
float diff = fabsf(value - this->last_value_);
|
||||
if (std::isnan(this->last_value_) || (diff > 0.0f && diff >= this->current_delta_)) {
|
||||
if (this->percentage_mode_) {
|
||||
this->current_delta_ = fabsf(value * this->delta_);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user