ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
pid_climate_sensor.cpp
Go to the documentation of this file.
3#include "esphome/core/log.h"
4
5namespace esphome::pid {
6
7static const char *const TAG = "pid.sensor";
8
14 float value;
15 switch (this->type_) {
17 value = this->parent_->get_output_value();
18 break;
20 value = this->parent_->get_error_value();
21 break;
23 value = this->parent_->get_proportional_term();
24 break;
26 value = this->parent_->get_integral_term();
27 break;
29 value = this->parent_->get_derivative_term();
30 break;
32 value = clamp(this->parent_->get_output_value(), 0.0f, 1.0f);
33 break;
35 value = clamp(-this->parent_->get_output_value(), 0.0f, 1.0f);
36 break;
38 value = this->parent_->get_kp();
39 this->publish_state(value);
40 return;
42 value = this->parent_->get_ki();
43 this->publish_state(value);
44 return;
46 value = this->parent_->get_kd();
47 this->publish_state(value);
48 return;
49 default:
50 value = NAN;
51 break;
52 }
53 this->publish_state(value * 100.0f);
54}
55void PIDClimateSensor::dump_config() { LOG_SENSOR("", "PID Climate Sensor", this); }
56
57} // namespace esphome::pid
void add_on_pid_computed_callback(F &&callback)
Definition pid_climate.h:74
float get_proportional_term() const
Definition pid_climate.h:56
float get_error_value() const
Definition pid_climate.h:50
float get_derivative_term() const
Definition pid_climate.h:58
float get_integral_term() const
Definition pid_climate.h:57
float get_output_value() const
Definition pid_climate.h:49
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68