mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-07 13:24:56 +02:00
Thermostat enhancements and code clean-up (#2073)
This commit is contained in:
@@ -17,7 +17,10 @@ struct ThermostatClimateTargetTempConfig {
|
||||
float default_temperature{NAN};
|
||||
float default_temperature_low{NAN};
|
||||
float default_temperature_high{NAN};
|
||||
float hysteresis{NAN};
|
||||
float cool_deadband_{NAN};
|
||||
float cool_overrun_{NAN};
|
||||
float heat_deadband_{NAN};
|
||||
float heat_overrun_{NAN};
|
||||
};
|
||||
|
||||
class ThermostatClimate : public climate::Climate, public Component {
|
||||
@@ -27,13 +30,18 @@ class ThermostatClimate : public climate::Climate, public Component {
|
||||
void dump_config() override;
|
||||
|
||||
void set_default_mode(climate::ClimateMode default_mode);
|
||||
void set_hysteresis(float hysteresis);
|
||||
void set_set_point_minimum_differential(float differential);
|
||||
void set_cool_deadband(float deadband);
|
||||
void set_cool_overrun(float overrun);
|
||||
void set_heat_deadband(float deadband);
|
||||
void set_heat_overrun(float overrun);
|
||||
void set_sensor(sensor::Sensor *sensor);
|
||||
void set_supports_auto(bool supports_auto);
|
||||
void set_supports_heat_cool(bool supports_heat_cool);
|
||||
void set_supports_cool(bool supports_cool);
|
||||
void set_supports_dry(bool supports_dry);
|
||||
void set_supports_fan_only(bool supports_fan_only);
|
||||
void set_supports_fan_only_cooling(bool supports_fan_only_cooling);
|
||||
void set_supports_heat(bool supports_heat);
|
||||
void set_supports_fan_mode_on(bool supports_fan_mode_on);
|
||||
void set_supports_fan_mode_off(bool supports_fan_mode_off);
|
||||
@@ -78,10 +86,19 @@ class ThermostatClimate : public climate::Climate, public Component {
|
||||
Trigger<> *get_swing_mode_off_trigger() const;
|
||||
Trigger<> *get_swing_mode_vertical_trigger() const;
|
||||
Trigger<> *get_temperature_change_trigger() const;
|
||||
/// Get current hysteresis value
|
||||
float hysteresis();
|
||||
/// Get current hysteresis values
|
||||
float cool_deadband();
|
||||
float cool_overrun();
|
||||
float heat_deadband();
|
||||
float heat_overrun();
|
||||
/// Call triggers based on updated climate states (modes/actions)
|
||||
void refresh();
|
||||
/// Set point and hysteresis validation
|
||||
bool hysteresis_valid(); // returns true if valid
|
||||
void validate_target_temperature();
|
||||
void validate_target_temperatures();
|
||||
void validate_target_temperature_low();
|
||||
void validate_target_temperature_high();
|
||||
|
||||
protected:
|
||||
/// Override control to change settings of the climate device.
|
||||
@@ -111,6 +128,11 @@ class ThermostatClimate : public climate::Climate, public Component {
|
||||
/// Check if the temperature change trigger should be called.
|
||||
void check_temperature_change_trigger_();
|
||||
|
||||
/// Check if cooling/fanning/heating actions are required; returns true if so
|
||||
bool cooling_required_();
|
||||
bool fanning_required_();
|
||||
bool heating_required_();
|
||||
|
||||
/// The sensor used for getting the current temperature
|
||||
sensor::Sensor *sensor_{nullptr};
|
||||
|
||||
@@ -124,6 +146,8 @@ class ThermostatClimate : public climate::Climate, public Component {
|
||||
bool supports_dry_{false};
|
||||
bool supports_fan_only_{false};
|
||||
bool supports_heat_{false};
|
||||
/// Special flag -- enables fan to be switched based on target_temperature_high
|
||||
bool supports_fan_only_cooling_{false};
|
||||
|
||||
/// Whether the controller supports turning on or off just the fan.
|
||||
///
|
||||
@@ -278,8 +302,14 @@ class ThermostatClimate : public climate::Climate, public Component {
|
||||
ThermostatClimateTargetTempConfig normal_config_{};
|
||||
ThermostatClimateTargetTempConfig away_config_{};
|
||||
|
||||
/// Hysteresis value used for computing climate actions
|
||||
float hysteresis_{0};
|
||||
/// Minimum differential required between set points
|
||||
float set_point_minimum_differential_{0};
|
||||
|
||||
/// Hysteresis values used for computing climate actions
|
||||
float cool_deadband_{0};
|
||||
float cool_overrun_{0};
|
||||
float heat_deadband_{0};
|
||||
float heat_overrun_{0};
|
||||
|
||||
/// setup_complete_ blocks modifying/resetting the temps immediately after boot
|
||||
bool setup_complete_{false};
|
||||
|
||||
Reference in New Issue
Block a user