mirror of
https://github.com/esphome/esphome.git
synced 2026-02-25 04:45:29 -07:00
fixed
This commit is contained in:
@@ -50,13 +50,15 @@ void FanCall::validate_() {
|
||||
}
|
||||
|
||||
if (!this->preset_mode_.empty()) {
|
||||
const auto &preset_modes = traits.supported_preset_modes();
|
||||
// Linear search is efficient for small preset mode lists (typically 2-5 items)
|
||||
bool found = false;
|
||||
for (const auto &mode : preset_modes) {
|
||||
if (mode == this->preset_mode_) {
|
||||
found = true;
|
||||
break;
|
||||
if (traits.supports_preset_modes()) {
|
||||
const auto &preset_modes = traits.supported_preset_modes();
|
||||
// Linear search is efficient for small preset mode lists (typically 2-5 items)
|
||||
for (const auto &mode : preset_modes) {
|
||||
if (mode == this->preset_mode_) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
|
||||
@@ -45,7 +45,7 @@ class FanTraits {
|
||||
/// Set the preset modes supported by the fan.
|
||||
void set_supported_preset_modes(const FixedVector<std::string> *preset_modes) { this->preset_modes_ = preset_modes; }
|
||||
/// Return if preset modes are supported
|
||||
bool supports_preset_modes() const { return !this->preset_modes_->empty(); }
|
||||
bool supports_preset_modes() const { return this->preset_modes_ != nullptr && !this->preset_modes_->empty(); }
|
||||
|
||||
protected:
|
||||
#ifdef USE_API
|
||||
|
||||
Reference in New Issue
Block a user