This commit is contained in:
Otto Winter 2019-05-15 11:49:05 +02:00
parent fb22c082c8
commit d23b7e5736
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
8 changed files with 102 additions and 38 deletions

View File

@ -220,7 +220,7 @@ There are currently 4 types of variables:
- float: A floating point number. C++ type: ``float``
- string: A string. C++ type: ``std::string``
.. _api.connected_condition:
.. _api-connected_condition:
``api.connected`` Condition
---------------------------

View File

@ -505,7 +505,7 @@ Configuration options:
root["something"] = id(my_sensor).state;
});
.. _mqtt.connected_condition:
.. _mqtt-connected_condition:
``mqtt.connected`` Condition
----------------------------

View File

@ -106,6 +106,28 @@ Configuration options:
id(my_servo).write(1.0);
.. _servo-detach_action:
``servo.detach`` Action
-----------------------
This :ref:`Action <config-action>` allows you to disable the output on a servo motor -
this will make the servo motor stop immediately and disable its active control.
.. code-block:: yaml
on_...:
then:
- servo.detach: my_servo
.. note::
This action can also be expressed as a :ref:`lambda <config-lambda>`:
.. code-block:: cpp
id(my_servo).detach();
.. _servo-ha-config:
Home Assistant Configuration

View File

@ -62,6 +62,40 @@ In :ref:`Lambdas <config-lambda>` you can get the value from the trigger with ``
Configuration variables: See :ref:`Automation <automation>`.
.. _text_sensor-state_condition:
``text_sensor.state`` Condition
-------------------------------
This :ref:`Condition <config-condition>` allows you to check if a given text sensor
has a specific state.
.. code-block:: yaml
on_...:
- if:
condition:
# Checks if "my_text_sensor" has state "Hello World"
text_sensor.state:
id: my_text_sensor
state: 'Hello World'
Configuration variables:
- **id** (**Required**, :ref:`config-id`): The text sensor ID.
- **state** (**Required**, :ref:`templatable <config-templatable>`, string): The state to compare
to.
.. note::
This condition can also be expressed in :ref:`lambdas <config-lambda>`:
.. code-block:: cpp
if (id(my_text_sensor).state == "Hello World") {
// do something
}
.. _text_sensor-lambda_calls:
lambda calls

View File

@ -168,7 +168,7 @@ Configuration variables:
- **hidden** (*Optional*, boolean): Whether this network is hidden. Defaults to false.
If you add this option you also have to specify ssid.
.. _wifi.connected_condition:
.. _wifi-connected_condition:
``wifi.connected`` Condition
----------------------------

View File

@ -37,47 +37,30 @@ ESPHome uses Home Assistant's cover architecture model which has two states: "OP
binary_sensor:
# The top endstop
- platform: gpio
pin: D4
id: top_endstop
on_press:
# Acknowledge that the cover is open
- cover.template.publish:
id: my_cover
state: OPEN
# Stop the cover motors
- cover.stop: my_cover
- platform: gpio
pin: D5
id: bottom_endstop
on_press:
# Acknowledge that the cover is closed
- cover.template.publish:
id: my_cover
state: CLOSED
# Stop the cover motors
- cover.stop: my_cover
cover:
- platform: template
- platform: endstop
name: "My Endstop Cover"
id: my_cover
open_action:
- switch.turn_on: up_pin
# Failsafe: Turn off motors after 3min if endstop not reached.
- delay: 3 min
- cover.stop: my_cover
open_duration: 2min
open_endstop: top_endstop
close_action:
- switch.turn_on: down_pin
- delay: 3 min
- cover.stop: my_cover
close_duration: 2min
close_endstop: bottom_endstop
stop_action:
- switch.turn_off: up_pin
- switch.turn_off: down_pin
optimistic: True
assumed_state: True
max_duration: 3min
You can then optionally also add manual controls to the cover with three buttons:
open, close, and stop.

View File

