From efe7bb1eb9c5d84db895fcd98ba1da3f99cfd300 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 17 Apr 2026 15:52:04 -0500 Subject: [PATCH] [sensor] Guard NaN specialization against explicit empty value list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preserves the prior behavior of `value: []` (behaves like plain throttle, no NaN bypass) by requiring a non-empty list before treating the config as NaN-only — `all([])` is vacuously true otherwise. --- esphome/components/sensor/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/sensor/__init__.py b/esphome/components/sensor/__init__.py index 7107a7a888..8dcb7165e3 100644 --- a/esphome/components/sensor/__init__.py +++ b/esphome/components/sensor/__init__.py @@ -666,7 +666,7 @@ async def throttle_with_priority_filter_to_code(config, filter_id): # omits `value:`) to avoid the TemplatableFn array + NaN lambda the # generic ValueListFilter path requires. Behavior is identical: NaN sensor # readings always bypass the throttle. - if all(isinstance(v, float) and math.isnan(v) for v in values): + if values and all(isinstance(v, float) and math.isnan(v) for v in values): filter_id = filter_id.copy() filter_id.type = ThrottleWithPriorityNanFilter return cg.new_Pvariable(filter_id, config[CONF_TIMEOUT])