mirror of
https://github.com/esphome/esphome.git
synced 2025-09-29 16:42:19 +01:00
Merge branch 'integration' into memory_api
This commit is contained in:
@@ -34,11 +34,12 @@ size_t Select::size() const {
|
|||||||
|
|
||||||
optional<size_t> Select::index_of(const std::string &option) const {
|
optional<size_t> Select::index_of(const std::string &option) const {
|
||||||
const auto &options = traits.get_options();
|
const auto &options = traits.get_options();
|
||||||
auto it = std::find(options.begin(), options.end(), option);
|
for (size_t i = 0; i < options.size(); i++) {
|
||||||
if (it == options.end()) {
|
if (options[i] == option) {
|
||||||
return {};
|
return i;
|
||||||
}
|
}
|
||||||
return std::distance(options.begin(), it);
|
}
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<size_t> Select::active_index() const {
|
optional<size_t> Select::active_index() const {
|
||||||
|
@@ -107,7 +107,7 @@ void SelectCall::perform() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find(options.begin(), options.end(), target_value) == options.end()) {
|
if (!parent->has_option(target_value)) {
|
||||||
ESP_LOGW(TAG, "'%s' - Option %s is not a valid option", name, target_value.c_str());
|
ESP_LOGW(TAG, "'%s' - Option %s is not a valid option", name, target_value.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user