Skip to content

Commit a116c8b

Browse files
authored
Merge pull request #15 from distante/ssd/update_to_esphome_2026.4
Ssd/update to esphome 2026.4
2 parents 1341465 + 2e0b379 commit a116c8b

5 files changed

Lines changed: 21 additions & 13 deletions

File tree

.github/instructions/sec-touch.intructions.md

Whitespace-only changes.

components/sec_touch/fan/_fan_mode.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,14 @@ int FanModeEnum::get_start_speed(FanMode mode) {
6666
return pair.second.start_speed;
6767
}
6868
return 0;
69+
}
70+
71+
const std::vector<const char *> &FanModeEnum::getPresetModePointers() {
72+
static std::vector<const char *> pointers;
73+
if (pointers.empty()) {
74+
for (const auto &pair : getFanModeList()) {
75+
pointers.push_back(pair.second.str.data());
76+
}
77+
}
78+
return pointers;
6979
}

components/sec_touch/fan/_fan_mode.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class FanModeEnum {
2828
// Get a list of string values dynamically from the list
2929
static std::vector<std::string_view> getStringValues();
3030

31+
// Returns a stable const char* vector for Fan::set_supported_preset_modes().
32+
// Built once from static string literals in FanModeList and cached for the program lifetime.
33+
static const std::vector<const char *> &getPresetModePointers();
34+
3135
static FanMode get_fan_mode_fromSpeed(int speed);
3236

3337
static int get_start_speed(FanMode mode);

components/sec_touch/fan/sec_touch_fan.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "esphome/components/text_sensor/text_sensor.h"
66
#include "../sec_touch.h"
77
#include "_fan_mode.h"
8-
#include <vector>
98

109
namespace esphome {
1110
namespace 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;

esphome

Submodule esphome updated 2206 files

0 commit comments

Comments
 (0)