Added basic usage example (#2498)

* Added basic usage example

Document is not easy to follow for people who do not have some experience using ESPHome. I added simple usage example to help them starting up.

* Update index.rst

Co-authored-by: H. Árkosi Róbert <robreg@zsurob.hu>
This commit is contained in:
pedjas 2022-12-14 17:49:11 +01:00 committed by GitHub
parent d931e55d50
commit 3d4d6bdca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions

View File

@ -334,6 +334,30 @@ advanced stuff (see the full API Reference for more info).
if (id(my_select).has_index(index)) {
ESP_LOGI("main", "Select has index offset %d", index);
}
Example
-------
Setting up three options and set component state to selected option value.
.. code-block:: yaml
select:
- platform: template
name: Mode
id: mode
options:
- "Option1"
- "Option2"
- "Option3"
set_action:
- logger.log:
format: "Chosen option: %s"
args: ["x.c_str()"]
- lambda: |-
id(mode).state = x.c_str();
See Also
--------