Thermostat remove deprecated config (#3643)

* Raise errors for all the now deprecated options

* Fix CONF_DEFAULT_PRESET detection

* Stop attempting to set the non-existent normal_config

* Add support for default presets

* Fix correct detection of Two Point temperature mode

* Fix lint issues

* Fix tests

* Generate correct yaml for equivalent configurations

* Remove debug code

* Only set default preset if the thermostat does not have state to restore

* Add restore_default_preset_on_boot option
If set to True then the default_preset will be applied on every boot. If False (Default) state will be restored from memory as per prior versions

* Apply lint suggestions

* Switch from restore_default_preset_on_boot to an enum for startup_behavior
This gives better self-documentation as well as the option for extending to other options down the track

* Lint fixes

* Rename startup_behavior to on_boot_restore_from
This removes any issues with different English locales

* Fix comparable_preset yaml output alignment

* Add dump of on_boot_restore_from setting

Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
This commit is contained in:
Michael Davidson
2022-09-26 12:59:04 +10:00
committed by GitHub
parent ce2e161b08
commit 8095db6715
4 changed files with 161 additions and 69 deletions
@@ -22,6 +22,7 @@ enum ThermostatClimateTimerIndex : size_t {
TIMER_IDLE_ON = 9,
};
enum OnBootRestoreFrom : size_t { MEMORY = 0, DEFAULT_PRESET = 1 };
struct ThermostatClimateTimer {
const std::string name;
bool active;
@@ -57,7 +58,9 @@ class ThermostatClimate : public climate::Climate, public Component {
void setup() override;
void dump_config() override;
void set_default_mode(climate::ClimateMode default_mode);
void set_default_preset(const std::string &custom_preset);
void set_default_preset(climate::ClimatePreset preset);
void set_on_boot_restore_from(thermostat::OnBootRestoreFrom on_boot_restore_from);
void set_set_point_minimum_differential(float differential);
void set_cool_deadband(float deadband);
void set_cool_overrun(float overrun);
@@ -225,7 +228,8 @@ class ThermostatClimate : public climate::Climate, public Component {
bool supplemental_cooling_required_();
bool supplemental_heating_required_();
void dump_preset_config_(const std::string &preset_name, const ThermostatClimateTargetTempConfig &config);
void dump_preset_config_(const std::string &preset_name, const ThermostatClimateTargetTempConfig &config,
bool is_default_preset);
/// The sensor used for getting the current temperature
sensor::Sensor *sensor_{nullptr};
@@ -397,7 +401,6 @@ class ThermostatClimate : public climate::Climate, public Component {
/// These are used to determine when a trigger/action needs to be called
climate::ClimateAction supplemental_action_{climate::CLIMATE_ACTION_OFF};
climate::ClimateFanMode prev_fan_mode_{climate::CLIMATE_FAN_ON};
climate::ClimateMode default_mode_{climate::CLIMATE_MODE_OFF};
climate::ClimateMode prev_mode_{climate::CLIMATE_MODE_OFF};
climate::ClimateSwingMode prev_swing_mode_{climate::CLIMATE_SWING_OFF};
@@ -441,6 +444,15 @@ class ThermostatClimate : public climate::Climate, public Component {
std::map<climate::ClimatePreset, ThermostatClimateTargetTempConfig> preset_config_{};
/// The set of custom preset configurations this thermostat supports (eg. "My Custom Preset")
std::map<std::string, ThermostatClimateTargetTempConfig> custom_preset_config_{};
/// Default standard preset to use on start up
climate::ClimatePreset default_preset_{};
/// Default custom preset to use on start up
std::string default_custom_preset_{};
/// If set to DEFAULT_PRESET then the default preset is always used. When MEMORY prior
/// state will attempt to be restored if possible
thermostat::OnBootRestoreFrom on_boot_restore_from_{thermostat::OnBootRestoreFrom::MEMORY};
};
} // namespace thermostat