From 752fdeff90c416e46ab5c4df1d6d1ccd456cd3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Koek?= Date: Mon, 25 Mar 2024 16:41:53 +0000 Subject: [PATCH] and update --- esphome/components/lora/lora.cpp | 5 +++++ esphome/components/lora/lora.h | 1 + 2 files changed, 6 insertions(+) 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;