From 59de35a7b8d46dae6bf1fff8be24844df08fefe8 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 3 May 2026 17:52:58 -0500 Subject: [PATCH] [fan] Cover fan.turn_on inside on_preset_set (StringRef Ts) in tests --- tests/components/fan/common.yaml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/components/fan/common.yaml b/tests/components/fan/common.yaml index 91f799432c..76508f391e 100644 --- a/tests/components/fan/common.yaml +++ b/tests/components/fan/common.yaml @@ -9,6 +9,14 @@ fan: has_oscillating: true has_direction: true speed_count: 3 + # Exercise fan.turn_on inside a trigger whose Ts pack is non-empty + # (StringRef from on_preset_set) so the apply-lambda + inner-lambda + # codegen runs through the cvref-normalized path. + on_preset_set: + then: + - fan.turn_on: + id: test_fan + speed: !lambda "return x.empty() ? 1 : 3;" # Test lambdas using get_preset_mode() which returns StringRef # These examples match the migration guide in the PR description @@ -89,8 +97,11 @@ button: id: test_fan speed: !lambda 'return 1;' -# Exercise fan.turn_on inside a trigger with non-empty Ts (number on_value -# passes float). +# Exercise fan.turn_on inside triggers with non-empty Ts: +# - number.on_value: Ts = float (Python value type; previously raised +# AttributeError on .operator("const")) +# - fan.on_preset_set: Ts = StringRef (already a value-type wrapper around +# a const char * + size; tests the cvref-normalized inner-lambda path) number: - platform: template id: fan_speed_number