ESPHome  2024.11.3
demo_number.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace demo {
8 
9 enum class DemoNumberType {
10  TYPE_1,
11  TYPE_2,
12  TYPE_3,
13 };
14 
15 class DemoNumber : public number::Number, public Component {
16  public:
17  void set_type(DemoNumberType type) { type_ = type; }
18  void setup() override {
19  switch (type_) {
21  this->publish_state(50);
22  break;
24  this->publish_state(-10);
25  break;
27  this->publish_state(42);
28  break;
29  }
30  }
31 
32  protected:
33  void control(float value) override { this->publish_state(value); }
34 
36 };
37 
38 } // namespace demo
39 } // namespace esphome
void control(float value) override
Definition: demo_number.h:33
DemoNumberType type_
Definition: demo_number.h:35
void setup() override
Definition: demo_number.h:18
Base-class for all numbers.
Definition: number.h:39
uint8_t type
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_type(DemoNumberType type)
Definition: demo_number.h:17