7static const char *
const TAG =
"pid.climate";
29 if (restore.has_value()) {
30 restore->to_call(
this).perform();
44 if (
call.get_mode().has_value())
46 if (
call.get_target_temperature().has_value())
75 LOG_CLIMATE(
"",
"PID Climate",
this);
76 ESP_LOGCONFIG(TAG,
" Control Parameters:");
81 ESP_LOGCONFIG(TAG,
" Deadband disabled.");
83 ESP_LOGCONFIG(TAG,
" Deadband Parameters:");
84 ESP_LOGCONFIG(TAG,
" threshold: %0.5f to %0.5f, multipliers(kp: %.5f, ki: %.5f, kd: %.5f), output samples: %d",
120 if (new_action != this->
action) {
121 this->
action = new_action;
139 if (res.result_params.has_value()) {
163 this->
autotuner_->config(min_value, max_value);
167 "%s: Autotune has started. This can take a long time depending on the "
168 "responsiveness of your system. Your system "
169 "output will be altered to deliberately oscillate above and below the setpoint multiple times. "
170 "Until your sensor provides a reading, the autotuner may display \'nan\'",
173 this->
set_interval(
"autotune-progress", 10000, [
this]() {
179 ESP_LOGW(TAG,
"%s: !!! For PID autotuner you need to set AUTO (also called heat/cool) mode!",
void set_interval(const std::string &name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
std::string get_object_id() const
This class is used to encode all control actions on a climate device.
const optional< float > & get_target_temperature() const
const optional< ClimateMode > & get_mode() const
ClimateMode mode
The active mode of the climate device.
float target_temperature
The target temperature of the climate device.
float current_humidity
The current humidity of the climate device, as reported from the integration.
float current_temperature
The current temperature of the climate device, as reported from the integration.
ClimateAction action
The active state of the climate device.
void publish_state()
Publish the state of the climate device, to be called from integrations.
optional< ClimateDeviceRestoreState > restore_state_()
Restore the state of the climate device, call this from your setup() method.
This class contains all static data for climate devices.
void set_supported_modes(std::set< ClimateMode > modes)
void set_supports_action(bool supports_action)
void set_supports_current_humidity(bool supports_current_humidity)
void set_supports_two_point_target_temperature(bool supports_two_point_target_temperature)
void add_supported_mode(ClimateMode mode)
void set_supports_current_temperature(bool supports_current_temperature)
void set_level(float state)
Set the level of this float output, this is called from the front-end.
void start_autotune(std::unique_ptr< PIDAutotuner > &&autotune)
PIDController controller_
output::FloatOutput * cool_output_
sensor::Sensor * sensor_
The sensor used for getting the current temperature.
void dump_config() override
bool supports_cool_() const
void write_output_(float value)
float default_target_temperature_
void reset_integral_term()
std::unique_ptr< PIDAutotuner > autotuner_
void control(const climate::ClimateCall &call) override
Override control to change settings of the climate device.
CallbackManager< void()> pid_computed_callback_
float output_value_
Output value as reported by the PID controller, for PIDClimateSensor.
sensor::Sensor * humidity_sensor_
The sensor used for getting the current humidity.
climate::ClimateTraits traits() override
Return the traits of this controller.
bool supports_heat_() const
output::FloatOutput * heat_output_
void add_on_state_callback(std::function< void(float)> &&callback)
Add a callback that will be called every time a filtered value arrives.
float state
This member variable stores the last state that has passed through all filters.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
ClimateAction
Enum for the current action of the climate device. Values match those of ClimateMode.
@ CLIMATE_ACTION_OFF
The climate device is off (inactive or no power)
@ CLIMATE_ACTION_IDLE
The climate device is idle (monitoring climate but no action needed)
@ CLIMATE_ACTION_HEATING
The climate device is actively heating.
@ CLIMATE_ACTION_COOLING
The climate device is actively cooling.
Providing packet encoding functions for exchanging data with a remote host.
void reset_accumulated_integral()
float update(float setpoint, float process_value)