ESPHome  2022.1.2
demo_fan.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace demo {
8 
9 enum class DemoFanType {
10  TYPE_1,
11  TYPE_2,
12  TYPE_3,
13  TYPE_4,
14 };
15 
16 class DemoFan : public Component {
17  public:
18  void set_type(DemoFanType type) { type_ = type; }
19  void set_fan(fan::FanState *fan) { fan_ = fan; }
20  void setup() override {
21  fan::FanTraits traits{};
22 
23  // oscillation
24  // speed
25  // direction
26  // speed_count
27  switch (type_) {
29  break;
31  traits.set_oscillation(true);
32  break;
34  traits.set_direction(true);
35  traits.set_speed(true);
36  traits.set_supported_speed_count(5);
37  break;
39  traits.set_direction(true);
40  traits.set_speed(true);
41  traits.set_supported_speed_count(100);
42  traits.set_oscillation(true);
43  break;
44  }
45 
46  this->fan_->set_traits(traits);
47  }
48 
51 };
52 
53 } // namespace demo
54 } // namespace esphome
void set_fan(fan::FanState *fan)
Definition: demo_fan.h:19
fan::FanState * fan_
Definition: demo_fan.h:49
void setup() override
Definition: demo_fan.h:20
uint8_t type
DemoFanType type_
Definition: demo_fan.h:50
Library based on https://github.com/miguelbalboa/rfid and adapted to ESPHome by . ...
Definition: a4988.cpp:4
void set_type(DemoFanType type)
Definition: demo_fan.h:18