diff --git a/components/opentherm/output/output.cpp b/components/opentherm/output/output.cpp index 872fcb8..3fab1f2 100644 --- a/components/opentherm/output/output.cpp +++ b/components/opentherm/output/output.cpp @@ -1,4 +1,4 @@ -#include "esphome/core/helpers.h" // for clamp() +#include "esphome/core/helpers.h" // for clamp() and lerp() #include "output.h" namespace esphome { @@ -6,7 +6,8 @@ namespace opentherm { void opentherm::OpenthermOutput::write_state(float state) { ESP_LOGD("opentherm.output", "Received state: %.2f. Min value: %.2f, max value: %.2f", state, min_value_, max_value_); - this->state = state < 0.003 && this->zero_means_zero_ ? 0.0 : clamp(min_value_ + state * (max_value_ - min_value_), min_value_, max_value_); + state = state < 0.003 && this->zero_means_zero_ ? 0.0 : lerp(state, min_value_, max_value_); + this->state = clamp(state, min_value_, max_value_); this->has_state_ = true; ESP_LOGD("opentherm.output", "Output %s set to %.2f", this->id_, this->state); }