mirror of
https://github.com/esphome/esphome-docs.git
synced 2025-03-01 03:51:36 +01:00
Add docs for select has_option(...) and has_index(...) (#2065)
Co-authored-by: Maurice Makaay <mmakaay1@xs4all.net>
This commit is contained in:
parent
528f0bfba9
commit
c51c935bf0
@ -282,7 +282,7 @@ advanced stuff (see the full API Reference for more info).
|
||||
auto size = id(my_select).size();
|
||||
ESP_LOGI("main", "Select has %d options", size);
|
||||
|
||||
- ``.index_of(<option name>)``: Retrieve the index offset for an option value.
|
||||
- ``.index_of(<option value>)``: Retrieve the index offset for an option value.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -317,6 +317,24 @@ advanced stuff (see the full API Reference for more info).
|
||||
ESP_LOGE("main", "Index %d does not exist", index);
|
||||
}
|
||||
|
||||
- ``.has_option(<option value>)``: Check if the select contains the given option value.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
auto option = "Happy";
|
||||
if (id(my_select).has_option(option)) {
|
||||
ESP_LOGI("main", "Select has option '%s'", option);
|
||||
}
|
||||
|
||||
- ``.has_index(<index offset>)``: Check if the select contains an option value for the given index offset.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
auto index = 3;
|
||||
if (id(my_select).has_index(index)) {
|
||||
ESP_LOGI("main", "Select has index offset %d", index);
|
||||
}
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user