From c7d485e8bdc8305a5cb4228c66faf11384ca5092 Mon Sep 17 00:00:00 2001 From: kbx81 Date: Mon, 24 Nov 2025 17:08:55 -0600 Subject: [PATCH] Use set.intersection --- esphome/components/wifi_info/text_sensor.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/esphome/components/wifi_info/text_sensor.py b/esphome/components/wifi_info/text_sensor.py index 50fe31d151..8097767d3d 100644 --- a/esphome/components/wifi_info/text_sensor.py +++ b/esphome/components/wifi_info/text_sensor.py @@ -61,6 +61,15 @@ CONFIG_SCHEMA = cv.Schema( } ) +# Keys that require WiFi callbacks +_NETWORK_INFO_KEYS = { + CONF_SSID, + CONF_BSSID, + CONF_IP_ADDRESS, + CONF_DNS_ADDRESS, + CONF_SCAN_RESULTS, +} + async def setup_conf(config, key): if key in config: @@ -71,16 +80,7 @@ async def setup_conf(config, key): async def to_code(config): # Request WiFi callbacks for any sensor that needs them - if any( - key in config - for key in ( - CONF_SSID, - CONF_BSSID, - CONF_IP_ADDRESS, - CONF_DNS_ADDRESS, - CONF_SCAN_RESULTS, - ) - ): + if _NETWORK_INFO_KEYS & config.keys(): wifi.request_wifi_callbacks() await setup_conf(config, CONF_SSID)