mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 01:19:45 +08:00
[fan] Cover fan.turn_on inside on_preset_set (StringRef Ts) in tests
This commit is contained in:
@@ -9,6 +9,14 @@ fan:
|
|||||||
has_oscillating: true
|
has_oscillating: true
|
||||||
has_direction: true
|
has_direction: true
|
||||||
speed_count: 3
|
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
|
# Test lambdas using get_preset_mode() which returns StringRef
|
||||||
# These examples match the migration guide in the PR description
|
# These examples match the migration guide in the PR description
|
||||||
@@ -89,8 +97,11 @@ button:
|
|||||||
id: test_fan
|
id: test_fan
|
||||||
speed: !lambda 'return 1;'
|
speed: !lambda 'return 1;'
|
||||||
|
|
||||||
# Exercise fan.turn_on inside a trigger with non-empty Ts (number on_value
|
# Exercise fan.turn_on inside triggers with non-empty Ts:
|
||||||
# passes float).
|
# - 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:
|
number:
|
||||||
- platform: template
|
- platform: template
|
||||||
id: fan_speed_number
|
id: fan_speed_number
|
||||||
|
|||||||
Reference in New Issue
Block a user