2021-07-12 21:20:18 +02:00
|
|
|
Template Number
|
|
|
|
===============
|
|
|
|
|
|
|
|
.. seo::
|
|
|
|
:description: Instructions for setting up template numbers with ESPHome.
|
|
|
|
:image: description.png
|
|
|
|
|
|
|
|
The ``template`` number platform allows you to create a number with templated values
|
|
|
|
using :ref:`lambdas <config-lambda>`.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
number:
|
|
|
|
- platform: template
|
|
|
|
name: "Template number"
|
2021-09-04 04:47:03 +02:00
|
|
|
optimistic: true
|
2021-07-12 21:20:18 +02:00
|
|
|
min_value: 0
|
|
|
|
max_value: 100
|
|
|
|
step: 1
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
- **name** (**Required**, string): The name of the number.
|
|
|
|
- **min_value** (**Required**, float): The minimum value this number can be.
|
|
|
|
- **max_value** (**Required**, float): The maximum value this number can be.
|
|
|
|
- **step** (**Required**, float): The granularity with which the number can be set.
|
|
|
|
- **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 value of the number.
|
2021-07-12 21:20:18 +02:00
|
|
|
- **set_action** (*Optional*, :ref:`Action <config-action>`): The action that should
|
2021-08-10 13:36:13 +02:00
|
|
|
be performed when the remote (like Home Assistant's frontend) requests to set the
|
|
|
|
number value. The new value is available to lambdas in the ``x`` variable.
|
2021-09-04 04:47:03 +02:00
|
|
|
- **update_interval** (*Optional*, :ref:`config-time`): The interval on which to update the number
|
|
|
|
by executing the ``lambda``. Defaults to ``60s``.
|
2021-07-12 21:20:18 +02:00
|
|
|
- **optimistic** (*Optional*, boolean): Whether to operate in optimistic mode - when in this mode,
|
|
|
|
any command sent to the template number will immediately update the reported state.
|
2021-07-20 05:40:43 +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_value** (*Optional*, float): The value to set the state to on setup if not
|
|
|
|
restored with ``restore_value``.
|
|
|
|
Cannot be used with ``lambda``. Defaults to ``min_value``.
|
2021-07-12 21:20:18 +02:00
|
|
|
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
|
2021-07-28 23:56:28 +02:00
|
|
|
- All other options from :ref:`Number <config-number>`.
|
2021-07-12 21:20:18 +02:00
|
|
|
|
|
|
|
``number.set`` Action
|
2021-09-04 04:47:03 +02:00
|
|
|
---------------------
|
2021-07-12 21:20:18 +02:00
|
|
|
|
2021-09-04 04:47:03 +02:00
|
|
|
You can also set the number for the template number from elsewhere in your YAML file
|
2021-07-12 21:20:18 +02:00
|
|
|
with the :ref:`number-set_action`.
|
|
|
|
|
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
|
|
|
- :ref:`automation`
|
|
|
|
- :apiref:`template/number/template_number.h`
|
|
|
|
- :ghedit:`Edit`
|