timeout filter: return value (#5612)

This commit is contained in:
Jesse Hills 2023-10-27 16:36:54 +13:00 committed by GitHub
parent 535568e065
commit 0c5d5cd623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,8 @@
#include "filter.h"
#include <cmath>
#include "esphome/core/hal.h"
#include "esphome/core/log.h"
#include "sensor.h"
#include <cmath>
namespace esphome {
namespace sensor {
@ -376,9 +376,7 @@ void OrFilter::initialize(Sensor *parent, Filter *next) {
// TimeoutFilter
optional<float> TimeoutFilter::new_value(float value) {
this->set_timeout("timeout", this->time_period_, [this]() { this->output(this->value_); });
this->output(value);
return {};
return value;
}
TimeoutFilter::TimeoutFilter(uint32_t time_period, float new_value) : time_period_(time_period), value_(new_value) {}