ESPHome 2025.5.0
Loading...
Searching...
No Matches
pid_climate_sensor.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
4
5namespace esphome {
6namespace pid {
7
8static const char *const TAG = "pid.sensor";
9
15 float value;
16 switch (this->type_) {
18 value = this->parent_->get_output_value();
19 break;
21 value = this->parent_->get_error_value();
22 break;
24 value = this->parent_->get_proportional_term();
25 break;
27 value = this->parent_->get_integral_term();
28 break;
30 value = this->parent_->get_derivative_term();
31 break;
33 value = clamp(this->parent_->get_output_value(), 0.0f, 1.0f);
34 break;
36 value = clamp(-this->parent_->get_output_value(), 0.0f, 1.0f);
37 break;
39 value = this->parent_->get_kp();
40 this->publish_state(value);
41 return;
43 value = this->parent_->get_ki();
44 this->publish_state(value);
45 return;
47 value = this->parent_->get_kd();
48 this->publish_state(value);
49 return;
50 default:
51 value = NAN;
52 break;
53 }
54 this->publish_state(value * 100.0f);
55}
56void PIDClimateSensor::dump_config() { LOG_SENSOR("", "PID Climate Sensor", this); }
57
58} // namespace pid
59} // namespace esphome
void add_on_pid_computed_callback(std::function< void()> &&callback)
Definition pid_climate.h:67
float get_proportional_term() const
Definition pid_climate.h:49
float get_error_value() const
Definition pid_climate.h:43
float get_derivative_term() const
Definition pid_climate.h:51
float get_integral_term() const
Definition pid_climate.h:50
float get_output_value() const
Definition pid_climate.h:42
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:39
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
Definition helpers.h:101