mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-12-25 17:17:54 +01:00
Add switch.on_turn_on/off docs
This commit is contained in:
parent
85cfae9aec
commit
45b931dbe9
@ -31,6 +31,10 @@ Configuration variables:
|
|||||||
- **internal** (*Optional*, boolean): Mark this component as internal. Internal components will
|
- **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
|
not be exposed to the frontend (like Home Assistant). Only specifying an ``id`` without
|
||||||
a ``name`` will implicitly set this to true.
|
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>`.
|
- If MQTT enabled, All other options from :ref:`MQTT Component <config-mqtt-component>`.
|
||||||
|
|
||||||
.. _switch-toggle_action:
|
.. _switch-toggle_action:
|
||||||
@ -144,6 +148,25 @@ This :ref:`condition <config-condition>` passes if the given switch is on/off.
|
|||||||
then:
|
then:
|
||||||
- script.execute: my_script
|
- 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
|
See Also
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -319,6 +319,7 @@ All Triggers
|
|||||||
- :ref:`pn532.on_tag <pn532-on_tag>`
|
- :ref:`pn532.on_tag <pn532-on_tag>`
|
||||||
- :ref:`time.on_time <time-on_time>`
|
- :ref:`time.on_time <time-on_time>`
|
||||||
- :ref:`interval.interval <interval>`
|
- :ref:`interval.interval <interval>`
|
||||||
|
- :ref:`switch.on_turn_on / switch.on_turn_off <switch-on_turn_on_off_trigger>`
|
||||||
|
|
||||||
All Actions
|
All Actions
|
||||||
-----------
|
-----------
|
||||||
|
Loading…
Reference in New Issue
Block a user