[fan] Cover preset mode reads and runtime sets in the component test (#20209)

This commit is contained in:
J. Nick Koston
2026-10-06 09:03:58 -04:00
committed by GitHub
parent b7ddd1daa2
commit 9b1a75b0ed
+19 -2
View File
@@ -66,9 +66,26 @@ binary_sensor:
}
return false;
# Exercise fan.turn_on with various field combinations so the
# register_apply_action codegen paths get build coverage.
button:
# Read and set preset modes the way external fan components do
- platform: template
name: "Fan Preset Modes Lambdas"
on_press:
- lambda: |-
// How external components and configs read and set fan preset modes
auto traits = id(test_fan).get_traits();
const auto &modes = traits.supported_preset_modes();
for (const auto &mode : modes)
ESP_LOGD("test", "%s", mode);
for (const char *mode : traits.supported_preset_modes())
ESP_LOGD("test", "%s", mode);
std::vector<const char *> runtime_modes{"Eco", "Turbo"};
id(test_fan).set_supported_preset_modes(runtime_modes);
id(test_fan).set_supported_preset_modes({"Eco"});
id(test_fan).set_supported_preset_modes({});
# Exercise fan.turn_on with various field combinations so the
# register_apply_action codegen paths get build coverage.
- platform: template
name: "Fan Speed Only"
on_press: