From c2f7dcfa6dccc2a9f742708df9fa64e9a1117caf Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Tue, 15 Jul 2025 13:36:07 +1000 Subject: [PATCH 1/4] [captive_portal] Add test case for libretiny (#9457) Co-authored-by: J. Nick Koston --- tests/components/captive_portal/test.bk72xx-ard.yaml | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/components/captive_portal/test.bk72xx-ard.yaml diff --git a/tests/components/captive_portal/test.bk72xx-ard.yaml b/tests/components/captive_portal/test.bk72xx-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/captive_portal/test.bk72xx-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml From 0f15250f12a440245695bc03b715b6f10265b904 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Mon, 14 Jul 2025 22:43:00 -0500 Subject: [PATCH 2/4] [opentherm.output] Fix ``lerp`` (#9506) --- esphome/components/opentherm/output/output.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/opentherm/output/output.cpp b/esphome/components/opentherm/output/output.cpp index f820dc76f1..486aa0d4e7 100644 --- a/esphome/components/opentherm/output/output.cpp +++ b/esphome/components/opentherm/output/output.cpp @@ -10,7 +10,7 @@ void opentherm::OpenthermOutput::write_state(float state) { ESP_LOGD(TAG, "Received state: %.2f. Min value: %.2f, max value: %.2f", state, min_value_, max_value_); this->state = state < 0.003 && this->zero_means_zero_ ? 0.0 - : clamp(lerp(state, min_value_, max_value_), min_value_, max_value_); + : clamp(std::lerp(min_value_, max_value_, state), min_value_, max_value_); this->has_state_ = true; ESP_LOGD(TAG, "Output %s set to %.2f", this->id_, this->state); } From 84349b6d05a2148375574a716beb1b9b04d7abf7 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Mon, 14 Jul 2025 22:45:38 -0500 Subject: [PATCH 3/4] [servo] Fix ``lerp`` (#9507) --- esphome/components/servo/servo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/servo/servo.cpp b/esphome/components/servo/servo.cpp index b8546d345c..b4511de2d0 100644 --- a/esphome/components/servo/servo.cpp +++ b/esphome/components/servo/servo.cpp @@ -88,9 +88,9 @@ void Servo::internal_write(float value) { value = clamp(value, -1.0f, 1.0f); float level; if (value < 0.0) { - level = lerp(-value, this->idle_level_, this->min_level_); + level = std::lerp(this->idle_level_, this->min_level_, -value); } else { - level = lerp(value, this->idle_level_, this->max_level_); + level = std::lerp(this->idle_level_, this->max_level_, value); } this->output_->set_level(level); this->current_value_ = value; From 909356698c545d55077acedce7c88225fbc5b9eb Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 14 Jul 2025 20:31:34 -1000 Subject: [PATCH 4/4] Optimize API connection batch priority message handling to reduce flash usage --- esphome/components/api/api_connection.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index ea3268a583..9ceb181b77 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -186,7 +186,8 @@ void APIConnection::loop() { on_fatal_error(); ESP_LOGW(TAG, "%s is unresponsive; disconnecting", this->get_client_combined_info().c_str()); } - } else if (now - this->last_traffic_ > KEEPALIVE_TIMEOUT_MS) { + } else if (now - this->last_traffic_ > KEEPALIVE_TIMEOUT_MS && !this->flags_.remove) { + // Only send ping if we're not disconnecting ESP_LOGVV(TAG, "Sending keepalive PING"); this->flags_.sent_ping = this->send_message(PingRequest()); if (!this->flags_.sent_ping) { @@ -1662,8 +1663,15 @@ void APIConnection::DeferredBatch::add_item(EntityBase *entity, MessageCreator c void APIConnection::DeferredBatch::add_item_front(EntityBase *entity, MessageCreator creator, uint8_t message_type, uint8_t estimated_size) { - // Insert at front for high priority messages (no deduplication check) - items.insert(items.begin(), BatchItem(entity, std::move(creator), message_type, estimated_size)); + // Add high priority message and swap to front + // This avoids expensive vector::insert which shifts all elements + // Note: We only ever have one high-priority message at a time (ping OR disconnect) + // If we're disconnecting, pings are blocked, so this simple swap is sufficient + items.emplace_back(entity, std::move(creator), message_type, estimated_size); + if (items.size() > 1) { + // Swap the new high-priority item to the front + std::swap(items.front(), items.back()); + } } bool APIConnection::schedule_batch_() {