2021-08-02 10:01:08 +02:00
|
|
|
Template Select
|
|
|
|
===============
|
|
|
|
|
|
|
|
.. seo::
|
2021-08-25 17:21:15 +02:00
|
|
|
:description: Instructions for setting up Template Select(s) with ESPHome.
|
2021-11-16 03:19:33 +01:00
|
|
|
:image: description.svg
|
2021-08-02 10:01:08 +02:00
|
|
|
|
2021-08-25 17:21:15 +02:00
|
|
|
The ``template`` Select platform allows you to create a Select with templated values
|
2021-08-02 10:01:08 +02:00
|
|
|
using :ref:`lambdas <config-lambda>`.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
select:
|
|
|
|
- platform: template
|
|
|
|
name: "Template select"
|
2021-09-04 04:47:03 +02:00
|
|
|
optimistic: true
|
2021-08-02 10:01:08 +02:00
|
|
|
options:
|
|
|
|
- one
|
|
|
|
- two
|
|
|
|
- three
|
|
|
|
initial_option: two
|
|
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
------------------------
|
|
|
|
|
2021-08-25 17:21:15 +02:00
|
|
|
- **name** (**Required**, string): The name of the Select.
|
|
|
|
- **options** (**Required**, list): The list of options this Select has.
|
2021-08-02 10:01:08 +02:00
|
|
|
- **lambda** (*Optional*, :ref:`lambda <config-lambda>`):
|
2021-09-04 04:47:03 +02:00
|
|
|
Lambda to be evaluated every update interval to get the current option of the select.
|
2021-08-02 10:01:08 +02:00
|
|
|
- **set_action** (*Optional*, :ref:`Action <config-action>`): The action that should
|
2021-08-25 17:21:15 +02:00
|
|
|
be performed when the remote (like Home Assistant's frontend) requests to set the Select option.
|
2021-09-04 04:47:03 +02:00
|
|
|
The new option is available to lambdas in the ``x`` variable.
|
|
|
|
- **update_interval** (*Optional*, :ref:`config-time`): The interval on which to update the select
|
|
|
|
by executing the ``lambda``. Defaults to ``60s``.
|
2021-08-02 10:01:08 +02:00
|
|
|
- **optimistic** (*Optional*, boolean): Whether to operate in optimistic mode - when in this mode,
|
2021-08-25 17:21:15 +02:00
|
|
|
any command sent to the Template Select will immediately update the reported state.
|
2021-08-02 10:01:08 +02:00
|
|
|
Cannot be used with ``lambda``. Defaults to ``false``.
|
|
|
|
- **restore_value** (*Optional*, boolean): Saves and loads the state to RTC/Flash.
|
|
|
|
Cannot be used with ``lambda``. Defaults to ``false``.
|
|
|
|
- **initial_option** (*Optional*, string): The option to set the option to on setup if not
|
|
|
|
restored with ``restore_value``.
|
|
|
|
Cannot be used with ``lambda``. Defaults to the first option in the ``options`` list.
|
|
|
|
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
|
|
|
|
- All other options from :ref:`Select <config-select>`.
|
|
|
|
|
|
|
|
``select.set`` Action
|
2021-09-04 04:47:03 +02:00
|
|
|
---------------------
|
2021-08-02 10:01:08 +02:00
|
|
|
|
2021-09-04 04:47:03 +02:00
|
|
|
You can also set an option for the template select from elsewhere in your YAML file
|
2021-08-02 10:01:08 +02:00
|
|
|
with the :ref:`select-set_action`.
|
|
|
|
|
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
|
|
|
- :ref:`automation`
|
|
|
|
- :apiref:`template/select/template_select.h`
|
|
|
|
- :ghedit:`Edit`
|