5static float absf(
float val) {
13 const String& config_path)
15 min_delta_{min_delta},
16 max_delta_{max_delta},
17 max_skips_{max_skips},
18 skips_(max_skips_ + 1) {
23 float delta = absf(new_value -
output_);
26 this->
emit(new_value);
40 String
const expected[] = {
"min_delta",
"max_delta",
"max_skips"};
41 for (
auto str : expected) {
42 if (!config[str].is<JsonVariant>()) {
54 return R
"###({"type":"object","properties":{"min_delta":{"title":"Minimum delta","description":"Minimum difference in change of value before forwarding","type":"number"},"max_delta":{"title":"Maximum delta","description":"Maximum difference in change of value to allow forwarding","type":"number"},"max_skips":{"title":"Max skip count","description":"Maximum number of consecutive filtered values before one is allowed through","type":"number"}}})###";
A float passthrough transform that will only pass that value through if it is "sufficiently different...
virtual bool from_json(const JsonObject &config) override
virtual void set(const float &new_value) override
ChangeFilter(float min_delta=0.0, float max_delta=9999.0, int max_skips=99, const String &config_path="")
virtual bool to_json(JsonObject &root) override
virtual bool load() override
Load and populate the object from a persistent storage.
void emit(const float &new_value)
const String ConfigSchema(const SmartSwitchController &obj)