From c4e1fae544f109e6bdf684c86262bcad04814654 Mon Sep 17 00:00:00 2001 From: edennelson Date: Tue, 26 May 2026 13:17:42 -0700 Subject: [PATCH] Fix fan preset mode API usage --- components/levoit/fan/levoit_fan.cpp | 2 +- components/levoit/fan/levoit_fan.h | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/levoit/fan/levoit_fan.cpp b/components/levoit/fan/levoit_fan.cpp index 3bd9de2..7ff60c7 100644 --- a/components/levoit/fan/levoit_fan.cpp +++ b/components/levoit/fan/levoit_fan.cpp @@ -72,7 +72,7 @@ namespace esphome // Construct traits this->traits_ = fan::FanTraits(this->has_oscillating_, this->speed_count_ > 0, this->has_direction_, this->speed_count_); - this->traits_.set_supported_preset_modes(preset_modes); + this->set_supported_preset_modes(preset_modes); } diff --git a/components/levoit/fan/levoit_fan.h b/components/levoit/fan/levoit_fan.h index 97c63b3..13ab378 100644 --- a/components/levoit/fan/levoit_fan.h +++ b/components/levoit/fan/levoit_fan.h @@ -15,8 +15,11 @@ class LevoitFan final : public Component, public fan::Fan { void dump_config() override; void set_parent(Levoit *parent) { parent_ = parent; } void set_speed_count(int count) { this->speed_count_ = count; } - void set_preset_modes(std::initializer_list presets) { this->preset_modes_ = presets; } - fan::FanTraits get_traits() override { return this->traits_; } + void set_preset_modes(std::initializer_list presets) { this->set_supported_preset_modes(presets); } + fan::FanTraits get_traits() override { + this->wire_preset_modes_(this->traits_); + return this->traits_; + } void apply_device_status(int power, int speed_level, int mode); @@ -27,7 +30,6 @@ class LevoitFan final : public Component, public fan::Fan { bool has_direction_{false}; int speed_count_{0}; fan::FanTraits traits_; - std::vector preset_modes_{}; Levoit *parent_{nullptr}; };