From eb64707d94a6f63b4cb0aa0605bcdb233dd0d069 Mon Sep 17 00:00:00 2001 From: kbx81 Date: Tue, 19 May 2026 23:16:01 -0500 Subject: [PATCH] fix(network): lower NETWORK_PRIORITY_BASE below NetworkComponent's own priority MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #14255 sets NETWORK_PRIORITY_BASE = 300.0, but PR #14012's NetworkComponent uses setup_priority::AFTER_BLUETOOTH = 300.0f. When the highest-priority interface (first in the priority list) tied with NetworkComponent at 300, the runtime tie-break was determined by registration order — and NetworkComponent registers AFTER ethernet (its codegen runs at CoroPriority.NETWORK_SERVICES = 55, below COMMUNICATION = 60 used by ethernet/wifi). Result: ethernet's setup() ran before NetworkComponent::setup(), esp_netif_init() had not yet been called, esp_netif_new() returned NULL, and EthernetComponent::setup() dereferenced NULL in esp_netif_attach() — LoadProhibited crash at boot. Drop the base to 250.0 (matches the historical setup_priority::WIFI / ::ETHERNET default, so a single-entry priority list behaves identically to a no-priority-block config) and shrink the step to 5.0 to keep all interfaces in the same priority band, above BEFORE_CONNECTION (220.0) and below AFTER_BLUETOOTH (300.0). --- esphome/components/network/__init__.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/esphome/components/network/__init__.py b/esphome/components/network/__init__.py index 9d13111621..f2c3e30d55 100644 --- a/esphome/components/network/__init__.py +++ b/esphome/components/network/__init__.py @@ -34,9 +34,18 @@ KEY_NETWORK_PRIORITY = "network_priority" VALID_NETWORK_TYPES = ["ethernet", "openthread", "wifi", "modem"] -# Setup priority base values — first in list gets the highest priority -NETWORK_PRIORITY_BASE = 300.0 -NETWORK_PRIORITY_STEP = 100.0 +# Setup priority base values — first in list gets the highest priority. +# +# The base equals the historical setup_priority::WIFI / ::ETHERNET default +# (250.0), so a single-entry priority list yields exactly the same setup order +# as a config with no priority block. Subsequent entries step down by a small +# amount to break ties without crossing other priority bands. +# +# Important: must stay strictly less than setup_priority::AFTER_BLUETOOTH +# (300.0), which NetworkComponent itself uses — otherwise the highest-priority +# interface could tie with NetworkComponent and run before esp_netif_init(). +NETWORK_PRIORITY_BASE = 250.0 +NETWORK_PRIORITY_STEP = 5.0 network_ns = cg.esphome_ns.namespace("network") NetworkComponent = network_ns.class_("NetworkComponent", cg.Component)