From 80375e6a079d7b8f45951541ffacd3dd876b716e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Koek?= Date: Mon, 3 Jun 2024 13:09:03 +0100 Subject: [PATCH] more stuff for the repeater --- esphome/components/ebyte_lora/ebyte_lora_component.cpp | 8 +++++++- esphome/components/ebyte_lora/ebyte_lora_component.h | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/esphome/components/ebyte_lora/ebyte_lora_component.cpp b/esphome/components/ebyte_lora/ebyte_lora_component.cpp index c63b68b3c4..f2aed1ae3f 100644 --- a/esphome/components/ebyte_lora/ebyte_lora_component.cpp +++ b/esphome/components/ebyte_lora/ebyte_lora_component.cpp @@ -405,12 +405,15 @@ void EbyteLoraComponent::loop() { ESP_LOGD(TAG, "%u", data[i]); } } + // starting info loop if (data[0] == SWITCH_INFO) { if (this->repeater_) { this->repeat_message(data); } - // it is it's own info + // only configs with switches should sent too +#ifdef USE_SWITCH + // Make sure it is not itself if (network_id != data[1]) { ESP_LOGD(TAG, "Got switch info"); for (int i = 2; i < data.size(); i = i + 2) { @@ -422,6 +425,7 @@ void EbyteLoraComponent::loop() { } } } +#endif } this->rssi_sensor_->publish_state((data[data.size() - 1] / 255.0) * 100); ESP_LOGD(TAG, "RSSI: %f", (data[data.size() - 1] / 255.0) * 100); @@ -475,6 +479,7 @@ void EbyteLoraComponent::setup_conf_(std::vector data) { } void EbyteLoraComponent::send_switch_info_() { +#ifdef USE_SWITCH if (!this->can_send_message_()) { return; } @@ -488,6 +493,7 @@ void EbyteLoraComponent::send_switch_info_() { ESP_LOGD(TAG, "Sending switch info"); this->write_array(data); this->setup_wait_response_(5000); +#endif } void EbyteLoraComponent::send_repeater_info() { diff --git a/esphome/components/ebyte_lora/ebyte_lora_component.h b/esphome/components/ebyte_lora/ebyte_lora_component.h index e062bd302f..d9789a91ce 100644 --- a/esphome/components/ebyte_lora/ebyte_lora_component.h +++ b/esphome/components/ebyte_lora/ebyte_lora_component.h @@ -7,7 +7,9 @@ #include "esphome/components/uart/uart.h" #include "esphome/core/log.h" #include "config.h" +#ifdef USE_SWITCH #include "esphome/components/switch/switch.h" +#endif namespace esphome { namespace ebyte_lora { @@ -88,6 +90,7 @@ class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice { InternalGPIOPin *pin_m0_{nullptr}; InternalGPIOPin *pin_m1_{nullptr}; }; +#ifdef USE_SWITCH class EbyteLoraSwitch : public switch_::Switch, public Parented { public: void set_pin(uint8_t pin) { pin_ = pin; } @@ -97,5 +100,6 @@ class EbyteLoraSwitch : public switch_::Switch, public Parentedparent_->send_switch_info_(); } uint8_t pin_; }; +#endif } // namespace ebyte_lora } // namespace esphome