[sensor] Guard NaN specialization against explicit empty value list

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.
This commit is contained in:
J. Nick Koston
2026-04-17 15:52:04 -05:00
parent a5cba91729
commit efe7bb1eb9
+1 -1
View File
@@ -666,7 +666,7 @@ async def throttle_with_priority_filter_to_code(config, filter_id):
# omits `value:`) to avoid the TemplatableFn<float> 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])