ESPHome 2026.11.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
7ESPHOME_LOG_TAG(TAG, "pid.sensor");
8
14 float value;
15 switch (this->type_) {
17 value = this->parent_->get_output_value() * 100.0f;
18 break;
20 value = this->parent_->get_error_value() * 100.0f;
21 break;
23 value = this->parent_->get_proportional_term() * 100.0f;
24 break;
26 value = this->parent_->get_integral_term() * 100.0f;
27 break;
29 value = this->parent_->get_derivative_term() * 100.0f;
30 break;
32 value = clamp(this->parent_->get_output_value(), 0.0f, 1.0f) * 100.0f;
33 break;
35 value = clamp(-this->parent_->get_output_value(), 0.0f, 1.0f) * 100.0f;
36 break;
38 value = this->parent_->get_kp();
39 break;
41 value = this->parent_->get_ki();
42 break;
44 value = this->parent_->get_kd();
45 break;
47 value = this->parent_->get_threshold_high();
48 break;
50 value = this->parent_->get_threshold_low();
51 break;
53 value = this->parent_->get_kp_multiplier();
54 break;
56 value = this->parent_->get_ki_multiplier();
57 break;
59 value = this->parent_->get_kd_multiplier();
60 break;
61 default:
62 value = NAN;
63 break;
64 }
65 this->publish_state(value);
66}
67void PIDClimateSensor::dump_config() { LOG_SENSOR("", "PID Climate Sensor", this); }
68
69} // namespace esphome::pid
void add_on_pid_computed_callback(F &&callback)
Definition pid_climate.h:75
float get_proportional_term() const
Definition pid_climate.h:57
float get_error_value() const
Definition pid_climate.h:51
float get_derivative_term() const
Definition pid_climate.h:59
float get_integral_term() const
Definition pid_climate.h:58
float get_output_value() const
Definition pid_climate.h:50
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:65
ESPHOME_LOG_TAG(TAG, "pid.autotune")
@ PID_SENSOR_TYPE_DEADBAND_THRESHOLD_HIGH
@ PID_SENSOR_TYPE_KI_DEADBAND_MULTIPLIER
@ PID_SENSOR_TYPE_KD_DEADBAND_MULTIPLIER
@ PID_SENSOR_TYPE_DEADBAND_THRESHOLD_LOW
@ PID_SENSOR_TYPE_KP_DEADBAND_MULTIPLIER