@ -320,9 +320,12 @@ All Triggers
- :ref:`esphome.on_boot <esphome-on_boot>` / :ref:`esphome.on_shutdown <esphome-on_shutdown>` / :ref:`esphome.on_loop <esphome-on_loop>`
- :ref:`time.on_time <time-on_time>`
- :ref:`mqtt.on_message <mqtt-on_message>` / :ref:`mqtt.on_json_message <mqtt-on_json_message>`
- :ref:`pn532.on_tag <pn532-on_tag>`
- :ref:`pn532.on_tag <pn532-on_tag>` / :ref:`rdm6300.on_tag <rdm6300-on_tag>`
- :ref:`interval.interval <interval>`
- :ref:`switch.on_turn_on / switch.on_turn_off <switch-on_turn_on_off_trigger>`
- :doc:`remote_receiver.on_* </components/remote_receiver>`
- :doc:`sun.on_sunrise </components/sun>` / :doc:`sun.on_sunset </components/sun>`
- :ref:`switch.on_turn_on/off <switch-on_turn_on_off_trigger>`
All Actions
-----------
@ -337,15 +340,25 @@ All Actions
- :ref:`mqtt.publish <mqtt-publish_action>` / :ref:`mqtt.publish_json <mqtt-publish_json_action>`
- :ref:`switch.toggle <switch-toggle_action>` / :ref:`switch.turn_off <switch-turn_off_action>` / :ref:`switch.turn_on <switch-turn_on_action>`
- :ref:`light.toggle <light-toggle_action>` / :ref:`light.turn_off <light-turn_off_action>` / :ref:`light.turn_on <light-turn_on_action>`
- :ref:`cover.open <cover-open_action>` / :ref:`cover.close <cover-close_action>` / :ref:`cover.stop <cover-stop_action>`
/ :ref:`light.control <light-control_action>` / :ref:`light.dim_relative <light-dim_relative_action>`
/ :ref:`light.addressable_set <light-addressable_set_action>`
- :ref:`cover.open <cover-open_action>` / :ref:`cover.close <cover-close_action>` / :ref:`cover.stop <cover-stop_action>` /
:ref:`cover.control <cover-control_action>`
- :ref:`fan.toggle <fan-toggle_action>` / :ref:`fan.turn_off <fan-turn_off_action>` / :ref:`fan.turn_on <fan-turn_on_action>`
- :ref:`output.turn_off <output-turn_off_action>` / :ref:`output.turn_on <output-turn_on_action>` / :ref:`output.set_level <output-set_level_action>`
- :ref:`deep_sleep.enter <deep_sleep-enter_action>` / :ref:`deep_sleep.prevent <deep_sleep-prevent_action>`
- :ref:`sensor.template.publish <sensor-template-publish_action>` / :ref:`binary_sensor.template.publish <binary_sensor-template-publish_action>` /
:ref:`cover.template.publish <cover-template-publish_action>` / :ref:`switch.template.publish <switch-template-publish_action>` /
:ref:`text_sensor.template.publish <text_sensor-template-publish_action>`
- :ref:`sensor.template.publish <sensor-template-publish_action>` / :ref:`binary_sensor.template.publish <binary_sensor-template-publish_action>`
/ :ref:`cover.template.publish <cover-template-publish_action>` / :ref:`switch.template.publish <switch-template-publish_action>`
/ :ref:`text_sensor.template.publish <text_sensor-template-publish_action>`
- :ref:`stepper.set_target <stepper-set_target_action>` / :ref:`stepper.report_position <stepper-report_position_action>`
- :ref:`servo.write <servo-write_action>`
/ :ref:`stepper.set_speed <stepper-set_speed_action>`
- :ref:`servo.write <servo-write_action>` / :ref:`servo.detach <servo-detach_action>`
- :ref:`globals.set <globals-set_action>`
- :ref:`remote_transmitter.transmit_* <remote_transmitter-transmit_action>`
- :ref:`climate.control <climate-control_action>`
- :ref:`output.esp8266_pwm.set_frequency <output-esp8266_pwm-set_frequency_action>`
- :ref:`sensor.integration.reset <sensor-integration-reset_action>`
- :ref:`display.page.show_* <display-pages>`
.. _config-condition:
@ -353,10 +366,16 @@ All Conditions
--------------
- :ref:`lambda <lambda_condition>`
- :ref:`and <and_condition>` / :ref:`or <or_condition>`
- :ref:`and <and_condition>` / :ref:`or <or_condition>` / :ref:`not <not_condition>`
- :ref:`for <for_condition>`
- :ref:`binary_sensor.is_on <binary_sensor-is_on_condition>` / :ref:`binary_sensor.is_off <binary_sensor-is_off_condition>`
- :ref:`switch.is_on <switch-is_on_condition>` / :ref:`switch.is_off <switch-is_off_condition>`
- :ref:`sensor.in_range <sensor-in_range_condition>`
- :ref:`wifi.connected <wifi-connected_condition>` / :ref:`api.connected <api-connected_condition>`
/ :ref:`mqtt.connected <mqtt-connected_condition>`
- :ref:`script.is_running <script-is_running_condition>`
- :ref:`sun.is_above_horizon / sun.is_below_horizon <sun-is_above_below_horizon-condition>`
- :ref:`text_sensor.state <text_sensor-state_condition>`
All Lambda Calls
----------------
@ -427,9 +446,10 @@ and can be used to create conditional flow in actions.
.. _and_condition:
.. _or_condition:
.. _not_condition:
``and`` / ``or`` Condition
--------------------------
``and`` / ``or`` / ``not`` Condition
------------------------------------
Check a combination of conditions
@ -445,6 +465,11 @@ Check a combination of conditions
- binary_sensor.is_on: other_binary_sensor
# ...
- if:
condition:
not:
binary_sensor.is_off: some_binary_sensor
.. _if_action:
``if`` Action
@ -545,7 +570,7 @@ compile error.
# The same as:
- lambda: 'id(my_component).update();'
.. _globals_set_action:
.. _globals-set_action:
``globals.set`` Action
----------------------

View File

@ -495,7 +495,7 @@ thing: Any C++ declared in the paranetheses of ``cg.add()`` will be added to the
If you do not call "add" a piece of code explicitly, it will not be added to the main.cpp file!
4. Runtime
----------
**********
Okay, the python part of the codebase is now complete - now let's talk about the C++ part of
creating a new integration.