2018-10-17 20:44:37 +02:00
|
|
|
Template Text Sensor
|
|
|
|
====================
|
|
|
|
|
2018-11-14 22:12:27 +01:00
|
|
|
.. seo::
|
|
|
|
:description: Instructions for setting up template text sensors in esphomelib
|
2018-11-19 18:32:16 +01:00
|
|
|
:image: description.png
|
2018-11-14 22:12:27 +01:00
|
|
|
|
2018-10-17 20:44:37 +02:00
|
|
|
The ``template`` text sensor platform allows you to create a text sensor with templated values
|
|
|
|
using :ref:`lambdas <config-lambda>`.
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
.. code-block:: yaml
|
2018-10-17 20:44:37 +02:00
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
text_sensor:
|
|
|
|
- platform: template
|
|
|
|
name: "Template Text Sensor"
|
|
|
|
lambda: |-
|
2018-10-17 21:13:52 +02:00
|
|
|
return {"Hello World"};
|
2019-01-06 18:56:14 +01:00
|
|
|
update_interval: 60s
|
2018-10-17 20:44:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
Possible return values for the lambda:
|
|
|
|
|
2018-10-17 21:13:52 +02:00
|
|
|
- ``return {"STRING LITERAL"};`` the new value for the sensor of type ``std::string``. **Has to be** in
|
|
|
|
brackets ``{}``!
|
2018-10-17 20:44:37 +02:00
|
|
|
- ``return {};`` if you don't want to publish a new state (advanced).
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
- **name** (**Required**, string): The name of the text sensor.
|
|
|
|
- **lambda** (*Optional*, :ref:`lambda <config-lambda>`):
|
|
|
|
Lambda to be evaluated every update interval to get the new value of the text sensor
|
|
|
|
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the
|
2019-01-06 18:56:14 +01:00
|
|
|
text sensor. Defaults to ``60s``.
|
2018-10-17 20:44:37 +02:00
|
|
|
- **id** (*Optional*,:ref:`config-id`): Manually specify the ID used for code generation.
|
|
|
|
- All other options from :ref:`Text Sensor <config-text_sensor>` and :ref:`MQTT Component <config-mqtt-component>`.
|
|
|
|
|
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
|
|
|
- :ref:`automation`
|
|
|
|
- :doc:`API Reference </api/text_sensor/template>`
|
|
|
|
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/text_sensor/template.rst>`__
|
|
|
|
|
|
|
|
.. disqus::
|