diff --git a/esphome/components/climate/climate_traits.h b/esphome/components/climate/climate_traits.h index b9789d9ccb..f0e0dbe02b 100644 --- a/esphome/components/climate/climate_traits.h +++ b/esphome/components/climate/climate_traits.h @@ -131,6 +131,9 @@ class ClimateTraits { void set_supported_custom_fan_modes(const std::vector &modes) { this->supported_custom_fan_modes_ = modes; } + template void set_supported_custom_fan_modes(const char *const (&modes)[N]) { + this->supported_custom_fan_modes_.assign(modes, modes + N); + } const std::vector &get_supported_custom_fan_modes() const { return this->supported_custom_fan_modes_; } bool supports_custom_fan_mode(const std::string &custom_fan_mode) const { for (const char *mode : this->supported_custom_fan_modes_) { @@ -152,6 +155,9 @@ class ClimateTraits { void set_supported_custom_presets(const std::vector &presets) { this->supported_custom_presets_ = presets; } + template void set_supported_custom_presets(const char *const (&presets)[N]) { + this->supported_custom_presets_.assign(presets, presets + N); + } const std::vector &get_supported_custom_presets() const { return this->supported_custom_presets_; } bool supports_custom_preset(const std::string &custom_preset) const { for (const char *preset : this->supported_custom_presets_) {