From 4437a0bd7f4704cffbf0600854139f5e4863b356 Mon Sep 17 00:00:00 2001 From: kbx81 Date: Wed, 2 Sep 2026 23:48:17 -0500 Subject: [PATCH] [serial_proxy] Reset the mode when a subscription is taken over A client taking over from a crashed subscriber inherited that session's mode; end the dead session with reset_mode_() before handing over the port, matching every other subscriber-change path. --- esphome/components/serial_proxy/serial_proxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/serial_proxy/serial_proxy.cpp b/esphome/components/serial_proxy/serial_proxy.cpp index 0877de66c4..a79edc4e2c 100644 --- a/esphome/components/serial_proxy/serial_proxy.cpp +++ b/esphome/components/serial_proxy/serial_proxy.cpp @@ -372,6 +372,10 @@ SerialProxyResult SerialProxy::serial_proxy_request(api::APIConnection *api_conn return SerialProxyResult::SERIAL_PROXY_RESULT_PORT_IN_USE; } ESP_LOGW(TAG, "Previous subscriber disconnected; taking over subscription"); + // End the dead client's session before starting the new one, so its mode + // cannot leak into a session that never asked for it + this->api_connection_ = nullptr; + this->reset_mode_(); } this->api_connection_ = api_connection; this->enable_loop();