mirror of
https://github.com/esphome/esphome.git
synced 2026-01-13 05:27:53 -07:00
245 lines
7.1 KiB
YAML
245 lines
7.1 KiB
YAML
esphome:
|
|
on_boot:
|
|
then:
|
|
# Test LightEffect::get_name() returns StringRef
|
|
- lambda: |-
|
|
// Test LightEffect::get_name() returns StringRef
|
|
auto &effects = id(test_monochromatic_light).get_effects();
|
|
if (!effects.empty()) {
|
|
// Test: get_name() returns StringRef
|
|
StringRef name = effects[0]->get_name();
|
|
|
|
// Test: comparison with string literal works directly
|
|
if (name == "Strobe") {
|
|
ESP_LOGI("test", "Found Strobe effect");
|
|
}
|
|
|
|
// Test: safe logging with %.*s format
|
|
ESP_LOGI("test", "Effect name: %.*s", (int) name.size(), name.c_str());
|
|
|
|
// Test: .c_str() for functions expecting const char*
|
|
ESP_LOGI("test", "Effect: %s", name.c_str());
|
|
|
|
// Test: explicit conversion to std::string
|
|
std::string name_str(name.c_str(), name.size());
|
|
ESP_LOGI("test", "As string: %s", name_str.c_str());
|
|
|
|
// Test: size() method
|
|
ESP_LOGI("test", "Name length: %d", (int) name.size());
|
|
}
|
|
|
|
# Test LightState::get_effect_name() returns StringRef
|
|
- lambda: |-
|
|
// Test LightState::get_effect_name() returns StringRef
|
|
StringRef current_effect = id(test_monochromatic_light).get_effect_name();
|
|
|
|
// Test: comparison with "None" works directly
|
|
if (current_effect == "None") {
|
|
ESP_LOGI("test", "No effect active");
|
|
}
|
|
|
|
// Test: safe logging
|
|
ESP_LOGI("test", "Current effect: %.*s", (int) current_effect.size(), current_effect.c_str());
|
|
|
|
# Test str_equals_case_insensitive with StringRef
|
|
- lambda: |-
|
|
// Test str_equals_case_insensitive(StringRef, StringRef)
|
|
auto &effects = id(test_monochromatic_light).get_effects();
|
|
if (!effects.empty()) {
|
|
StringRef name = effects[0]->get_name();
|
|
|
|
// Test: case-insensitive comparison
|
|
if (str_equals_case_insensitive(name, "STROBE")) {
|
|
ESP_LOGI("test", "Case-insensitive match works");
|
|
}
|
|
|
|
// Test: case-insensitive with StringRef from string
|
|
std::string search = "strobe";
|
|
if (str_equals_case_insensitive(StringRef(search.c_str(), search.size()), name)) {
|
|
ESP_LOGI("test", "Reverse comparison works");
|
|
}
|
|
}
|
|
|
|
- light.toggle: test_binary_light
|
|
- light.turn_off: test_rgb_light
|
|
- light.turn_on:
|
|
id: test_rgb_light
|
|
brightness: 100%
|
|
red: 100%
|
|
green: 100%
|
|
blue: 1.0
|
|
- light.control:
|
|
id: test_monochromatic_light
|
|
state: on
|
|
- light.dim_relative:
|
|
id: test_monochromatic_light
|
|
relative_brightness: 5%
|
|
brightness_limits:
|
|
max_brightness: 90%
|
|
- light.turn_on:
|
|
id: test_addressable_transition
|
|
brightness: 50%
|
|
red: 100%
|
|
green: 0%
|
|
blue: 0%
|
|
transition_length: 500ms
|
|
- light.turn_on:
|
|
id: test_addressable_transition
|
|
brightness: 100%
|
|
red: 0%
|
|
green: 100%
|
|
blue: 0%
|
|
transition_length: 1s
|
|
|
|
light:
|
|
- platform: binary
|
|
id: test_binary_light
|
|
name: Binary Light
|
|
output: test_binary
|
|
effects:
|
|
- strobe:
|
|
on_state:
|
|
- logger.log: Binary light state changed
|
|
- platform: monochromatic
|
|
id: test_monochromatic_light
|
|
name: Monochromatic Light
|
|
output: test_ledc_1
|
|
gamma_correct: 2.8
|
|
default_transition_length: 2s
|
|
effects:
|
|
- strobe:
|
|
- flicker:
|
|
- flicker:
|
|
name: My Flicker
|
|
alpha: 98%
|
|
intensity: 1.5%
|
|
- lambda:
|
|
name: My Custom Effect
|
|
update_interval: 1s
|
|
lambda: |-
|
|
static int state = 0;
|
|
state += 1;
|
|
if (state == 4)
|
|
state = 0;
|
|
- pulse:
|
|
transition_length: 10s
|
|
update_interval: 20s
|
|
min_brightness: 10%
|
|
max_brightness: 90%
|
|
- pulse:
|
|
name: pulse2
|
|
transition_length:
|
|
on_length: 10s
|
|
off_length: 5s
|
|
update_interval: 15s
|
|
min_brightness: 10%
|
|
max_brightness: 90%
|
|
- platform: rgb
|
|
id: test_rgb_light
|
|
name: RGB Light
|
|
red: test_ledc_1
|
|
green: test_ledc_2
|
|
blue: test_ledc_3
|
|
- platform: rgbw
|
|
id: test_rgbw_light
|
|
name: RGBW Light
|
|
red: test_ledc_1
|
|
green: test_ledc_2
|
|
blue: test_ledc_3
|
|
white: test_ledc_4
|
|
color_interlock: true
|
|
- platform: rgbww
|
|
id: test_rgbww_light
|
|
name: RGBWW Light
|
|
red: test_ledc_1
|
|
green: test_ledc_2
|
|
blue: test_ledc_3
|
|
cold_white: test_ledc_4
|
|
warm_white: test_ledc_5
|
|
cold_white_color_temperature: 153 mireds
|
|
warm_white_color_temperature: 500 mireds
|
|
color_interlock: true
|
|
- platform: rgbct
|
|
id: test_rgbct_light
|
|
name: RGBCT Light
|
|
red: test_ledc_1
|
|
green: test_ledc_2
|
|
blue: test_ledc_3
|
|
color_temperature: test_ledc_4
|
|
white_brightness: test_ledc_5
|
|
cold_white_color_temperature: 153 mireds
|
|
warm_white_color_temperature: 500 mireds
|
|
color_interlock: true
|
|
- platform: cwww
|
|
id: test_cwww_light
|
|
name: CWWW Light
|
|
cold_white: test_ledc_1
|
|
warm_white: test_ledc_2
|
|
cold_white_color_temperature: 153 mireds
|
|
warm_white_color_temperature: 500 mireds
|
|
constant_brightness: true
|
|
- platform: color_temperature
|
|
id: test_color_temperature_light
|
|
name: CT Light
|
|
color_temperature: test_ledc_1
|
|
brightness: test_ledc_2
|
|
cold_white_color_temperature: 153 mireds
|
|
warm_white_color_temperature: 500 mireds
|
|
- platform: rgb
|
|
id: test_rgb_light_initial_state
|
|
name: RGB Light Initial State
|
|
red: test_ledc_1
|
|
green: test_ledc_2
|
|
blue: test_ledc_3
|
|
initial_state:
|
|
color_mode: rgb
|
|
red: 100%
|
|
green: 50%
|
|
blue: 50%
|
|
# Test StrobeLightEffect with multiple colors
|
|
- platform: monochromatic
|
|
id: test_strobe_multiple
|
|
name: Strobe Multiple Colors
|
|
output: test_ledc_1
|
|
effects:
|
|
- strobe:
|
|
name: Strobe Multi
|
|
colors:
|
|
- state: true
|
|
brightness: 100%
|
|
duration: 500ms
|
|
- state: false
|
|
duration: 250ms
|
|
- state: true
|
|
brightness: 50%
|
|
duration: 500ms
|
|
# Test StrobeLightEffect with transition
|
|
- platform: rgb
|
|
id: test_strobe_transition
|
|
name: Strobe With Transition
|
|
red: test_ledc_1
|
|
green: test_ledc_2
|
|
blue: test_ledc_3
|
|
effects:
|
|
- strobe:
|
|
name: Strobe Transition
|
|
colors:
|
|
- state: true
|
|
red: 100%
|
|
green: 0%
|
|
blue: 0%
|
|
duration: 1s
|
|
transition_length: 500ms
|
|
- state: true
|
|
red: 0%
|
|
green: 100%
|
|
blue: 0%
|
|
duration: 1s
|
|
transition_length: 500ms
|
|
- platform: partition
|
|
id: test_addressable_transition
|
|
name: Addressable Transition Test
|
|
default_transition_length: 1s
|
|
segments:
|
|
- single_light_id: test_rgb_light
|