Fix text sensor outdated API docs (#70)

This commit is contained in:
Otto Winter 2018-10-26 22:27:01 +02:00 committed by GitHub
parent c01eefc0af
commit 8489ec555e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -297,6 +297,11 @@ use any string you pass it, like ``"ON"`` or ``"OFF"``.
// Shorthand:
it.printf(0, 0, id(my_font), "State: %s", id(my_binary_sensor).state ? "ON" : "OFF");
.. note::
For displaying external data on the display, for example data from your Home Assistant instance,
you can use the :doc:`/esphomeyaml/components/text_sensor/mqtt` (see the example there for more information).
.. _display-strftime:
Displaying Time

View File

@ -60,19 +60,19 @@ 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.
- ``publish_state()``: 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");
id(my_sensor).publish_state("Hello World");
- ``value``: Retrieve the current value of the sensor as an ``std::string`` object.
- ``.state``: 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;
std::string val = id(my_sensor).state;
ESP_LOGI("main", "Value of my sensor: %s", val.c_str());
See Also

View File

@ -27,7 +27,7 @@ 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
Please note you have to use the ``.c_str()`` method on the ``.state`` object together with the ``%s`` format
to use it in ``printf`` expressions.
.. code:: yaml
@ -43,7 +43,7 @@ to use it in ``printf`` expressions.
- platform: ...
# ...
lambda: |-
it.printf("The data is: %s", id(font), id(mysensor).value.c_str());
it.printf(0, 0, id(font), "The data is: %s", id(mysensor).state.c_str());
See Also
--------