ESPHome  2022.12.8
uart_switch.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 #include <vector>
8 
9 namespace esphome {
10 namespace uart {
11 
12 class UARTSwitch : public switch_::Switch, public UARTDevice, public Component {
13  public:
14  void loop() override;
15 
16  void set_data(const std::vector<uint8_t> &data) { data_ = data; }
17  void set_send_every(uint32_t send_every) { this->send_every_ = send_every; }
18 
19  void dump_config() override;
20 
21  protected:
22  void write_command_();
23  void write_state(bool state) override;
24  std::vector<uint8_t> data_;
25  uint32_t send_every_;
27 };
28 
29 } // namespace uart
30 } // namespace esphome
Base class for all switches.
Definition: switch.h:32
void set_send_every(uint32_t send_every)
Definition: uart_switch.h:17
void set_data(const std::vector< uint8_t > &data)
Definition: uart_switch.h:16
void dump_config() override
Definition: uart_switch.cpp:39
std::vector< uint8_t > data_
Definition: uart_switch.h:24
void loop() override
Definition: uart_switch.cpp:9
Definition: a4988.cpp:4
void write_state(bool state) override
Definition: uart_switch.cpp:24
bool state
The current reported state of the binary sensor.
Definition: switch.h:47