ESPHome 2025.5.0
Loading...
Searching...
No Matches
nextion_binarysensor.h
Go to the documentation of this file.
1#pragma once
5#include "../nextion_base.h"
6
7namespace esphome {
8namespace nextion {
9class NextionBinarySensor;
10
13 public PollingComponent {
14 public:
15 NextionBinarySensor(NextionBase *nextion) { this->nextion_ = nextion; }
16
17 void update_component() override { this->update(); }
18 void update() override;
19 void send_state_to_nextion() override { this->set_state(this->state, false); };
20 void process_bool(const std::string &variable_name, bool state) override;
21 void process_touch(uint8_t page_id, uint8_t component_id, bool state) override;
22
23 // Set the components page id for Nextion Touch Component
24 void set_page_id(uint8_t page_id) { page_id_ = page_id; }
25 // Set the components component id for Nextion Touch Component
26 void set_component_id(uint8_t component_id) { component_id_ = component_id; }
27
28 void set_state(bool state) override { this->set_state(state, true, true); }
29 void set_state(bool state, bool publish) override { this->set_state(state, publish, true); }
30 void set_state(bool state, bool publish, bool send_to_nextion) override;
31
33 void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion) override {}
34 void set_state_from_int(int state_value, bool publish, bool send_to_nextion) override {
35 this->set_state(state_value != 0, publish, send_to_nextion);
36 }
37
38 protected:
39 uint8_t page_id_;
40};
41} // namespace nextion
42} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
bool state
The current reported state of the binary sensor.
NextionQueueType get_queue_type() override
void set_state_from_int(int state_value, bool publish, bool send_to_nextion) 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
void set_component_id(uint8_t component_id)
void process_bool(const std::string &variable_name, bool state) override
void process_touch(uint8_t page_id, uint8_t component_id, bool state) override
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7