diff --git a/esphome/components/lora/lora.cpp b/esphome/components/lora/lora.cpp index 7a07b65c1f..b51affb6ed 100644 --- a/esphome/components/lora/lora.cpp +++ b/esphome/components/lora/lora.cpp @@ -3,12 +3,16 @@ namespace esphome { namespace lora { void Lora::update() { + if (!this->update_needed_) + return; if (this->rssi_sensor_ != nullptr) this->rssi_sensor_->publish_state(this->rssi_); // raw info if (this->message_text_sensor_ != nullptr) this->message_text_sensor_->publish_state(this->raw_message_); + // reset the updater + this->update_needed_ = false; } void Lora::setup() { this->pin_aux_->setup(); @@ -157,6 +161,7 @@ void Lora::loop() { data.push_back(c); } } + this->update_needed_ = true; ESP_LOGD(TAG, "Got %s", buffer.c_str()); if (!data.empty()) { ESP_LOGD(TAG, "Found pin data!"); diff --git a/esphome/components/lora/lora.h b/esphome/components/lora/lora.h index e4cdcaac82..8546ddb578 100644 --- a/esphome/components/lora/lora.h +++ b/esphome/components/lora/lora.h @@ -54,6 +54,7 @@ class Lora : public PollingComponent, public uart::UARTDevice { bool send_pin_info_(uint8_t pin, bool value); protected: + bool update_needed_ = false; int rssi_ = 0; float latitude_ = -1; float longitude_ = -1;