mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-25 07:08:30 +02:00
add on/off options for uart switch (#5539)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
This commit is contained in:
@@ -13,15 +13,19 @@ class UARTSwitch : public switch_::Switch, public UARTDevice, public Component {
|
||||
public:
|
||||
void loop() override;
|
||||
|
||||
void set_data(const std::vector<uint8_t> &data) { data_ = data; }
|
||||
void set_data_on(const std::vector<uint8_t> &data) { this->data_on_ = data; }
|
||||
void set_data_off(const std::vector<uint8_t> &data) { this->data_off_ = data; }
|
||||
void set_send_every(uint32_t send_every) { this->send_every_ = send_every; }
|
||||
void set_single_state(bool single) { this->single_state_ = single; }
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
void write_command_();
|
||||
void write_command_(bool state);
|
||||
void write_state(bool state) override;
|
||||
std::vector<uint8_t> data_;
|
||||
std::vector<uint8_t> data_on_;
|
||||
std::vector<uint8_t> data_off_;
|
||||
bool single_state_{false};
|
||||
uint32_t send_every_;
|
||||
uint32_t last_transmission_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user