ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
climate_traits.cpp
Go to the documentation of this file.
1#include "climate_traits.h"
2
3namespace esphome::climate {
4
5// Compat: shared empty vector for getters when no custom modes are set.
6// Remove in 2026.11.0 when deprecated ClimateTraits setters are removed
7// and getters can return const vector * instead of const vector &.
8static const std::vector<const char *> EMPTY_CUSTOM_MODES; // NOLINT
9
10const std::vector<const char *> &ClimateTraits::get_supported_custom_fan_modes() const {
12 return *this->supported_custom_fan_modes_;
13 }
14 // Compat: fall back to owned vector from deprecated setters. Remove in 2026.11.0.
15 if (!this->compat_custom_fan_modes_.empty()) {
16 return this->compat_custom_fan_modes_;
17 }
18 return EMPTY_CUSTOM_MODES;
19}
20
21const std::vector<const char *> &ClimateTraits::get_supported_custom_presets() const {
22 if (this->supported_custom_presets_) {
23 return *this->supported_custom_presets_;
24 }
25 // Compat: fall back to owned vector from deprecated setters. Remove in 2026.11.0.
26 if (!this->compat_custom_presets_.empty()) {
27 return this->compat_custom_presets_;
28 }
29 return EMPTY_CUSTOM_MODES;
30}
31
35
39
40} // namespace esphome::climate
const std::vector< const char * > * supported_custom_presets_
const std::vector< const char * > & get_supported_custom_fan_modes() const
const std::vector< const char * > * supported_custom_fan_modes_
Custom mode storage - pointers to vectors owned by the Climate base class.
int8_t get_target_temperature_accuracy_decimals() const
int8_t get_current_temperature_accuracy_decimals() const
const std::vector< const char * > & get_supported_custom_presets() const
std::vector< const char * > compat_custom_presets_
std::vector< const char * > compat_custom_fan_modes_
int8_t step_to_accuracy_decimals(float step)
Derive accuracy in decimals from an increment step.
Definition helpers.cpp:570