diff --git a/esphome/components/ebyte_lora/ebyte_lora.cpp b/esphome/components/ebyte_lora/ebyte_lora.cpp index c60b224da8..90173e675e 100644 --- a/esphome/components/ebyte_lora/ebyte_lora.cpp +++ b/esphome/components/ebyte_lora/ebyte_lora.cpp @@ -147,6 +147,21 @@ void EbyteLoraComponent::loop() { } if (data[0] == SWITCH_PUSH) { ESP_LOGD(TAG, "GOT SWITCH PUSH ", data.size()); + ESP_LOGD(TAG, "Total: %u ", data.size()); + ESP_LOGD(TAG, "Start bit: ", data[0]); + ESP_LOGD(TAG, "PIN: %u ", data[1]); + ESP_LOGD(TAG, "VALUE: %u ", data[2]); + ESP_LOGD(TAG, "RSSI: %u % ", (data[3] / 255.0) * 100); + if (this->rssi_sensor_ != nullptr) + this->rssi_sensor_->publish_state((data[3] / 255.0) * 100); + + for (auto *sensor : this->sensors_) { + if (sensor->get_pin() == data[1]) { + ESP_LOGD(TAG, "Updating switch"); + sensor->got_state_message(data[2]); + } + } + send_switch_info_(); } if (data[0] == SWITCH_INFO) { ESP_LOGD(TAG, "GOT INFO ", data.size()); @@ -161,23 +176,6 @@ void EbyteLoraComponent::loop() { i = +2; } } - if (data.size() == 4) { - ESP_LOGD(TAG, "Total: %u ", data.size()); - ESP_LOGD(TAG, "Start bit: ", data[0]); - ESP_LOGD(TAG, "PIN: %u ", data[1]); - ESP_LOGD(TAG, "VALUE: %u ", data[2]); - ESP_LOGD(TAG, "RSSI: %u % ", (data[3] / 255.0) * 100); - if (this->rssi_sensor_ != nullptr) - this->rssi_sensor_->publish_state((data[3] / 255.0) * 100); - - for (auto *sensor : this->sensors_) { - if (sensor->get_pin() == data[1]) { - ESP_LOGD(TAG, "Updating switch"); - sensor->got_state_message(data[2]); - } - } - send_switch_info_(); - } } } void EbyteLoraComponent::send_switch_info_() {