Add switch.on_turn_on/off docs

This commit is contained in:
Otto Winter 2019-02-17 19:09:52 +01:00
parent 85cfae9aec
commit 45b931dbe9
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
2 changed files with 24 additions and 0 deletions

View File

@ -31,6 +31,10 @@ Configuration variables:
- **internal** (*Optional*, boolean): Mark this component as internal. Internal components will
not be exposed to the frontend (like Home Assistant). Only specifying an ``id`` without
a ``name`` will implicitly set this to true.
- **on_turn_on** (*Optional*, :ref:`Action <config-action>`): An automation to perform
when the switch is turned on. See :ref:`switch-on_turn_on_off_trigger`.
- **on_turn_off** (*Optional*, :ref:`Action <config-action>`): An automation to perform
when the switch is turned off. See :ref:`switch-on_turn_on_off_trigger`.
- If MQTT enabled, All other options from :ref:`MQTT Component <config-mqtt-component>`.
.. _switch-toggle_action:
@ -144,6 +148,25 @@ This :ref:`condition <config-condition>` passes if the given switch is on/off.
then:
- script.execute: my_script
.. _switch-on_turn_on_off_trigger:
``switch.on_turn_on`` / ``switch.on_turn_off`` Trigger
******************************************************
This trigger is activated each time the switch is turned on. It becomes active
right after the switch component has acknowledged the state (e.g. after it switched
ON/OFF itself).
.. code-block:: yaml
switch:
- platform: gpio # or any other platform
# ...
on_turn_on:
- logger.log: "Switch Turned On!"
on_turn_off:
- logger.log: "Switch Turned Off!"
See Also
--------

View File

@ -319,6 +319,7 @@ All Triggers
- :ref:`pn532.on_tag <pn532-on_tag>`
- :ref:`time.on_time <time-on_time>`
- :ref:`interval.interval <interval>`
- :ref:`switch.on_turn_on / switch.on_turn_off <switch-on_turn_on_off_trigger>`
All Actions
-----------