diff --git a/esphome/components/nextion/binary_sensor/nextion_binarysensor.cpp b/esphome/components/nextion/binary_sensor/nextion_binarysensor.cpp index 6dccd1a2d287..bf6e74cb38fe 100644 --- a/esphome/components/nextion/binary_sensor/nextion_binarysensor.cpp +++ b/esphome/components/nextion/binary_sensor/nextion_binarysensor.cpp @@ -5,7 +5,7 @@ namespace esphome { namespace nextion { -static const char *TAG = "nextion_binarysensor"; +static const char *const TAG = "nextion_binarysensor"; void NextionBinarySensor::process_bool(const std::string &variable_name, bool state) { if (!this->nextion_->is_setup()) diff --git a/esphome/components/nextion/binary_sensor/nextion_binarysensor.h b/esphome/components/nextion/binary_sensor/nextion_binarysensor.h index 5d2b4f02aee1..b6b23ada85d6 100644 --- a/esphome/components/nextion/binary_sensor/nextion_binarysensor.h +++ b/esphome/components/nextion/binary_sensor/nextion_binarysensor.h @@ -32,7 +32,7 @@ class NextionBinarySensor : public NextionComponent, NextionQueueType get_queue_type() override { return NextionQueueType::BINARY_SENSOR; } void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion) override {} void set_state_from_int(int state_value, bool publish, bool send_to_nextion) override { - this->set_state(state_value == 0 ? false : true, publish, send_to_nextion); + this->set_state(state_value != 0, publish, send_to_nextion); } protected: diff --git a/esphome/components/nextion/nextion.cpp b/esphome/components/nextion/nextion.cpp index da76655d5a6b..426c95d5eb39 100644 --- a/esphome/components/nextion/nextion.cpp +++ b/esphome/components/nextion/nextion.cpp @@ -869,7 +869,7 @@ uint16_t Nextion::recv_ret_string_(std::string &response, uint32_t timeout, bool uint16_t ret = 0; uint8_t c = 0; uint8_t nr_of_ff_bytes = 0; - long start; + uint64_t start; bool exit_flag = false; bool ff_flag = false; diff --git a/esphome/components/nextion/nextion.h b/esphome/components/nextion/nextion.h index 4ae7601d8be6..5666a8884a39 100644 --- a/esphome/components/nextion/nextion.h +++ b/esphome/components/nextion/nextion.h @@ -731,7 +731,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe std::deque nextion_queue_; uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag); void all_components_send_state_(bool force_update = false); - long comok_sent_ = 0; + uint64_t comok_sent_ = 0; bool remove_from_q_(bool report_empty = true); /** * @brief diff --git a/esphome/components/nextion/nextion_commands.cpp b/esphome/components/nextion/nextion_commands.cpp index 10526beec771..931b934ba220 100644 --- a/esphome/components/nextion/nextion_commands.cpp +++ b/esphome/components/nextion/nextion_commands.cpp @@ -4,7 +4,7 @@ namespace esphome { namespace nextion { -static const char *TAG = "nextion"; +static const char *const TAG = "nextion"; // Sleep safe commands void Nextion::soft_reset() { this->send_command_("rest"); } diff --git a/esphome/components/nextion/nextion_component_base.h b/esphome/components/nextion/nextion_component_base.h index 65ccc1d460cc..71ad803bc4f2 100644 --- a/esphome/components/nextion/nextion_component_base.h +++ b/esphome/components/nextion/nextion_component_base.h @@ -1,4 +1,5 @@ #pragma once +#include #include "esphome/core/defines.h" namespace esphome { @@ -13,8 +14,8 @@ enum NextionQueueType { WAVEFORM_SENSOR = 5, }; -static const char *NextionQueueTypeStrings[] = {"NO_RESULT", "SENSOR", "BINARY_SENSOR", - "SWITCH", "TEXT_SENSOR", "WAVEFORM_SENSOR"}; +static const char *const NEXTION_QUEUE_TYPE_STRINGS[] = {"NO_RESULT", "SENSOR", "BINARY_SENSOR", + "SWITCH", "TEXT_SENSOR", "WAVEFORM_SENSOR"}; class NextionComponentBase; @@ -29,10 +30,10 @@ class NextionComponentBase { public: virtual ~NextionComponentBase() = default; - void set_variable_name(std::string variable_name, std::string variable_name_to_send = "") { + void set_variable_name(const std::string &variable_name, const std::string &variable_name_to_send = "") { variable_name_ = variable_name; if (variable_name_to_send.empty()) { - variable_name_to_send_ = variable_name_; + variable_name_to_send_ = variable_name; } else { variable_name_to_send_ = variable_name_to_send; } @@ -71,7 +72,7 @@ class NextionComponentBase { std::string get_variable_name() { return this->variable_name_; } std::string get_variable_name_to_send() { return this->variable_name_to_send_; } virtual NextionQueueType get_queue_type() { return NextionQueueType::NO_RESULT; } - virtual std::string get_queue_type_string() { return NextionQueueTypeStrings[this->get_queue_type()]; } + virtual std::string get_queue_type_string() { return NEXTION_QUEUE_TYPE_STRINGS[this->get_queue_type()]; } 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(){}; diff --git a/esphome/components/nextion/nextion_upload.cpp b/esphome/components/nextion/nextion_upload.cpp index 6fd262c2629f..6a681af6c5e8 100644 --- a/esphome/components/nextion/nextion_upload.cpp +++ b/esphome/components/nextion/nextion_upload.cpp @@ -6,7 +6,7 @@ namespace esphome { namespace nextion { -static const char *TAG = "nextion_upload"; +static const char *const TAG = "nextion_upload"; #if defined(USE_TFT_UPLOAD) && (defined(USE_ETHERNET) || defined(USE_WIFI)) diff --git a/esphome/components/nextion/sensor/nextion_sensor.cpp b/esphome/components/nextion/sensor/nextion_sensor.cpp index 45af00375bb0..bbcb465d85c2 100644 --- a/esphome/components/nextion/sensor/nextion_sensor.cpp +++ b/esphome/components/nextion/sensor/nextion_sensor.cpp @@ -5,7 +5,7 @@ namespace esphome { namespace nextion { -static const char *TAG = "nextion_sensor"; +static const char *const TAG = "nextion_sensor"; void NextionSensor::process_sensor(const std::string &variable_name, int state) { if (!this->nextion_->is_setup()) diff --git a/esphome/components/nextion/switch/nextion_switch.cpp b/esphome/components/nextion/switch/nextion_switch.cpp index 090addf39dc7..1f32ad34257c 100644 --- a/esphome/components/nextion/switch/nextion_switch.cpp +++ b/esphome/components/nextion/switch/nextion_switch.cpp @@ -5,7 +5,7 @@ namespace esphome { namespace nextion { -static const char *TAG = "nextion_switch"; +static const char *const TAG = "nextion_switch"; void NextionSwitch::process_bool(const std::string &variable_name, bool on) { if (!this->nextion_->is_setup()) diff --git a/esphome/components/nextion/switch/nextion_switch.h b/esphome/components/nextion/switch/nextion_switch.h index ced61880dd70..154828747364 100644 --- a/esphome/components/nextion/switch/nextion_switch.h +++ b/esphome/components/nextion/switch/nextion_switch.h @@ -24,7 +24,7 @@ class NextionSwitch : public NextionComponent, public switch_::Switch, public Po NextionQueueType get_queue_type() override { return NextionQueueType::SWITCH; } void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion) override {} void set_state_from_int(int state_value, bool publish, bool send_to_nextion) override { - this->set_state(state_value == 0 ? false : true, publish, send_to_nextion); + this->set_state(state_value != 0, publish, send_to_nextion); } protected: diff --git a/esphome/components/nextion/text_sensor/nextion_textsensor.cpp b/esphome/components/nextion/text_sensor/nextion_textsensor.cpp index 7d0f1b40968d..08f032df74f1 100644 --- a/esphome/components/nextion/text_sensor/nextion_textsensor.cpp +++ b/esphome/components/nextion/text_sensor/nextion_textsensor.cpp @@ -4,7 +4,7 @@ namespace esphome { namespace nextion { -static const char *TAG = "nextion_textsensor"; +static const char *const TAG = "nextion_textsensor"; void NextionTextSensor::process_text(const std::string &variable_name, const std::string &text_value) { if (!this->nextion_->is_setup())