mirror of
https://github.com/esphome/esphome-docs.git
synced 2025-01-22 21:41:39 +01:00
parent
0e540437cb
commit
b996e377da
@ -13,4 +13,5 @@ API Reference
|
||||
Switch <switch/index>
|
||||
Cover <cover/index>
|
||||
Display <display/index>
|
||||
Text Sensors <text_sensor/index>
|
||||
Miscellaneous <misc/index>
|
||||
|
40
api/text_sensor/index.rst
Normal file
40
api/text_sensor/index.rst
Normal file
@ -0,0 +1,40 @@
|
||||
Text Sensor
|
||||
===========
|
||||
|
||||
.. cpp:namespace:: nullptr
|
||||
|
||||
See :cpp:func:`Application::register_text_sensor`.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
version
|
||||
mqtt_subscribe
|
||||
template
|
||||
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
.. cpp:namespace:: nullptr
|
||||
|
||||
TextSensor
|
||||
**********
|
||||
|
||||
.. doxygenclass:: text_sensor::TextSensor
|
||||
:members:
|
||||
:protected-members:
|
||||
:undoc-members:
|
||||
|
||||
.. doxygenclass:: text_sensor::TextSensorValueTrigger
|
||||
:members:
|
||||
:protected-members:
|
||||
:undoc-members:
|
||||
|
||||
MQTTTextSensor
|
||||
**************
|
||||
|
||||
.. doxygenclass:: text_sensor::MQTTTextSensor
|
||||
:members:
|
||||
:protected-members:
|
||||
:undoc-members:
|
16
api/text_sensor/mqtt_subscribe.rst
Normal file
16
api/text_sensor/mqtt_subscribe.rst
Normal file
@ -0,0 +1,16 @@
|
||||
MQTT Subscribe Text Sensor
|
||||
==========================
|
||||
|
||||
.. cpp:namespace:: nullptr
|
||||
|
||||
See :cpp:func:`Application::make_mqtt_subscribe_text_sensor`.
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
.. cpp:namespace:: nullptr
|
||||
|
||||
.. doxygenclass:: text_sensor::MQTTSubscribeTextSensor
|
||||
:members:
|
||||
:protected-members:
|
||||
:undoc-members:
|
16
api/text_sensor/template.rst
Normal file
16
api/text_sensor/template.rst
Normal file
@ -0,0 +1,16 @@
|
||||
Template Text Sensor
|
||||
====================
|
||||
|
||||
.. cpp:namespace:: nullptr
|
||||
|
||||
See :cpp:func:`Application::make_template_text_sensor`.
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
.. cpp:namespace:: nullptr
|
||||
|
||||
.. doxygenclass:: text_sensor::TemplateTextSensor
|
||||
:members:
|
||||
:protected-members:
|
||||
:undoc-members:
|
16
api/text_sensor/version.rst
Normal file
16
api/text_sensor/version.rst
Normal file
@ -0,0 +1,16 @@
|
||||
Version Text Sensor
|
||||
===================
|
||||
|
||||
.. cpp:namespace:: nullptr
|
||||
|
||||
See :cpp:func:`Application::make_version_text_sensor`.
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
.. cpp:namespace:: nullptr
|
||||
|
||||
.. doxygenclass:: text_sensor::VersionTextSensor
|
||||
:members:
|
||||
:protected-members:
|
||||
:undoc-members:
|
@ -11,6 +11,7 @@ Components
|
||||
sensor/index
|
||||
switch/index
|
||||
display/index
|
||||
text_sensor/index
|
||||
ads1115
|
||||
dallas
|
||||
debug
|
||||
|
@ -313,7 +313,7 @@ advanced stuff (see the full :doc:`API Reference </api/sensor/index>` for more i
|
||||
|
||||
|
||||
See Also
|
||||
********
|
||||
--------
|
||||
|
||||
- :doc:`API Reference </api/sensor/index>`
|
||||
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/sensor/index.rst>`__
|
||||
|
BIN
esphomeyaml/components/text_sensor/images/version-ui.png
Normal file
BIN
esphomeyaml/components/text_sensor/images/version-ui.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
91
esphomeyaml/components/text_sensor/index.rst
Normal file
91
esphomeyaml/components/text_sensor/index.rst
Normal file
@ -0,0 +1,91 @@
|
||||
Text Sensor Component
|
||||
=====================
|
||||
|
||||
Text sensors are a lot like normal :doc:`sensors </esphomeyaml/components/sensor/index>`.
|
||||
But where the "normal" sensors only represent sensors that output **numbers**, this
|
||||
component can represent any *text*.
|
||||
|
||||
.. _config-text_sensor:
|
||||
|
||||
Base Text Sensor Configuration
|
||||
------------------------------
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
# Example sensor configuration
|
||||
name: Livingroom Temperature
|
||||
|
||||
# Optional variables:
|
||||
icon: "mdi:water-percent"
|
||||
|
||||
Configuration variables:
|
||||
|
||||
- **name** (**Required**, string): The name for the sensor.
|
||||
- **icon** (*Optional*, icon): Manually set the icon to use for the sensor in the frontend.
|
||||
|
||||
Automations:
|
||||
|
||||
- **on_value** (*Optional*, :ref:`Automation <automation>`): An automation to perform
|
||||
when a new value is published. See :ref:`text_sensor-on_value`.
|
||||
|
||||
Text Sensor Automation
|
||||
----------------------
|
||||
|
||||
You can access the most recent state of the sensor in :ref:`lambdas <config-lambda>` using
|
||||
``id(sensor_id).value``.
|
||||
|
||||
.. _text_sensor-on_value:
|
||||
|
||||
``on_value``
|
||||
************
|
||||
|
||||
This automation will be triggered when a new value is published.
|
||||
In :ref:`Lambdas <config-lambda>` you can get the value from the trigger with ``x``.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
text_sensor:
|
||||
- platform: version
|
||||
# ...
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD("main", "The current version is %s", x.c_str());
|
||||
|
||||
Configuration variables: See :ref:`Automation <automation>`.
|
||||
|
||||
lambda calls
|
||||
************
|
||||
|
||||
From :ref:`lambdas <config-lambda>`, you can call several methods on all text sensors to do some
|
||||
advanced stuff (see the full :doc:`API Reference </api/sensor/index>` for more info).
|
||||
|
||||
- ``push_new_value()``: Manually cause the sensor to push out a value.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
// Within lambda, push a value of "Hello World"
|
||||
id(my_sensor).push_new_value("Hello World");
|
||||
|
||||
- ``value``: Retrieve the current value of the sensor as an ``std::string`` object.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
// For example, create a custom log message when a value is received:
|
||||
std::string val = id(my_sensor).value;
|
||||
ESP_LOGI("main", "Value of my sensor: %s", val.c_str());
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- :doc:`API Reference </api/text_sensor/index>`
|
||||
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/text_sensor/index.rst>`__
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
version
|
||||
mqtt_subscribe
|
||||
template
|
||||
|
||||
.. disqus::
|
54
esphomeyaml/components/text_sensor/mqtt_subscribe.rst
Normal file
54
esphomeyaml/components/text_sensor/mqtt_subscribe.rst
Normal file
@ -0,0 +1,54 @@
|
||||
MQTT Subscribe Text Sensor
|
||||
==========================
|
||||
|
||||
The ``mqtt_subscribe`` text sensor platform allows you to get external data into esphomelib.
|
||||
The sensor will subscribe to messages on the given MQTT topic and save the most recent value
|
||||
in its ``id(mysensor).value``.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
# Example configuration entry
|
||||
text_sensor:
|
||||
- platform: mqtt_subscribe
|
||||
name: "Data from topic"
|
||||
id: mysensor
|
||||
topic: the/topic
|
||||
|
||||
Configuration variables:
|
||||
------------------------
|
||||
|
||||
- **name** (**Required**, string): The name of the text sensor.
|
||||
- **topic** (**Required**, string): The MQTT topic to listen for numeric messages.
|
||||
- **qos** (*Optional*, int): The MQTT QoS to subscribe with. Defaults to ``0``.
|
||||
- **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>`.
|
||||
|
||||
Example Usage for Displays
|
||||
--------------------------
|
||||
|
||||
This integration is especially useful for displays, to show external data on the display.
|
||||
Please note you have to use the ``.c_str()`` method on the value object together with the ``%s`` format
|
||||
to use it in ``printf`` expressions.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
# Example configuration entry
|
||||
text_sensor:
|
||||
- platform: mqtt_subscribe
|
||||
name: "Data from topic"
|
||||
id: mysensor
|
||||
topic: the/topic
|
||||
|
||||
display:
|
||||
- platform: ...
|
||||
# ...
|
||||
lambda: |-
|
||||
it.printf("The data is: %s", id(font), id(mysensor).value.c_str());
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- :doc:`API Reference </api/text_sensor/mqtt_subscribe>`
|
||||
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/text_sensor/mqtt_subscribe.rst>`__
|
||||
|
||||
.. disqus::
|
41
esphomeyaml/components/text_sensor/template.rst
Normal file
41
esphomeyaml/components/text_sensor/template.rst
Normal file
@ -0,0 +1,41 @@
|
||||
Template Text Sensor
|
||||
====================
|
||||
|
||||
The ``template`` text sensor platform allows you to create a text sensor with templated values
|
||||
using :ref:`lambdas <config-lambda>`.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
# Example configuration entry
|
||||
text_sensor:
|
||||
- platform: template
|
||||
name: "Template Text Sensor"
|
||||
lambda: |-
|
||||
return "Hello World";
|
||||
update_interval: 15s
|
||||
|
||||
|
||||
Possible return values for the lambda:
|
||||
|
||||
- ``return "STRING LITERAL";`` the new value for the sensor of type ``std::string``.
|
||||
- ``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
|
||||
text sensor. Defaults to ``15s``. See :ref:`sensor-default_filter`.
|
||||
- **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::
|
31
esphomeyaml/components/text_sensor/version.rst
Normal file
31
esphomeyaml/components/text_sensor/version.rst
Normal file
@ -0,0 +1,31 @@
|
||||
Version Text Sensor
|
||||
===================
|
||||
|
||||
The ``version`` text sensor platform exposes the esphomelib version the firmware
|
||||
was compiled against as a text sensor.
|
||||
|
||||
.. figure:: images/version-ui.png
|
||||
:align: center
|
||||
:width: 80.0%
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
# Example configuration entry
|
||||
text_sensor:
|
||||
- platform: version
|
||||
name: "Esphomelib Version"
|
||||
|
||||
Configuration variables:
|
||||
------------------------
|
||||
|
||||
- **name** (**Required**, string): The name of the text sensor.
|
||||
- **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
|
||||
--------
|
||||
|
||||
- :doc:`API Reference </api/text_sensor/version>`
|
||||
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/text_sensor/version.rst>`__
|
||||
|
||||
.. disqus::
|
@ -624,6 +624,32 @@ Cover Components
|
||||
:class: component-image
|
||||
.. _Template Cover: /esphomeyaml/components/cover/template.html
|
||||
|
||||
Text Sensor Components
|
||||
----------------------
|
||||
|
||||
================================================== ================================================== ==================================================
|
||||
|Text Sensor Core|_ |MQTT Subscribe|_ |Version|_
|
||||
-------------------------------------------------- -------------------------------------------------- --------------------------------------------------
|
||||
`Text Sensor Core`_ `MQTT Subscribe`_ `Version`_
|
||||
-------------------------------------------------- -------------------------------------------------- --------------------------------------------------
|
||||
|Template Text Sensor|_
|
||||
-------------------------------------------------- -------------------------------------------------- --------------------------------------------------
|
||||
`Template Text Sensor`_
|
||||
================================================== ================================================== ==================================================
|
||||
|
||||
.. |Text Sensor Core| image:: /esphomeyaml/images/folder-open.svg
|
||||
:class: component-image
|
||||
.. _Text Sensor Core: /esphomeyaml/components/text_sensor/index.html
|
||||
.. |MQTT Subscribe| image:: /esphomeyaml/images/mqtt.png
|
||||
:class: component-image
|
||||
.. _MQTT Subscribe: /esphomeyaml/components/text_sensor/mqtt_subscribe.html
|
||||
.. |Version| image:: /esphomeyaml/images/new-box.svg
|
||||
:class: component-image
|
||||
.. _Version: /esphomeyaml/components/text_sensor/version.html
|
||||
.. |Template Text Sensor| image:: /esphomeyaml/images/description.svg
|
||||
:class: component-image
|
||||
.. _Template Text Sensor: /esphomeyaml/components/text_sensor/template.html
|
||||
|
||||
|
||||
Misc Components
|
||||
---------------
|
||||
|
4
esphomeyaml/text_sensor.csv
Normal file
4
esphomeyaml/text_sensor.csv
Normal file
@ -0,0 +1,4 @@
|
||||
Text Sensor Core, components/text_sensor/index, folder-open.svg
|
||||
MQTT Subscribe, components/text_sensor/mqtt_subscribe, mqtt.png
|
||||
Version, components/text_sensor/version, new-box.svg
|
||||
Template Text Sensor, components/text_sensor/template, description.svg
|
|
Loading…
Reference in New Issue
Block a user