55#include " esphome/components/text_sensor/text_sensor.h"
66#include " ../sec_touch.h"
77#include " _fan_mode.h"
8- #include < vector>
98
109namespace esphome {
1110namespace sec_touch {
@@ -21,7 +20,6 @@ class SecTouchFan : public Component, public fan::Fan {
2120 static FanModeEnum::FanMode calculate_mode_from_speed (int speed);
2221 void update_label_mode ();
2322 void turn_off_sec_touch_hardware_fan ();
24- fan::FanTraits traits_;
2523 /* *
2624 * Will return `true` if an assignment was done so a call to publish is needed.
2725 */
@@ -30,17 +28,13 @@ class SecTouchFan : public Component, public fan::Fan {
3028 public:
3129 SecTouchFan (SECTouchComponent *parent, int level_id, int label_id);
3230
33- void setup () override {
34- this ->traits_ = fan::FanTraits (false , true , false , 11 );
35- std::vector<const char *> preset_modes;
36- for (auto str_view : FanModeEnum::getStringValues ()) {
37- preset_modes.push_back (str_view.data ());
38- }
39-
40- this ->traits_ .set_supported_preset_modes (preset_modes);
41- }
31+ void setup () override { this ->set_supported_preset_modes (FanModeEnum::getPresetModePointers ()); }
4232 // From Fan
43- fan::FanTraits get_traits () override { return this ->traits_ ; }
33+ fan::FanTraits get_traits () override {
34+ auto traits = fan::FanTraits (false , true , false , 11 );
35+ this ->wire_preset_modes_ (traits);
36+ return traits;
37+ }
4438
4539 // Print method for debugging
4640 void dump_config () override ;
0 commit comments