mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 09:44:12 +01:00
and update
This commit is contained in:
parent
3d4e589bcb
commit
752fdeff90
2 changed files with 6 additions and 0 deletions
|
@ -3,12 +3,16 @@
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace lora {
|
namespace lora {
|
||||||
void Lora::update() {
|
void Lora::update() {
|
||||||
|
if (!this->update_needed_)
|
||||||
|
return;
|
||||||
if (this->rssi_sensor_ != nullptr)
|
if (this->rssi_sensor_ != nullptr)
|
||||||
this->rssi_sensor_->publish_state(this->rssi_);
|
this->rssi_sensor_->publish_state(this->rssi_);
|
||||||
|
|
||||||
// raw info
|
// raw info
|
||||||
if (this->message_text_sensor_ != nullptr)
|
if (this->message_text_sensor_ != nullptr)
|
||||||
this->message_text_sensor_->publish_state(this->raw_message_);
|
this->message_text_sensor_->publish_state(this->raw_message_);
|
||||||
|
// reset the updater
|
||||||
|
this->update_needed_ = false;
|
||||||
}
|
}
|
||||||
void Lora::setup() {
|
void Lora::setup() {
|
||||||
this->pin_aux_->setup();
|
this->pin_aux_->setup();
|
||||||
|
@ -157,6 +161,7 @@ void Lora::loop() {
|
||||||
data.push_back(c);
|
data.push_back(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->update_needed_ = true;
|
||||||
ESP_LOGD(TAG, "Got %s", buffer.c_str());
|
ESP_LOGD(TAG, "Got %s", buffer.c_str());
|
||||||
if (!data.empty()) {
|
if (!data.empty()) {
|
||||||
ESP_LOGD(TAG, "Found pin data!");
|
ESP_LOGD(TAG, "Found pin data!");
|
||||||
|
|
|
@ -54,6 +54,7 @@ class Lora : public PollingComponent, public uart::UARTDevice {
|
||||||
bool send_pin_info_(uint8_t pin, bool value);
|
bool send_pin_info_(uint8_t pin, bool value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool update_needed_ = false;
|
||||||
int rssi_ = 0;
|
int rssi_ = 0;
|
||||||
float latitude_ = -1;
|
float latitude_ = -1;
|
||||||
float longitude_ = -1;
|
float longitude_ = -1;
|
||||||
|
|
Loading…
Reference in a new issue