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