mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-12-24 17:08:15 +01:00
Make naming convention consistent (#62)
This commit is contained in:
parent
a5f07bf923
commit
09b2374aef
@ -14,14 +14,9 @@ Supported Binary Sensors
|
||||
------------------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
esp32_touch
|
||||
gpio
|
||||
pn532
|
||||
rdm6300
|
||||
remote_receiver
|
||||
status
|
||||
template
|
||||
*
|
||||
|
||||
Example Usage
|
||||
-------------
|
||||
|
@ -5,8 +5,9 @@ Supported Covers
|
||||
----------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
template
|
||||
*
|
||||
|
||||
Example Usage
|
||||
-------------
|
||||
|
@ -5,12 +5,9 @@ Supported Displays
|
||||
------------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
lcd_display
|
||||
max7219
|
||||
nextion
|
||||
ssd1306
|
||||
waveshare_epaper
|
||||
*
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
@ -8,7 +8,9 @@ access a combined :cpp:class:`LightState` object and use only that to set state
|
||||
state updates.
|
||||
|
||||
.. toctree::
|
||||
fastled.rst
|
||||
:glob:
|
||||
|
||||
*
|
||||
|
||||
Example Usage
|
||||
-------------
|
||||
|
@ -2,9 +2,6 @@ Miscellaneous Components
|
||||
========================
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
pcf8574
|
||||
esp32_ble_tracker
|
||||
debug
|
||||
status_led
|
||||
esp32_ble_beacon
|
||||
*
|
||||
|
@ -4,10 +4,9 @@ Output
|
||||
The `output` namespace contains all peripheral output components.
|
||||
|
||||
.. toctree::
|
||||
GPIO Binary Output <gpio-binary>
|
||||
LEDC PWM Output <ledc>
|
||||
PCA9685 Output <pca9685>
|
||||
ESP8266 Software PWM <esp8266-pwm>
|
||||
:glob:
|
||||
|
||||
*
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
@ -8,43 +8,9 @@ The `sensor` namespace contains all sensors.
|
||||
See :cpp:func:`Application::register_sensor`.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
adc
|
||||
ads1115
|
||||
bh1750
|
||||
bme280
|
||||
bme680
|
||||
bmp085
|
||||
bmp280
|
||||
cse7766
|
||||
dallas
|
||||
dht
|
||||
dht12
|
||||
duty_cycle
|
||||
esp32_hall
|
||||
hdc1080
|
||||
hlw8012
|
||||
hmc5883l
|
||||
htu21d
|
||||
hx711
|
||||
ina219
|
||||
ina3221
|
||||
max6675
|
||||
mhz19
|
||||
mpu6050
|
||||
mqtt_subscribe
|
||||
ms5611
|
||||
pmsx003
|
||||
pulse_counter
|
||||
rotary_encoder
|
||||
sht3xd
|
||||
tcs34725
|
||||
template
|
||||
tsl2561
|
||||
ultrasonic
|
||||
uptime
|
||||
wifi_signal
|
||||
*
|
||||
|
||||
|
||||
API Reference
|
||||
|
@ -4,12 +4,9 @@ Switch
|
||||
The `switch_` namespace contains all switch helpers.
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
remote_transmitter
|
||||
restart
|
||||
shutdown
|
||||
template
|
||||
uart
|
||||
*
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
@ -61,7 +61,7 @@ They are similar to :ref:`Sensor Filters <sensor-filters>`.
|
||||
- delayed_on: 100ms
|
||||
- delayed_off: 100ms
|
||||
- lambda: >-
|
||||
if (id(other_binary_sensor).value) {
|
||||
if (id(other_binary_sensor).state) {
|
||||
return x;
|
||||
} else {
|
||||
return {};
|
||||
@ -93,7 +93,7 @@ perfectly fit every use case, but at least makes the naming consistent. For exam
|
||||
in the first moment when the button on your mouse is pushed down.
|
||||
|
||||
You can access the current state of the binary sensor in :ref:`lambdas <config-lambda>` using
|
||||
``id(binary_sensor_id).value``.
|
||||
``id(binary_sensor_id).state``.
|
||||
|
||||
.. _binary_sensor-on_press:
|
||||
|
||||
@ -206,12 +206,12 @@ advanced stuff (see the full :doc:`API Reference </api/binary_sensor/index>` for
|
||||
// Within lambda, publish an ON state.
|
||||
id(my_binary_sensor).publish_state(true);
|
||||
|
||||
- ``value``: Retrieve the current value of the binary sensor.
|
||||
- ``.state``: Retrieve the current state of the binary sensor.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
// Within lambda, get the binary sensor state and conditionally do something
|
||||
if (id(my_binary_sensor).value) {
|
||||
if (id(my_binary_sensor).state) {
|
||||
// Binary sensor is ON, do something here
|
||||
} else {
|
||||
// Binary sensor is OFF, do something else here
|
||||
@ -226,15 +226,8 @@ See Also
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
gpio
|
||||
status
|
||||
esp32_ble_tracker
|
||||
esp32_touch
|
||||
template
|
||||
remote_receiver
|
||||
pn532
|
||||
rdm6300
|
||||
nextion
|
||||
*
|
||||
|
||||
.. disqus::
|
||||
|
@ -14,12 +14,12 @@ a binary sensor.
|
||||
- platform: template
|
||||
name: "Garage Door Open"
|
||||
lambda: >-
|
||||
if (isnan(id(ultrasonic_sensor1).value)) {
|
||||
if (isnan(id(ultrasonic_sensor1).state)) {
|
||||
// isnan checks if the ultrasonic sensor echo
|
||||
// has timed out, resulting in a NaN (not a number) state
|
||||
// in that case, return {} to indicate that we don't know.
|
||||
return {};
|
||||
} else if (id(ultrasonic_sensor1).value > 30) {
|
||||
} else if (id(ultrasonic_sensor1).state > 30) {
|
||||
// Garage Door is open.
|
||||
return true;
|
||||
} else {
|
||||
|
@ -16,8 +16,15 @@ This action opens the cover with the given ID when executed.
|
||||
|
||||
on_...:
|
||||
then:
|
||||
- cover.open:
|
||||
id: cover_1
|
||||
- cover.open: cover_1
|
||||
|
||||
.. note::
|
||||
|
||||
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
id(cover_1).open();
|
||||
|
||||
.. _cover-close_action:
|
||||
|
||||
@ -30,8 +37,15 @@ This action closes the cover with the given ID when executed.
|
||||
|
||||
on_...:
|
||||
then:
|
||||
- cover.close:
|
||||
id: cover_1
|
||||
- cover.close: cover_1
|
||||
|
||||
.. note::
|
||||
|
||||
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
id(cover_1).close();
|
||||
|
||||
.. _cover-stop_action:
|
||||
|
||||
@ -44,8 +58,15 @@ This action stops the cover with the given ID when executed.
|
||||
|
||||
on_...:
|
||||
then:
|
||||
- cover.stop:
|
||||
id: cover_1
|
||||
- cover.stop: cover_1
|
||||
|
||||
.. note::
|
||||
|
||||
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
id(cover_1).stop();
|
||||
|
||||
|
||||
lambda calls
|
||||
@ -69,34 +90,10 @@ advanced stuff (see the full :doc:`API Reference </api/cover/index>` for more in
|
||||
|
||||
if (id(my_cover).state == cover::COVER_OPEN) {
|
||||
// Cover is open
|
||||
} else if (id(my_cover).state == cover::COVER_CLOSED) {
|
||||
// Cover is closed
|
||||
} else {
|
||||
// The cover hasn't reported any state yet.
|
||||
// Cover is closed
|
||||
}
|
||||
|
||||
- ``open()``: Manually cause the cover to open from code. Similar to the ``cover.open``
|
||||
action, but can be used in complex lambda expressions.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
id(my_cover).open();
|
||||
|
||||
- ``close()``: Manually cause the cover to close from code. Similar to the ``cover.close``
|
||||
action, but can be used in complex lambda expressions.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
id(my_cover).close();
|
||||
|
||||
- ``stop()``: Manually cause the cover to stop from code. Similar to the ``cover.stop``
|
||||
action, but can be used in complex lambda expressions.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
id(my_cover).stop();
|
||||
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
@ -105,7 +102,8 @@ See Also
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
template.rst
|
||||
*
|
||||
|
||||
.. disqus::
|
||||
|
@ -16,7 +16,7 @@ as a cover and can be controlled through the frontend.
|
||||
- platform: template
|
||||
name: "Template Cover"
|
||||
lambda: >-
|
||||
if (id(top_end_stop).value) {
|
||||
if (id(top_end_stop).state) {
|
||||
return cover::COVER_OPEN;
|
||||
} else {
|
||||
return cover::COVER_CLOSED;
|
||||
|
@ -232,11 +232,11 @@ For example, a printf call can look like this:
|
||||
- platform: ...
|
||||
# ...
|
||||
lambda: |-
|
||||
it.printf(0, 0, id(my_font), "The sensor value is: %.1f", id(my_sensor).value);
|
||||
it.printf(0, 0, id(my_font), "The sensor value is: %.1f", id(my_sensor).state);
|
||||
// If the sensor has the value 30.02, the result will be: "The sensor value is: 30.0"
|
||||
|
||||
As you can see, when you call ``printf`` most of the string is printed as-is, but when this weird percent sign with some
|
||||
stuff after it is encountered, it is magically replaced by the argument after the format (here ``id(my_sensor).value``).
|
||||
stuff after it is encountered, it is magically replaced by the argument after the format (here ``id(my_sensor).state``).
|
||||
|
||||
Every time you type a percent sign ``%`` in a printf format string, it will treat the following letters as a format tag
|
||||
until a so-called "specifier" is encountered (in this case ``f``). You can read more about it `here <https://www.tutorialspoint.com/c_standard_library/c_function_printf.htm>`__,
|
||||
@ -270,7 +270,7 @@ arguments after the format string in the right order.
|
||||
# ...
|
||||
lambda: |-
|
||||
// %% - literal % sign
|
||||
it.printf(0, 0, id(my_font), "Temperature: %.1f°C, Humidity: %.1f%%", id(temperature).value, id(humidity).value);
|
||||
it.printf(0, 0, id(my_font), "Temperature: %.1f°C, Humidity: %.1f%%", id(temperature).state, id(humidity).state);
|
||||
|
||||
|
||||
The last printf tip for use in displays I will discuss here is how to display binary sensor values. You
|
||||
@ -289,13 +289,13 @@ use any string you pass it, like ``"ON"`` or ``"OFF"``.
|
||||
- platform: ...
|
||||
# ...
|
||||
lambda: |-
|
||||
if (id(my_binary_sensor).value) {
|
||||
if (id(my_binary_sensor).state) {
|
||||
it.print(0, 0, id(my_font), "state: ON");
|
||||
} else {
|
||||
it.print(0, 0, id(my_font), "state: OFF");
|
||||
}
|
||||
// Shorthand:
|
||||
it.printf(0, 0, id(my_font), "State: %s", id(my_binary_sensor).value ? "ON" : "OFF");
|
||||
it.printf(0, 0, id(my_font), "State: %s", id(my_binary_sensor).state ? "ON" : "OFF");
|
||||
|
||||
.. _display-strftime:
|
||||
|
||||
@ -347,13 +347,8 @@ See Also
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
lcd_gpio
|
||||
lcd_pcf8574
|
||||
max7219
|
||||
nextion
|
||||
ssd1306_i2c
|
||||
ssd1306_spi
|
||||
waveshare_epaper
|
||||
*
|
||||
|
||||
.. disqus::
|
||||
|
@ -80,11 +80,11 @@ by default which means the character at the top left.
|
||||
it.print(1, 1, "1");
|
||||
|
||||
// Let's write a sensor value (let's assume it's 42.1)
|
||||
it.printf("%.1f", id(my_sensor).value);
|
||||
it.printf("%.1f", id(my_sensor).state);
|
||||
// Result: "42.1" (the dot will appear on the "2" segment)
|
||||
|
||||
// Print a right-padded sensor value with 0 digits after the decimal
|
||||
it.printf("Sensor value: %8.0f", id(my_sensor).value);
|
||||
it.printf("Sensor value: %8.0f", id(my_sensor).state);
|
||||
// Result: "Sensor value: 42"
|
||||
|
||||
// Print the current time
|
||||
|
@ -86,13 +86,13 @@ segment of the previous position will be enabled.
|
||||
// Result: "01 "
|
||||
|
||||
// Let's write a sensor value (let's assume it's 42.1)
|
||||
it.printf(3, "%.1f", id(my_sensor).value);
|
||||
it.printf(3, "%.1f", id(my_sensor).state);
|
||||
// Result: "01 42.1 " (the dot will appear on the "2" segment)
|
||||
|
||||
// Overwrite the previous content with blank
|
||||
it.print(" ");
|
||||
// Print a right-padded sensor value with 0 digits after the decimal
|
||||
it.printf("SENS%4.0f", id(my_sensor).value);
|
||||
it.printf("SENS%4.0f", id(my_sensor).state);
|
||||
// Result: "SENS 42"
|
||||
|
||||
// Print the current time
|
||||
|
@ -72,7 +72,7 @@ you can call to populate data on the display:
|
||||
it.set_component_text("textview", "Hello World!");
|
||||
|
||||
// set the text of a component with formatting
|
||||
it.set_component_text("textview", "The uptime is: %.1f", id(uptime_sensor).value);
|
||||
it.set_component_text("textview", "The uptime is: %.1f", id(uptime_sensor).state);
|
||||
|
||||
|
||||
Please see :ref:`display-printf` for a quick introduction into the ``printf`` formatting rules and
|
||||
|
@ -45,8 +45,7 @@ Toggles the ON/OFF state of the fan with the given ID when executed.
|
||||
|
||||
on_...:
|
||||
then:
|
||||
- fan.toggle:
|
||||
id: fan_1
|
||||
- fan.toggle: fan_1
|
||||
|
||||
.. _fan-turn_off_action:
|
||||
|
||||
@ -59,8 +58,7 @@ Turns the fan with the given ID off when executed.
|
||||
|
||||
on_...:
|
||||
then:
|
||||
- fan.turn_off:
|
||||
id: fan_1
|
||||
- fan.turn_off: fan_1
|
||||
|
||||
.. _fan-turn_on_action:
|
||||
|
||||
@ -93,8 +91,8 @@ Full Fan Index
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
binary.rst
|
||||
speed.rst
|
||||
*
|
||||
|
||||
.. disqus::
|
||||
|
@ -25,6 +25,16 @@ Configuration options:
|
||||
- **transition_length** (*Optional*, :ref:`config-time`, :ref:`templatable <config-templatable>`): The length of the transition
|
||||
if the light supports it.
|
||||
|
||||
.. note::
|
||||
|
||||
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
auto call = id(light_1).toggle();
|
||||
// perform action:
|
||||
call.perform();
|
||||
|
||||
.. _light-turn_on_action:
|
||||
|
||||
``light.turn_on`` Action
|
||||
@ -48,7 +58,7 @@ This action turns a light with the given ID on when executed.
|
||||
id: light_1
|
||||
brightness: !lambda >-
|
||||
// output value must be in range 0 - 1.0
|
||||
return id(some_sensor).value / 100.0;
|
||||
return id(some_sensor).state / 100.0;
|
||||
|
||||
Configuration options:
|
||||
|
||||
@ -70,6 +80,21 @@ Configuration options:
|
||||
- **effect** (*Optional*, string, :ref:`templatable <config-templatable>`): If set, will attempt to
|
||||
start an effect with the given name.
|
||||
|
||||
.. note::
|
||||
|
||||
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
auto call = id(light_1).turn_on();
|
||||
// set parameters (optional)
|
||||
call.set_transition_length(1000); // in ms
|
||||
call.set_brightness(1.0); // 1.0 is full brightness
|
||||
call.set_rgb(1.0, 1.0, 1.0); // color, 1.0 is fully lit
|
||||
call.set_effect("The Effect");
|
||||
// perform action:
|
||||
call.perform();
|
||||
|
||||
.. _light-turn_off_action:
|
||||
|
||||
``light.turn_off`` Action
|
||||
@ -90,7 +115,17 @@ Configuration options:
|
||||
- **transition_length** (*Optional*, :ref:`config-time`, :ref:`templatable <config-templatable>`): The length of the transition
|
||||
if the light supports it.
|
||||
|
||||
This action turns a switch with the given ID off when executed.
|
||||
.. note::
|
||||
|
||||
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
auto call = id(light_1).turn_off();
|
||||
// set parameters (optional)
|
||||
call.set_transition_length(1000); // in ms
|
||||
// perform action:
|
||||
call.perform();
|
||||
|
||||
.. _light-effects:
|
||||
|
||||
@ -462,14 +497,8 @@ See Also
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
binary.rst
|
||||
cwww.rst
|
||||
monochromatic.rst
|
||||
rgb.rst
|
||||
rgbw.rst
|
||||
rgbww.rst
|
||||
fastled_clockless.rst
|
||||
fastled_spi.rst
|
||||
*
|
||||
|
||||
.. disqus::
|
||||
|
@ -384,10 +384,10 @@ Publish an MQTT message on a topic using this action in automations.
|
||||
# Templated:
|
||||
- mqtt.publish:
|
||||
topic: !lambda >-
|
||||
if (id(reed_switch).value) return "topic1";
|
||||
if (id(reed_switch).state) return "topic1";
|
||||
else return "topic2";
|
||||
payload: !lambda >-
|
||||
return id(reed_switch).value ? "YES" : "NO";
|
||||
return id(reed_switch).state ? "YES" : "NO";
|
||||
|
||||
Configuration options:
|
||||
|
||||
|
@ -52,6 +52,14 @@ This action turns the output with the given ID on when executed.
|
||||
then:
|
||||
- output.turn_on: relay_1
|
||||
|
||||
.. note::
|
||||
|
||||
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
id(relay_1).turn_on();
|
||||
|
||||
.. _output-turn_off_action:
|
||||
|
||||
``output.turn_off`` Action
|
||||
@ -65,6 +73,14 @@ This action turns the output with the given ID off when executed.
|
||||
then:
|
||||
- output.turn_off: relay_1
|
||||
|
||||
.. note::
|
||||
|
||||
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
id(relay_1).turn_off();
|
||||
|
||||
.. _output-set_level_action:
|
||||
|
||||
``output.set_level`` Action
|
||||
@ -81,6 +97,15 @@ works with floating point outputs like ESP8266 PWM or LEDC.
|
||||
id: output_1
|
||||
level: 50%
|
||||
|
||||
.. note::
|
||||
|
||||
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
// range is 0.0 (off) to 1.0 (on)
|
||||
id(relay_1).set_level(0.5);
|
||||
|
||||
Full Output Index
|
||||
-----------------
|
||||
|
||||
@ -96,10 +121,8 @@ Full Output Index
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
esp8266_pwm.rst
|
||||
gpio.rst
|
||||
ledc.rst
|
||||
pca9685.rst
|
||||
*
|
||||
|
||||
.. disqus::
|
||||
|
@ -13,7 +13,7 @@ your configuration for this sensor to work.
|
||||
:align: center
|
||||
:width: 50.0%
|
||||
|
||||
BMP180 Temperature & Pressure Sensor..
|
||||
BMP180 Temperature & Pressure Sensor.
|
||||
|
||||
.. figure:: images/temperature-pressure.png
|
||||
:align: center
|
||||
@ -31,7 +31,7 @@ your configuration for this sensor to work.
|
||||
update_interval: 15s
|
||||
|
||||
Configuration variables:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
------------------------
|
||||
|
||||
- **temperature** (**Required**): The information for the temperature sensor.
|
||||
|
||||
@ -52,7 +52,7 @@ Configuration variables:
|
||||
sensor. Defaults to ``15s``. See :ref:`sensor-default_filter`.
|
||||
|
||||
See Also
|
||||
^^^^^^^^
|
||||
--------
|
||||
|
||||
- :ref:`sensor-filters`
|
||||
- :doc:`bme280`
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
@ -138,7 +138,7 @@ Let's also now make our sensor actually *output* values (42 for now):
|
||||
// class CustomSensor ...
|
||||
// ... previous code
|
||||
void update() override {
|
||||
push_new_value(42.0); // 42°C
|
||||
publish_state(42.0); // 42°C
|
||||
}
|
||||
|
||||
std::string unit_of_measurement() override { return "°C"; }
|
||||
@ -255,7 +255,7 @@ Then update our sensor for BMP180 support:
|
||||
|
||||
void update() override {
|
||||
int pressure = bmp.readPressure(); // in Pa, or 1/100 hPa
|
||||
push_new_value(pressure / 100.0); // convert to hPa
|
||||
publish_state(pressure / 100.0); // convert to hPa
|
||||
}
|
||||
|
||||
std::string unit_of_measurement() override { return "hPa"; }
|
||||
@ -330,10 +330,10 @@ Let's look at what that could look like in code:
|
||||
void update() override {
|
||||
// This is the actual sensor reading logic.
|
||||
int pressure = bmp.readPressure();
|
||||
pressure_sensor->push_new_value(pressure / 100.0);
|
||||
pressure_sensor->publish_state(pressure / 100.0);
|
||||
|
||||
float temperature = bmp.readTemperature();
|
||||
temperature_sensor->push_new_value(temperature);
|
||||
temperature_sensor->publish_state(temperature);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -29,4 +29,11 @@ Configuration variables:
|
||||
- **id** (*Optional*, :ref:`config-id`): Set the ID of this sensor for use in lambdas.
|
||||
- All other options from :ref:`Sensor <config-sensor>` and :ref:`MQTT Component <config-mqtt-component>`.
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- :ref:`sensor-filters`
|
||||
- :doc:`API Reference </api/sensor/duty_cycle>`
|
||||
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/components/sensor/duty_cycle.rst>`__
|
||||
|
||||
.. disqus::
|
||||
|
@ -195,15 +195,17 @@ directly, put an empty ``filters:`` block in your configuration:
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
# Example configuration entry
|
||||
sensor:
|
||||
- platform: ...
|
||||
filters:
|
||||
- platform: adc
|
||||
# ...
|
||||
filters: []
|
||||
|
||||
Sensor Automation
|
||||
-----------------
|
||||
|
||||
You can access the most recent state of the sensor in :ref:`lambdas <config-lambda>` using
|
||||
``id(sensor_id).value`` and the most recent raw state using ``id(sensor_id).raw_value``.
|
||||
``id(sensor_id).state`` and the most recent raw state using ``id(sensor_id).raw_value``.
|
||||
|
||||
.. _sensor-on_value:
|
||||
|
||||
@ -287,29 +289,29 @@ lambda calls
|
||||
From :ref:`lambdas <config-lambda>`, you can call several methods on all 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. It will then
|
||||
- ``publish_state()``: Manually cause the sensor to push out a value. It will then
|
||||
be processed by the sensor filters, and once done be published to MQTT.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
// Within lambda, push a value of 42.0
|
||||
id(my_sensor).push_new_value(42.0);
|
||||
id(my_sensor).publish_state(42.0);
|
||||
|
||||
- ``value``: Retrieve the current value of the sensor that has passed through all sensor filters.
|
||||
- ``.state``: Retrieve the current value of the sensor that has passed through all sensor filters.
|
||||
Is ``NAN`` if no value has gotten through all filters yet.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
// For example, create a custom log message when a value is received:
|
||||
ESP_LOGI("main", "Value of my sensor: %f", id(my_sensor).value);
|
||||
ESP_LOGI("main", "Value of my sensor: %f", id(my_sensor).state);
|
||||
|
||||
- ``raw_value``: Retrieve the current value of the sensor that has not passed through any filters
|
||||
- ``raw_state``: Retrieve the current value of the sensor that has not passed through any filters
|
||||
Is ``NAN`` if no value if no value has been pushed by the sensor itself yet.
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
// For example, create a custom log message when a value is received:
|
||||
ESP_LOGI("main", "Raw Value of my sensor: %f", id(my_sensor).value);
|
||||
ESP_LOGI("main", "Raw Value of my sensor: %f", id(my_sensor).raw_state);
|
||||
|
||||
|
||||
See Also
|
||||
@ -320,45 +322,8 @@ See Also
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
adc
|
||||
ads1115
|
||||
bh1750
|
||||
ble_rssi
|
||||
bme280
|
||||
bme680
|
||||
bmp085
|
||||
bmp280
|
||||
cse7766
|
||||
custom
|
||||
dallas
|
||||
dht
|
||||
dht12
|
||||
duty_cycle
|
||||
esp32_hall
|
||||
hdc1080
|
||||
hlw8012
|
||||
hmc5883l
|
||||
htu21d
|
||||
hx711
|
||||
ina219
|
||||
ina3221
|
||||
max6675
|
||||
mhz19
|
||||
mpu6050
|
||||
mqtt_subscribe
|
||||
ms5611
|
||||
pulse_counter
|
||||
pmsx003
|
||||
rotary_encoder
|
||||
sht3xd
|
||||
tcs34725
|
||||
template
|
||||
tsl2561
|
||||
ultrasonic
|
||||
uptime
|
||||
wifi_signal
|
||||
xiaomi_miflora
|
||||
xiaomi_mijia
|
||||
*
|
||||
|
||||
.. disqus::
|
||||
|
@ -11,7 +11,7 @@ using :ref:`lambdas <config-lambda>`.
|
||||
- platform: template
|
||||
name: "Template Sensor"
|
||||
lambda: >-
|
||||
if (id(some_binary_sensor).value) {
|
||||
if (id(some_binary_sensor).state) {
|
||||
return 42.0;
|
||||
} else {
|
||||
return 0.0;
|
||||
|
@ -88,7 +88,7 @@ advanced stuff (see the full :doc:`API Reference </api/cover/index>` for more in
|
||||
.. code:: yaml
|
||||
|
||||
// Within lambda, get the switch state and conditionally do something
|
||||
if (id(my_switch).value) {
|
||||
if (id(my_switch).state) {
|
||||
// Switch is ON, do something here
|
||||
} else {
|
||||
// Switch is OFF, do something else here
|
||||
@ -113,13 +113,8 @@ See Also
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
gpio
|
||||
output
|
||||
remote_transmitter
|
||||
restart
|
||||
shutdown
|
||||
template
|
||||
uart
|
||||
*
|
||||
|
||||
.. disqus::
|
||||
|
@ -12,7 +12,7 @@ as a switch and can be controlled through the frontend.
|
||||
- platform: template
|
||||
name: "Template Switch"
|
||||
lambda: >-
|
||||
if (id(some_binary_sensor).value) {
|
||||
if (id(some_binary_sensor).state) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -48,29 +48,21 @@ Of the four main components (button sensor, 2 relays switches and the cover), on
|
||||
# logic for cycling through movements: open->stop->close->stop->...
|
||||
- lambda: |
|
||||
if (id(cover).state == cover::COVER_OPEN) {
|
||||
if (id(open).value){
|
||||
if (id(open).state){
|
||||
// cover is in opening movement, stop it
|
||||
id(cover).stop();
|
||||
} else {
|
||||
// cover has finished opening, close it
|
||||
id(cover).close();
|
||||
}
|
||||
} else if (id(cover).state == cover::COVER_CLOSED) {
|
||||
if (id(close).value){
|
||||
} else {
|
||||
if (id(close).state){
|
||||
// cover is in closing movement, stop it
|
||||
id(cover).stop();
|
||||
} else {
|
||||
// cover has finished closing, open it
|
||||
id(cover).open();
|
||||
}
|
||||
} else {
|
||||
// state of cover is not known
|
||||
if (id(open).value || id(close).value){
|
||||
// cover is either opening or closing, stop it
|
||||
id(cover).stop();
|
||||
} else {
|
||||
id(cover).open();
|
||||
}
|
||||
}
|
||||
|
||||
switch:
|
||||
|
@ -2,11 +2,6 @@ Cookbook
|
||||
========
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
garage-door
|
||||
pir
|
||||
bruh
|
||||
temt6000
|
||||
relay
|
||||
power_meter
|
||||
dual-r2-cover
|
||||
*
|
||||
|
@ -2,12 +2,6 @@ Cookbook
|
||||
========
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
esp32
|
||||
esp8266
|
||||
nodemcu_esp32
|
||||
nodemcu_esp8266
|
||||
sonoff
|
||||
sonoff_4ch
|
||||
sonoff_s20
|
||||
sonoff_basic
|
||||
*
|
||||
|
@ -182,7 +182,7 @@ first:
|
||||
- platform: template
|
||||
name: Living Room Cover
|
||||
lambda: !lambda >-
|
||||
if (id(top_end_stop).value) {
|
||||
if (id(top_end_stop).state) {
|
||||
return cover::COVER_OPEN;
|
||||
} else {
|
||||
return cover::COVER_CLOSED;
|
||||
@ -213,7 +213,7 @@ we're either *returning* ``cover::COVER_OPEN`` or ``cover::COVER_CLOSED`` to ind
|
||||
|
||||
Finally, ``id(...)`` is a helper function that makes esphomeyaml fetch an object with the supplied ID (which you defined
|
||||
somewhere else, like ``top_end_stop```) and let's you call any of esphomelib's many APIs directly. For example, here
|
||||
we're retrieving the current state of the end stop using ``.value`` and using it to construct our cover state.
|
||||
we're retrieving the current state of the end stop using ``.state`` and using it to construct our cover state.
|
||||
|
||||
.. note::
|
||||
|
||||
@ -234,7 +234,7 @@ we're retrieving the current state of the end stop using ``.value`` and using it
|
||||
ESP_LOGV("main", "This is a gray verbose message"); // doesn't show up with the default log level.
|
||||
|
||||
// Use printf-style syntax (http://www.cplusplus.com/reference/cstdio/printf/)
|
||||
ESP_LOGD("main", "The temperature inside is %.1f", id(outside_temperature_sensor).value);
|
||||
ESP_LOGD("main", "The temperature inside is %.1f", id(outside_temperature_sensor).state);
|
||||
|
||||
.. tip::
|
||||
|
||||
@ -269,7 +269,7 @@ if you have a light and want to set it to a pre-defined color when a button is p
|
||||
blue: !lambda >-
|
||||
# The sensor outputs values from 0 to 100. The blue
|
||||
# part of the light color will be determined by the sensor value.
|
||||
return id(some_sensor).value / 100.0;
|
||||
return id(some_sensor).state / 100.0;
|
||||
|
||||
Every parameter in actions that has the label "templatable" in the docs can be templated like above, using
|
||||
all of the usual lambda syntax.
|
||||
@ -337,7 +337,7 @@ time period.
|
||||
- switch.turn_off:
|
||||
id: relay_1
|
||||
# Templated, waits for 1s (1000ms) only if a reed switch is active
|
||||
- delay: !lambda "if (id(reed_switch).value) return 1000; else return 0;"
|
||||
- delay: !lambda "if (id(reed_switch).state) return 1000; else return 0;"
|
||||
|
||||
.. note::
|
||||
|
||||
@ -376,7 +376,7 @@ turns on a light for 5 seconds. Otherwise, the light is turned off immediately.
|
||||
on_...:
|
||||
then:
|
||||
- if:
|
||||
lambda: 'return id(some_sensor).value < 30;'
|
||||
lambda: 'return id(some_sensor).state < 30;'
|
||||
then:
|
||||
- lambda: 'ESP_LOGD("main", "The sensor value is below 30!");
|
||||
- light.turn_on: my_light
|
||||
|
@ -2,14 +2,6 @@ Guides
|
||||
======
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
|
||||
automations
|
||||
configuration-types
|
||||
faq
|
||||
getting_started_command_line
|
||||
getting_started_hassio
|
||||
migrate_espeasy
|
||||
migrate_espurna
|
||||
migrate_sonoff_tasmota
|
||||
contributing
|
||||
changelog
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user