ESPHome  2024.12.2
output.cpp
Go to the documentation of this file.
1 #include "esphome/core/helpers.h" // for clamp() and lerp()
2 #include "output.h"
3 
4 namespace esphome {
5 namespace opentherm {
6 
7 static const char *const TAG = "opentherm.output";
8 
10  ESP_LOGD(TAG, "Received state: %.2f. Min value: %.2f, max value: %.2f", state, min_value_, max_value_);
11  this->state = state < 0.003 && this->zero_means_zero_
12  ? 0.0
13  : clamp(lerp(state, min_value_, max_value_), min_value_, max_value_);
14  this->has_state_ = true;
15  ESP_LOGD(TAG, "Output %s set to %.2f", this->id_, this->state);
16 }
17 } // namespace opentherm
18 } // namespace esphome
float lerp(float completion, float start, float end)
Linearly interpolate between start and end by completion (between 0 and 1).
Definition: helpers.cpp:94
void write_state(float state) override
Definition: output.cpp:9
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
Definition: helpers.h:93
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool state
Definition: fan.h:34