ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
template_fan.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome::template_ {
7
8class TemplateFan final : public Component, public fan::Fan {
9 public:
11 void setup() override;
12 void dump_config() override;
13 void set_has_direction(bool has_direction) { this->has_direction_ = has_direction; }
14 void set_has_oscillating(bool has_oscillating) { this->has_oscillating_ = has_oscillating; }
15 void set_speed_count(int count) { this->speed_count_ = count; }
16 void set_preset_modes(std::initializer_list<const char *> presets) { this->set_supported_preset_modes(presets); }
18 this->wire_preset_modes_(this->traits_);
19 return this->traits_;
20 }
21
22 protected:
23 void control(const fan::FanCall &call) override;
24
25 bool has_oscillating_{false};
26 bool has_direction_{false};
29};
30
31} // namespace esphome::template_
void set_supported_preset_modes(std::initializer_list< const char * > preset_modes)
Set the supported preset modes (stored on Fan, referenced by FanTraits via pointer).
Definition fan.h:134
void wire_preset_modes_(FanTraits &traits)
Wire the Fan-owned preset modes pointer into the given traits object.
Definition fan.h:179
void control(const fan::FanCall &call) override
void set_has_direction(bool has_direction)
void set_has_oscillating(bool has_oscillating)
fan::FanTraits get_traits() override
void set_preset_modes(std::initializer_list< const char * > presets)