ESPHome 2025.5.0
Loading...
Searching...
No Matches
nextion_sensor.h
Go to the documentation of this file.
1#pragma once
5#include "../nextion_base.h"
6
7namespace esphome {
8namespace nextion {
9class NextionSensor;
10
12 public:
13 NextionSensor(NextionBase *nextion) { this->nextion_ = nextion; }
14 void send_state_to_nextion() override { this->set_state(this->state, false, true); };
15
16 void update_component() override { this->update(); }
17 void update() override;
18 void add_to_wave_buffer(float state);
19 void set_precision(uint8_t precision) { this->precision_ = precision; }
20 void set_component_id(uint8_t component_id) { component_id_ = component_id; }
21 void set_wave_channel_id(uint8_t wave_chan_id) { this->wave_chan_id_ = wave_chan_id; }
22 void set_wave_max_value(uint32_t wave_maxvalue) { this->wave_maxvalue_ = wave_maxvalue; }
23 void process_sensor(const std::string &variable_name, int state) override;
24
25 void set_state(float state) override { this->set_state(state, true, true); }
26 void set_state(float state, bool publish) override { this->set_state(state, publish, true); }
27 void set_state(float state, bool publish, bool send_to_nextion) override;
28
29 void set_waveform_send_last_value(bool send_last_value) { this->send_last_value_ = send_last_value; }
30 uint8_t get_wave_chan_id() { return this->wave_chan_id_; }
31 void set_wave_max_length(int wave_max_length) { this->wave_max_length_ = wave_max_length; }
35 void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion) override {}
36 void set_state_from_int(int state_value, bool publish, bool send_to_nextion) override {
37 this->set_state(state_value, publish, send_to_nextion);
38 }
39
40 protected:
41 uint8_t precision_ = 0;
42 uint32_t wave_maxvalue_ = 255;
43
44 float last_value_ = 0;
45 bool send_last_value_ = true;
46 void wave_update_();
47};
48} // namespace nextion
49} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
void set_state(float state, bool publish) override
void set_wave_max_length(int wave_max_length)
void set_wave_max_value(uint32_t wave_maxvalue)
void set_component_id(uint8_t component_id)
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_waveform_send_last_value(bool send_last_value)
NextionSensor(NextionBase *nextion)
void set_wave_channel_id(uint8_t wave_chan_id)
void set_precision(uint8_t precision)
NextionQueueType get_queue_type() override
void set_state(float state) override
void process_sensor(const std::string &variable_name, int state) override
Base-class for all sensors.
Definition sensor.h:57
float state
This member variable stores the last state that has passed through all filters.
Definition sensor.h:131
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7