From 3314e1953a85af2e9c8de45c965deaf80a5a67c2 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 4 Oct 2026 19:59:46 -0500 Subject: [PATCH] [wifi] Skip the post-connect roam scan on LN882x by default --- esphome/components/wifi/__init__.py | 13 ++++++++++++- tests/component_tests/wifi/config/bare_ln882x.yaml | 12 ++++++++++++ tests/component_tests/wifi/test_default_setters.py | 10 ++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/component_tests/wifi/config/bare_ln882x.yaml diff --git a/esphome/components/wifi/__init__.py b/esphome/components/wifi/__init__.py index fa552da9692..dc4f95d8430 100644 --- a/esphome/components/wifi/__init__.py +++ b/esphome/components/wifi/__init__.py @@ -542,7 +542,18 @@ CONFIG_SCHEMA = cv.All( ), cv.Optional(CONF_PASSIVE_SCAN, default=False): cv.boolean, cv.Optional(CONF_ENABLE_ON_BOOT, default=True): cv.boolean, - cv.Optional(CONF_POST_CONNECT_ROAMING, default=True): cv.boolean, + # An LN882H scan takes the radio off the AP long enough to drop + # the association, so the post-connect roam check costs a + # disconnect there. + cv.SplitDefault( + CONF_POST_CONNECT_ROAMING, + esp8266=True, + esp32=True, + rp2=True, + bk72xx=True, + rtl87xx=True, + ln882x=False, + ): cv.boolean, cv.Optional(CONF_ON_CONNECT): automation.validate_automation(single=True), cv.Optional(CONF_ON_DISCONNECT): automation.validate_automation( single=True diff --git a/tests/component_tests/wifi/config/bare_ln882x.yaml b/tests/component_tests/wifi/config/bare_ln882x.yaml new file mode 100644 index 00000000000..885a469b8df --- /dev/null +++ b/tests/component_tests/wifi/config/bare_ln882x.yaml @@ -0,0 +1,12 @@ +--- +esphome: + name: test + +ln882x: + board: generic-ln882h + +wifi: + ssid: test + password: testtest + ap: + ssid: fallback diff --git a/tests/component_tests/wifi/test_default_setters.py b/tests/component_tests/wifi/test_default_setters.py index b326f3eaeeb..61c721e8237 100644 --- a/tests/component_tests/wifi/test_default_setters.py +++ b/tests/component_tests/wifi/test_default_setters.py @@ -37,3 +37,13 @@ def test_custom_values_are_emitted( assert "set_reboot_timeout(0);" in main_cpp assert "set_power_save_mode(wifi::WIFI_POWER_SAVE_LIGHT);" in main_cpp assert "set_min_auth_mode(wifi::WIFI_MIN_AUTH_MODE_WPA);" in main_cpp + + +def test_ln882x_skips_post_connect_roaming( + generate_main: Callable[[str | Path], str], + component_config_path: Callable[[str], Path], +) -> None: + """An LN882H scan drops the association, so LN882x does not roam by default.""" + main_cpp = generate_main(component_config_path("bare_ln882x.yaml")) + + assert "set_post_connect_roaming(false);" in main_cpp