diff --git a/esphome/components/espnow/__init__.py b/esphome/components/espnow/__init__.py index 1f5ca1104a..c18b3d7a54 100644 --- a/esphome/components/espnow/__init__.py +++ b/esphome/components/espnow/__init__.py @@ -17,7 +17,7 @@ from esphome.core import CORE, HexInt from esphome.types import ConfigType CODEOWNERS = ["@jesserockz"] -AUTO_LOAD = ["socket"] +AUTO_LOAD = ["network", "socket"] byte_vector = cg.std_vector.template(cg.uint8) peer_address_t = cg.std_ns.class_("array").template(cg.uint8, 6) diff --git a/esphome/components/network/__init__.py b/esphome/components/network/__init__.py index 2d2bd4a727..1ec668b86c 100644 --- a/esphome/components/network/__init__.py +++ b/esphome/components/network/__init__.py @@ -1,6 +1,7 @@ import ipaddress import logging +from esphome import core import esphome.codegen as cg from esphome.components.esp32 import add_idf_sdkconfig_option from esphome.components.psram import is_guaranteed as psram_is_guaranteed @@ -144,7 +145,11 @@ async def to_code(config): # Register NetworkComponent to initialize network stack early (ESP32 only) # This ensures esp_netif_init() is called before web_server binds if CORE.is_esp32: - var = cg.new_Pvariable(cg.new_id("network_component")) + component_id = core.ID( + "network_component", is_declaration=True, type=NetworkComponent + ) + CORE.component_ids.add(component_id.id) + var = cg.new_Pvariable(component_id) await cg.register_component(var, {}) # Apply high performance networking settings