ESPHome 2025.5.0
Loading...
Searching...
No Matches
nextion_switch.h
Go to the documentation of this file.
1#pragma once
5#include "../nextion_base.h"
6
7namespace esphome {
8namespace nextion {
9class NextionSwitch;
10
12 public:
13 NextionSwitch(NextionBase *nextion) { this->nextion_ = nextion; }
14
15 void update() override;
16 void update_component() override { this->update(); }
17 void process_bool(const std::string &variable_name, bool on) override;
18
19 void set_state(bool state) override { this->set_state(state, true, true); }
20 void set_state(bool state, bool publish) override { this->set_state(state, publish, true); }
21 void set_state(bool state, bool publish, bool send_to_nextion) override;
22
23 void send_state_to_nextion() override { this->set_state(this->state, false, true); };
25 void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion) override {}
26 void set_state_from_int(int state_value, bool publish, bool send_to_nextion) override {
27 this->set_state(state_value != 0, publish, send_to_nextion);
28 }
29
30 protected:
31 void write_state(bool state) override;
32};
33} // namespace nextion
34} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
void set_state_from_int(int state_value, bool publish, bool send_to_nextion) override
NextionQueueType get_queue_type() override
void write_state(bool state) override
void process_bool(const std::string &variable_name, bool on) override
NextionSwitch(NextionBase *nextion)
void set_state(bool state) override
void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion) override
void set_state(bool state, bool publish) override
Base class for all switches.
Definition switch.h:39
bool state
The current reported state of the binary sensor.
Definition switch.h:53
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7