[socket] Compile the lookup and client link helpers only when required (#20002)

This commit is contained in:
J. Nick Koston
2026-10-02 07:31:41 -05:00
committed by GitHub
parent 12b016e3d2
commit 3fd8f00e97
6 changed files with 62 additions and 1 deletions
@@ -1,4 +1,5 @@
import esphome.codegen as cg
from esphome.components import socket
import esphome.config_validation as cv
from esphome.const import CONF_ID
from esphome.types import ConfigType
@@ -18,5 +19,6 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config: ConfigType) -> None:
socket.require_ipv4_resolve()
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
@@ -1,4 +1,5 @@
import esphome.codegen as cg
from esphome.components import socket
from esphome.components.const import CONF_HOST
import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_PORT
@@ -28,6 +29,7 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config: ConfigType) -> None:
socket.require_tcp_client_link()
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
cg.add(var.set_host(config[CONF_HOST]))