Compare commits

...
Author SHA1 Message Date
J. Nick Koston e270ba85e5 Merge remote-tracking branch 'origin/dev' into nextion-tables-progmem
# Conflicts:
#	esphome/components/nextion/nextion_component_base.h
2026-10-21 07:25:33 -10:00
J. Nick Koston c18a0003de Merge remote-tracking branch 'origin/dev' into nextion-tables-progmem
# Conflicts:
#	esphome/components/nextion/nextion.cpp
2026-10-20 09:59:38 -10:00
J. Nick Koston ac7c67d4a8 Merge remote-tracking branch 'origin/dev' into nextion-tables-progmem 2026-10-13 10:44:41 -10:00
J. Nick Koston 88be4c0389 [nextion] Keep the queue type name table in flash 2026-10-13 10:03:23 -10:00
3 changed files with 20 additions and 9 deletions
+6 -5
View File
@@ -336,7 +336,7 @@ void Nextion::print_queue_members_() {
ESP_LOGN(TAG, "Queue null");
} else {
ESP_LOGN(TAG, "Queue type: %d:%s, name: %s", i->component->get_queue_type(),
i->component->get_queue_type_string(), i->component->get_variable_name().c_str());
LOG_STR_ARG(i->component->get_queue_type_string()), i->component->get_variable_name().c_str());
}
}
ESP_LOGN(TAG, "*******************************************");
@@ -499,11 +499,11 @@ void Nextion::deliver_queue_response_(const LogString *response_name, const Next
} else if (!resp.is_string && (qtype == NextionQueueType::SENSOR || qtype == NextionQueueType::BINARY_SENSOR ||
qtype == NextionQueueType::SWITCH)) {
ESP_LOGN(TAG, "Numeric: %s type %d:%s val %d", component->get_variable_name().c_str(), qtype,
component->get_queue_type_string(), resp.int_value);
LOG_STR_ARG(component->get_queue_type_string()), resp.int_value);
component->set_state_from_int(resp.int_value, true, false);
} else if (resp.is_string && qtype == NextionQueueType::TEXT_SENSOR) {
ESP_LOGN(TAG, "String resp: '%s' id: %s type: %s", resp.str_value->c_str(),
component->get_variable_name().c_str(), component->get_queue_type_string());
component->get_variable_name().c_str(), LOG_STR_ARG(component->get_queue_type_string()));
component->set_state_from_string(*resp.str_value, true, false);
} else {
ESP_LOGE(TAG, "%s but '%s' invalid type %d", LOG_STR_ARG(response_name), component->get_variable_name().c_str(),
@@ -970,7 +970,7 @@ void Nextion::purge_stale_queue_entries_() {
for (auto it = this->nextion_queue_.begin(); it != this->nextion_queue_.end();) {
if (ms - (*it)->queue_time > this->max_q_age_ms_) {
NextionComponentBase *component = (*it)->component;
ESP_LOGV(TAG, "Remove old queue '%s':'%s'", component->get_queue_type_string(),
ESP_LOGV(TAG, "Remove old queue '%s':'%s'", LOG_STR_ARG(component->get_queue_type_string()),
component->get_variable_name().c_str());
if (is_sleep_wake_command(component)) {
@@ -1349,7 +1349,8 @@ void Nextion::add_to_get_queue(NextionComponentBase *component) {
nextion_queue->component = component;
nextion_queue->queue_time = App.get_loop_component_start_time();
ESP_LOGN(TAG, "Queue %s: %s", component->get_queue_type_string(), component->get_variable_name().c_str());
ESP_LOGN(TAG, "Queue %s: %s", LOG_STR_ARG(component->get_queue_type_string()),
component->get_variable_name().c_str());
std::string command = "get " + component->get_variable_name_to_send();
@@ -1,7 +1,16 @@
#include "nextion_component.h"
#include "esphome/core/progmem.h"
namespace esphome::nextion {
PROGMEM_STRING_TABLE(NextionQueueTypeStrings, "NO_RESULT", "SENSOR", "BINARY_SENSOR", "SWITCH", "TEXT_SENSOR",
"WAVEFORM_SENSOR");
static_assert(NextionQueueTypeStrings::COUNT == NextionQueueType::WAVEFORM_SENSOR + 1, "queue type names out of sync");
const LogString *NextionComponentBase::get_queue_type_string() const {
return NextionQueueTypeStrings::get_log_str(this->get_queue_type(), 0);
}
void NextionComponent::set_background_color(Color bco) {
if (this->variable_name_ == this->variable_name_to_send_) {
return; // This is a variable. no need to set color
@@ -5,6 +5,10 @@
#include <vector>
#include "esphome/core/defines.h"
namespace esphome {
struct LogString;
} // namespace esphome
namespace esphome::nextion {
enum NextionQueueType {
@@ -16,9 +20,6 @@ enum NextionQueueType {
WAVEFORM_SENSOR = 5,
};
static const char *const NEXTION_QUEUE_TYPE_STRINGS[] = {"NO_RESULT", "SENSOR", "BINARY_SENSOR",
"SWITCH", "TEXT_SENSOR", "WAVEFORM_SENSOR"};
class NextionComponentBase;
class NextionQueue {
@@ -82,7 +83,7 @@ class NextionComponentBase {
const std::string &get_variable_name() const { return this->variable_name_; }
const std::string &get_variable_name_to_send() const { return this->variable_name_to_send_; }
virtual NextionQueueType get_queue_type() const { return NextionQueueType::NO_RESULT; }
virtual const char *get_queue_type_string() const { return NEXTION_QUEUE_TYPE_STRINGS[this->get_queue_type()]; }
const LogString *get_queue_type_string() const;
virtual void set_state_from_int(int state_value, bool publish, bool send_to_nextion) {};
virtual void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion) {};
virtual void send_state_to_nextion() {};