ESPHome 2025.5.0
Loading...
Searching...
No Matches
uart_switch.h
Go to the documentation of this file.
1#pragma once
2
6
7#include <cinttypes>
8#include <vector>
9
10namespace esphome {
11namespace uart {
12
13class UARTSwitch : public switch_::Switch, public UARTDevice, public Component {
14 public:
15 void loop() override;
16
17 void set_data_on(const std::vector<uint8_t> &data) { this->data_on_ = data; }
18 void set_data_off(const std::vector<uint8_t> &data) { this->data_off_ = data; }
19 void set_send_every(uint32_t send_every) { this->send_every_ = send_every; }
20 void set_single_state(bool single) { this->single_state_ = single; }
21
22 void dump_config() override;
23
24 protected:
25 void write_command_(bool state);
26 void write_state(bool state) override;
27 std::vector<uint8_t> data_on_;
28 std::vector<uint8_t> data_off_;
29 bool single_state_{false};
30 uint32_t send_every_;
32};
33
34} // namespace uart
35} // namespace esphome
Base class for all switches.
Definition switch.h:39
bool state
The current reported state of the binary sensor.
Definition switch.h:53
std::vector< uint8_t > data_off_
Definition uart_switch.h:28
void write_state(bool state) override
void write_command_(bool state)
std::vector< uint8_t > data_on_
Definition uart_switch.h:27
void dump_config() override
void set_data_off(const std::vector< uint8_t > &data)
Definition uart_switch.h:18
void set_single_state(bool single)
Definition uart_switch.h:20
void set_data_on(const std::vector< uint8_t > &data)
Definition uart_switch.h:17
void set_send_every(uint32_t send_every)
Definition uart_switch.h:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7