Update docs

This commit is contained in:
Otto Winter 2018-12-05 10:19:48 +01:00
parent e7d8597175
commit 505255fa56
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
16 changed files with 323 additions and 19 deletions

View File

@ -119,3 +119,13 @@ Triggers
:members:
:protected-members:
:undoc-members:
.. doxygenclass:: binary_sensor::BinarySensorCondition
:members:
:protected-members:
:undoc-members:
.. doxygenclass:: binary_sensor::CustomBinarySensorConstructor
:members:
:protected-members:
:undoc-members:

View File

@ -17,6 +17,7 @@ MQTTClientComponent
:undoc-members:
.. doxygentypedef:: mqtt::mqtt_callback_t
.. doxygentypedef:: mqtt::mqtt_json_callback_t
.. doxygenstruct:: mqtt::MQTTMessage
:members:
@ -83,3 +84,13 @@ Actions
:members:
:protected-members:
:undoc-members:
.. _api-custom_mqtt_device:
CustomMQTTDevice
****************
.. doxygenclass:: mqtt::CustomMQTTDevice
:members:
:protected-members:
:undoc-members:

View File

@ -26,7 +26,7 @@ API Reference
.. cpp:namespace:: nullptr
.. doxygenenum:: PCF8574GPIOMode
.. doxygenenum:: io::PCF8574GPIOMode
.. doxygenclass:: io::PCF8574Component
:members:

View File

@ -37,6 +37,11 @@ GPIOSwitch
:protected-members:
:undoc-members:
.. doxygenclass:: switch_::SwitchCondition
:members:
:protected-members:
:undoc-members:
MQTTSwitchComponent
*******************

View File

@ -260,6 +260,24 @@ presses.
then:
- logger.log: "Single Short Clicked"
.. _binary_sensor-is_on_off_condition:
``binary_sensor.is_on`` / ``binary_sensor.is_off Condition
**********************************************************
This :ref:`config-condition <condition>` passes if the given binary sensor is on/off.
.. code-block:: yaml
# in a trigger:
on_...:
if:
condition:
binary_sensor.is_on: my_binary_sensor
# same goes for is_off
then:
- script.execute: my_script
lambda calls
************

View File

@ -289,6 +289,33 @@ with ``x``.
Configuration variables: See :ref:`Automation <automation>`.
.. _sensor-in_range_condition:
``sensor.in_range`` Condition
*****************************
This condition passes if the state of the given sensor is inside a range.
Define the range with ``above`` and ``below``. If only one of them is defined, the interval is half-open.
So for example ``above: 5`` with no below would mean the range from 5 to positive infinity.
.. code-block:: yaml
# in a trigger:
on_...:
if:
condition:
sensor.in_range:
id: my_sensor
above: 50.0
then:
- script.execute: my_script
Configuration variables:
- **above** (*Optional*, float): The minimum for the condition.
- **below** (*Optional*, float): The maximum for the condition.
lambda calls
************

View File

@ -106,6 +106,24 @@ advanced stuff (see the full :doc:`API Reference </api/cover/index>` for more in
// Toggle the switch
id(my_switch).write_state(!id(my_switch).state);
.. _switch-is_on_off_condition:
``switch.is_on`` / ``switch.is_off Condition
********************************************
This :ref:`config-condition <condition>` passes if the given switch is on/off.
.. code-block:: yaml
# in a trigger:
on_...:
if:
condition:
switch.is_on: my_switch
# same goes for is_off
then:
- script.execute: my_script
See Also
--------

View File

@ -87,9 +87,8 @@ See Also
.. toctree::
:maxdepth: 1
:glob:
version
mqtt_subscribe
template
*
.. disqus::

View File

@ -36,7 +36,7 @@ The example below is an example of a custom component that can do anything you w
};
In many cases however components should communicate with other appliances using the network.
That's why there is :cpp:class:`mqtt:CustomMQTTDevice`. It is a helper class to create
That's why there is :cpp:class:`mqtt::CustomMQTTDevice`. It is a helper class to create
custom components that communicate using MQTT.
.. code-block:: cpp
@ -100,7 +100,7 @@ Configuration variables:
- **lambda** (**Required**, :ref:`lambda <config-lambda>`): The lambda to run for instantiating the
binary sensor(s).
See :cpp:class:`Component` and :cpp:class:`mqtt:CustomMQTTDevice`.
See :cpp:class:`Component` and :cpp:class:`mqtt::CustomMQTTDevice`.
See Also
--------

View File

