mirror of
https://github.com/esphome/esphome.git
synced 2025-10-31 23:21:54 +00:00
preen
This commit is contained in:
@@ -321,9 +321,15 @@ climate::ClimateTraits ThermostatClimate::traits() {
|
||||
for (auto &it : this->preset_config_) {
|
||||
traits.add_supported_preset(it.first);
|
||||
}
|
||||
for (auto &it : this->custom_preset_config_) {
|
||||
traits.add_supported_custom_preset(it.first);
|
||||
|
||||
// Custom presets and fan modes are set directly from Python (includes all non-standard preset names from map)
|
||||
if (!this->additional_custom_presets_.empty()) {
|
||||
traits.set_supported_custom_presets(this->additional_custom_presets_);
|
||||
}
|
||||
if (!this->additional_custom_fan_modes_.empty()) {
|
||||
traits.set_supported_custom_fan_modes(this->additional_custom_fan_modes_);
|
||||
}
|
||||
|
||||
return traits;
|
||||
}
|
||||
|
||||
@@ -1613,6 +1619,14 @@ void ThermostatClimate::dump_config() {
|
||||
}
|
||||
}
|
||||
|
||||
void ThermostatClimate::set_custom_fan_modes(std::initializer_list<const char *> custom_fan_modes) {
|
||||
this->additional_custom_fan_modes_ = custom_fan_modes;
|
||||
}
|
||||
|
||||
void ThermostatClimate::set_custom_presets(std::initializer_list<const char *> custom_presets) {
|
||||
this->additional_custom_presets_ = custom_presets;
|
||||
}
|
||||
|
||||
ThermostatClimateTargetTempConfig::ThermostatClimateTargetTempConfig() = default;
|
||||
|
||||
ThermostatClimateTargetTempConfig::ThermostatClimateTargetTempConfig(float default_temperature)
|
||||
|
||||
@@ -133,6 +133,8 @@ class ThermostatClimate : public climate::Climate, public Component {
|
||||
|
||||
void set_preset_config(climate::ClimatePreset preset, const ThermostatClimateTargetTempConfig &config);
|
||||
void set_custom_preset_config(const std::string &name, const ThermostatClimateTargetTempConfig &config);
|
||||
void set_custom_fan_modes(std::initializer_list<const char *> custom_fan_modes);
|
||||
void set_custom_presets(std::initializer_list<const char *> custom_presets);
|
||||
|
||||
Trigger<> *get_cool_action_trigger() const;
|
||||
Trigger<> *get_supplemental_cool_action_trigger() const;
|
||||
@@ -537,6 +539,10 @@ 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_{};
|
||||
/// Custom fan mode names (from Python codegen)
|
||||
std::vector<const char *> additional_custom_fan_modes_{};
|
||||
/// Custom preset names (from Python codegen)
|
||||
std::vector<const char *> additional_custom_presets_{};
|
||||
};
|
||||
|
||||
} // namespace thermostat
|
||||
|
||||
@@ -45,7 +45,9 @@ async def test_climate_custom_fan_modes_and_presets(
|
||||
f"Expected 3 custom presets, got {len(custom_presets)}: {custom_presets}"
|
||||
)
|
||||
assert "Eco Plus" in custom_presets, "Expected 'Eco Plus' in custom presets"
|
||||
assert "Comfort" in custom_presets, "Expected 'Comfort' in custom presets"
|
||||
assert "Super Saver" in custom_presets, (
|
||||
"Expected 'Super Saver' in custom presets"
|
||||
)
|
||||
assert "Vacation Mode" in custom_presets, (
|
||||
"Expected 'Vacation Mode' in custom presets"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user