mirror of
https://github.com/esphome/esphome.git
synced 2026-09-19 11:08:38 +00:00
[light] Fix ambiguous set_effect overload for const char*
When calling set_effect("None") from a lambda, the compiler cannot
choose between set_effect(optional<std::string>) and
set_effect(const std::string&) since both require one implicit
conversion from const char*. Add explicit const char* overload to
resolve the ambiguity.
Fixes https://github.com/esphome/esphome/issues/14728
This commit is contained in:
@@ -130,6 +130,8 @@ class LightCall {
|
||||
LightCall &set_effect(optional<std::string> effect);
|
||||
/// Set the effect of the light by its name.
|
||||
LightCall &set_effect(const std::string &effect) { return this->set_effect(effect.data(), effect.size()); }
|
||||
/// Set the effect of the light by its name (const char * overload to resolve ambiguity).
|
||||
LightCall &set_effect(const char *effect) { return this->set_effect(effect, strlen(effect)); }
|
||||
/// Set the effect of the light by its name and length (zero-copy from API).
|
||||
LightCall &set_effect(const char *effect, size_t len);
|
||||
/// Set the effect of the light by its internal index number (only for internal use).
|
||||
|
||||
Reference in New Issue
Block a user