mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 19:44:08 +00:00
[light] Cover get_effects() as published configs use it in the component test (#20203)
This commit is contained in:
@@ -28,6 +28,21 @@ esphome:
|
||||
ESP_LOGI("test", "Name length: %d", (int) name.size());
|
||||
}
|
||||
|
||||
# get_effects() shapes used by published configs and external components
|
||||
- lambda: |-
|
||||
const auto &effects = id(test_monochromatic_light).get_effects();
|
||||
auto &same = id(test_monochromatic_light).get_effects();
|
||||
uint32_t total = effects.size();
|
||||
for (auto *effect : effects) {
|
||||
ESP_LOGD("test", "Effect %s", effect->get_name().c_str());
|
||||
}
|
||||
if (total > 0) {
|
||||
ESP_LOGD("test", "First %s", effects.at(0)->get_name().c_str());
|
||||
// Raw pointer iterators on purpose: external code binds std::find's result to `const auto *`
|
||||
auto *it = std::find(same.begin(), same.end(), effects[0]);
|
||||
ESP_LOGD("test", "Index %d", (int) (it - same.begin()));
|
||||
}
|
||||
|
||||
# Test LightState::get_effect_name() returns StringRef
|
||||
- lambda: |-
|
||||
// Test LightState::get_effect_name() returns StringRef
|
||||
|
||||
Reference in New Issue
Block a user