mirror of
https://github.com/esphome/esphome.git
synced 2025-11-10 11:55:52 +00:00
preen
This commit is contained in:
@@ -7,15 +7,11 @@ namespace select {
|
|||||||
|
|
||||||
static const char *const TAG = "select";
|
static const char *const TAG = "select";
|
||||||
|
|
||||||
SelectCall &SelectCall::set_option(const std::string &option) {
|
SelectCall &SelectCall::set_option(const std::string &option) { return this->with_option(option); }
|
||||||
return this->with_operation(SELECT_OP_SET).with_option(option);
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectCall &SelectCall::set_option(const char *option) {
|
SelectCall &SelectCall::set_option(const char *option) { return this->with_option(option); }
|
||||||
return this->with_operation(SELECT_OP_SET).with_option(option);
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectCall &SelectCall::set_index(size_t index) { return this->with_operation(SELECT_OP_SET).with_index(index); }
|
SelectCall &SelectCall::set_index(size_t index) { return this->with_index(index); }
|
||||||
|
|
||||||
SelectCall &SelectCall::select_next(bool cycle) { return this->with_operation(SELECT_OP_NEXT).with_cycle(cycle); }
|
SelectCall &SelectCall::select_next(bool cycle) { return this->with_operation(SELECT_OP_NEXT).with_cycle(cycle); }
|
||||||
|
|
||||||
@@ -40,12 +36,14 @@ SelectCall &SelectCall::with_cycle(bool cycle) {
|
|||||||
SelectCall &SelectCall::with_option(const std::string &option) { return this->with_option(option.c_str()); }
|
SelectCall &SelectCall::with_option(const std::string &option) { return this->with_option(option.c_str()); }
|
||||||
|
|
||||||
SelectCall &SelectCall::with_option(const char *option) {
|
SelectCall &SelectCall::with_option(const char *option) {
|
||||||
|
this->operation_ = SELECT_OP_SET;
|
||||||
// Find the option index - this validates the option exists
|
// Find the option index - this validates the option exists
|
||||||
this->index_ = this->parent_->index_of(option);
|
this->index_ = this->parent_->index_of(option);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectCall &SelectCall::with_index(size_t index) {
|
SelectCall &SelectCall::with_index(size_t index) {
|
||||||
|
this->operation_ = SELECT_OP_SET;
|
||||||
if (index >= this->parent_->size()) {
|
if (index >= this->parent_->size()) {
|
||||||
ESP_LOGW(TAG, "'%s' - Index value %zu out of bounds", this->parent_->get_name().c_str(), index);
|
ESP_LOGW(TAG, "'%s' - Index value %zu out of bounds", this->parent_->get_name().c_str(), index);
|
||||||
this->index_ = {}; // Store nullopt for invalid index
|
this->index_ = {}; // Store nullopt for invalid index
|
||||||
|
|||||||
Reference in New Issue
Block a user