esphome-docs/esphomeyaml/components/switch/index.rst

86 lines
1.7 KiB
ReStructuredText
Raw Normal View History

2018-05-13 11:37:02 +02:00
Switch Component
================
The ``switch`` domain includes all platforms that should show up like a
switch and can only be turned ON or OFF.
2018-06-01 18:10:00 +02:00
.. _config-switch:
2018-05-13 11:37:02 +02:00
Base Switch Configuration
-------------------------
.. code:: yaml
switch:
- platform: ...
name: "Switch Name"
icon: "mdi:restart"
Configuration variables:
- **name** (**Required**, string): The name of the switch.
- **icon** (*Optional*, icon): Manually set the icon to use for the
sensor in the frontend.
2018-05-17 17:34:45 +02:00
- **inverted** (*Optional*, boolean): Whether to invert the binary
state, i.e. report ON states as OFF and vice versa. Defaults
to ``False``.
2018-06-01 18:10:00 +02:00
- All other options from :ref:`MQTT Component <config-mqtt-component>`.
.. _switch-toggle_action:
``switch.toggle`` Action
^^^^^^^^^^^^^^^^^^^^^^^^
This action toggles a switch with the given ID when executed.
.. code:: yaml
on_...:
then:
- switch.toggle:
id: relay_1
.. _switch-turn_on_action:
``switch.turn_on`` Action
^^^^^^^^^^^^^^^^^^^^^^^^^
This action turns a switch with the given ID on when executed.
.. code:: yaml
on_...:
then:
- switch.turn_on:
id: relay_1
.. _switch-turn_off_action:
``switch.turn_off`` Action
^^^^^^^^^^^^^^^^^^^^^^^^^^
This action turns a switch with the given ID off when executed.
.. code:: yaml
on_...:
then:
- switch.turn_off:
id: relay_1
See Also
^^^^^^^^
- :doc:`API Reference </api/switch/index>`
2018-06-03 12:50:44 +02:00
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/master/esphomeyaml/components/switch/index.rst>`__
2018-06-01 18:10:00 +02:00
.. toctree::
:maxdepth: 1
gpio.rst
shutdown.rst
output.rst
ir_transmitter.rst
restart.rst
template.rst