@ -3,7 +3,7 @@ Custom I²C Device
Lots of devices communicate using the i2c protocol. If you want to integrate
a device into esphomelib that uses this protocol you can pretty much use almost
all Arduino-based code, since the ``Wire`` library is also available in esphomelib.
all Arduino-based code because the ``Wire`` library is also available in esphomelib.
See the other custom component guides for how to register components and make
them publish values.

View File

@ -0,0 +1,7 @@
Custom
======
.. toctree::
:glob:
*

View File

@ -1,9 +1,9 @@
Custom SPI Device
=================
Lots of devices communicate using the i2c protocol. If you want to integrate
Lots of devices communicate using the SPI protocol. If you want to integrate
a device into esphomelib that uses this protocol you can pretty much use almost
all Arduino-based code, since the ``Wire`` library is also available in esphomelib.
all Arduino-based code because the ``SPI`` library is also available in esphomelib.
See the other custom component guides for how to register components and make
them publish values.
@ -16,23 +16,24 @@ them publish values.
class MyCustomComponent : public Component {
public:
void setup() override {
// Initialize the device here. Usually Wire.begin() will be called in here,
// though that call is unnecessary if you have an 'i2c:' entry in your config
SPI.pins(SCK_PIN, MISO_PIN, MOSI_PIN);
SPI.begin();
Wire.begin();
pinMode(CS_PIN, OUTPUT);
}
void loop() override {
// Example: write the value 0x42 to register 0x78 of device with address 0x21
Wire.beginTransmission(0x21);
Wire.write(0x78);
Wire.write(0x42);
Wire.endTransmission();
digitalWrite(CS_PIN, LOW);
SPI.beginTransaction(...);
SPI.write(0x42);
digitalWrite(CS_PIN, HIGH);
}
};
See Also
--------
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/custom/i2c.rst>`__
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/custom/spi.rst>`__
.. disqus::

View File

@ -0,0 +1,59 @@
Custom UART Device
==================
Lots of devices communicate using the UART protocol. If you want to integrate
a device into esphomelib that uses this protocol you can pretty much use almost
all Arduino-based code because esphomelib has a nice abstraction over the UART bus.
See the other custom component guides for how to register components and make
them publish values.
.. code-block:: cpp
#include "esphomelib.h"
using namespace esphomelib;
class MyCustomComponent : public Component, public UARTDevice {
public:
MyCustomComponent(UARTComponent *parent) : UARTDevice(parent) {}
void setup() override {
// nothing to do here
}
void loop() override {
// Use Arduino API to read data, for example
String line = readString();
int i = parseInt();
while (available()) {
char c = read();
}
// etc
}
};
And in YAML:
.. code-block:: yaml
# Example configuration entry
esphomeyaml:
includes:
- my_custom_component.h
uart:
id: uart_bus
tx_pin: D0
rx_pin: D1
baud_rate: 9600
custom_component:
- lambda: |-
auto my_custom = new MyCustomComponent(id(uart_bus));
return {my_custom};
See Also
--------
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/custom/uart.rst>`__
.. disqus::

View File

@ -333,8 +333,10 @@ All Actions
- :ref:`delay <delay_action>`
- :ref:`lambda <lambda_action>`
- :ref:`if <if_action>`
- :ref:`while <while_action>`
- :ref:`component.update <component-update_action>`
- :ref:`script.execute <script-execute_action>`
- :ref:`script.stop <script-stop_action>`
- :ref:`logger.log <logger-log_action>`
- :ref:`mqtt.publish <mqtt-publish_action>`
- :ref:`mqtt.publish_json <mqtt-publish_json_action>`
@ -356,6 +358,18 @@ All Actions
- :ref:`deep_sleep.enter <deep_sleep-enter_action>`
- :ref:`deep_sleep.prevent <deep_sleep-prevent_action>`
.. _config-condition:
All Conditions
--------------
- :ref:`and <and_condition>`
- :ref:`or <or_condition>`
- :ref:`lambda <lambda_condition>`
- :ref:`binary_sensor.is_on / binary_sensor.is_off <binary_sensor-is_on_off_condition>`
- :ref:`switch.is_on / switch.is_off <switch-is_on_off_condition>`
- :ref:`sensor.in_range <sensor-in_range_condition>`
.. _delay_action:
``delay`` Action
@ -424,12 +438,47 @@ turns on a light for 5 seconds. Otherwise, the light is turned off immediately.
Configuration options:
- **if** (**Required**): The condition to check which branch to take.
- **if** (**Required**, :ref:`config-condition`): The condition to check which branch to take.
- **then** (*Optional*, :ref:`config-action`): The action to perform if the condition evaluates to true.
Defaults to doing nothing.
- **else** (*Optional*, :ref:`config-action`): The action to perform if the condition evaluates to false.
Defaults to doing nothing.
.. _while_action:
``while`` Action
----------------
This actions repeats a sequence of actions until a condition is no longer met.
For example, below you can see a configuration that will blink an LED as long as a template
switch is on.
.. code-block:: yaml
switch:
- platform: gpio
pin: D1
id: blinking_pin
- platform: template
name: Blink LED
id: blink
optimistic: true
turn_on_action:
- while:
condition:
switch.is_on: blink
then:
- switch.turn_on: blinking_pin
- delay: 500ms
- switch.turn_off: blinking_pin
- delay: 500ms
Configuration options:
- **if** (**Required**, :ref:`config-condition`): The condition to check whether to continue evaluation.
- **then** (**Optional**, :ref:`config-action`): The action to perform if the condition evaluates to true.
.. _component-update_action:
@ -477,6 +526,89 @@ execute the script with a single call.
then:
- script.execute: my_script
.. _script-stop_action:
``script.stop`` Action
----------------------
This action allows you to stop a given script during execution. Please note this is only
useful right now if your script contains a ``delay`` action.
.. code-block:: yaml
# Example configuration entry
script:
- id: my_script
then:
- switch.turn_on: my_switch
- delay: 1s
- switch.turn_off: my_switch
# in a trigger:
on_...:
then:
- script.stop: my_script
.. _and_condition:
``and`` Condition
-----------------
This condition passes if and only if all of the conditions pass.
.. code-block:: yaml
# in a trigger:
on_...:
if:
condition:
and:
- condition_a:
- condition_b:
then:
- script.execute: my_script
.. _or_condition:
``or`` Condition
----------------
This condition passes if at least one condition passes.
.. code-block:: yaml
# in a trigger:
on_...:
if:
condition:
or:
- condition_a:
- condition_b:
then:
- script.execute: my_script
.. _lambda_condition:
``lambda`` Condition
--------------------
This condition passes if the given :ref:`lambda <config-lambda>` returns ``true``.
.. code-block:: yaml
# in a trigger:
on_...:
if:
condition:
lambda: |-
if (id(my_sensor).value > 30.0) {
return true;
} else {
return false;
}
then:
- script.execute: my_script
See Also
--------

View File

@ -12,6 +12,8 @@ Tips for using esphomeyaml
``!include``, ``!secret``. So you can store all your secret WiFi passwords and so on
in a file called ``secrets.yaml`` within the directory where the configuration file is.
For even more configuration templating, take a look at :ref:`config-substitutions`.
2. If you want to see how esphomeyaml interprets your configuration, run
.. code-block:: bash

View File

@ -135,6 +135,7 @@ Binary Sensor Components
Remote Receiver, components/binary_sensor/remote_receiver, remote.svg
PN532 Tag, components/binary_sensor/pn532, pn532.jpg
RDM6300 Tag, components/binary_sensor/rdm6300, rdm6300.jpg
Custom Binary Sensor, components/binary_sensor/custom, language-cpp.svg
Output Components
-----------------
@ -147,6 +148,7 @@ Output Components
ESP32 LEDC, components/output/ledc, pwm.png
PCA9685, components/output/pca9685, pca9685.jpg
MY9231/MY9291, components/output/my9231, my9231.svg
Custom Output, components/output/custom, language-cpp.svg
Light Components
----------------
@ -179,6 +181,7 @@ Switch Components
Generic Output Switch, components/switch/output, upload.svg
Template Switch, components/switch/template, description.svg
UART Switch, components/switch/uart, uart.svg
Custom Switch, components/switch/custom, language-cpp.svg
Fan Components
--------------
@ -220,6 +223,7 @@ Text Sensor Components
MQTT Subscribe Text, components/text_sensor/mqtt_subscribe, mqtt.png
Version, components/text_sensor/version, new-box.svg
Template Text Sensor, components/text_sensor/template, description.svg
Custom Text Sensor, components/text_sensor/custom, language-cpp.svg
Misc Components
---------------
@ -243,6 +247,16 @@ Misc Components
Stepper, components/stepper/index, stepper.svg
MY9231/MY9291 LED driver, components/my9231, my9231.svg
Additional Custom Components
----------------------------
.. imgtable::
Generic Custom Component, custom/custom_component, language-cpp.svg
Custom I2C Component, custom/i2c, language-cpp.svg
Custom SPI Component, custom/spi, language-cpp.svg
Custom UART Component, custom/uart, language-cpp.svg
.. _cookbook:
Cookbook
@ -271,3 +285,4 @@ documentation for others to copy. See :doc:`Contributing <guides/contributing>`.
devices/index
guides/index
changelog/index
custom/index