2018-08-22 22:05:28 +02:00
|
|
|
UART Switch
|
|
|
|
===========
|
|
|
|
|
2018-11-14 22:12:27 +01:00
|
|
|
.. seo::
|
2019-02-16 23:25:23 +01:00
|
|
|
:description: Instructions for setting up UART switches in ESPHome that can output arbitrary UART sequences when activated.
|
2021-11-16 03:19:33 +01:00
|
|
|
:image: uart.svg
|
2018-11-14 22:12:27 +01:00
|
|
|
|
2018-08-22 22:05:28 +02:00
|
|
|
The ``uart`` switch platform allows you to send a pre-defined sequence of bytes on a
|
2019-02-07 13:54:45 +01:00
|
|
|
:doc:`UART bus </components/uart>` when triggered.
|
2018-08-22 22:05:28 +02:00
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
switch:
|
|
|
|
- platform: uart
|
|
|
|
name: "UART String Output"
|
|
|
|
data: 'DataToSend'
|
|
|
|
- platform: uart
|
|
|
|
name: "UART Bytes Output"
|
|
|
|
data: [0xDE, 0xAD, 0xBE, 0xEF]
|
2021-02-27 23:53:29 +01:00
|
|
|
- platform: uart
|
|
|
|
name: "UART Recurring Output"
|
|
|
|
data: [0xDE, 0xAD, 0xBE, 0xEF]
|
|
|
|
send_every: 1s
|
2023-10-17 21:07:33 +02:00
|
|
|
- platform: uart
|
|
|
|
name: "UART On/Off"
|
|
|
|
data:
|
|
|
|
turn_on: "TurnOn\r\n"
|
|
|
|
turn_off: "TurnOff\r\n"
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
Configuration variables:
|
2018-08-24 22:44:01 +02:00
|
|
|
------------------------
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
|
2023-10-17 21:07:33 +02:00
|
|
|
- **name** (*Optional*, string): The name for the switch.
|
|
|
|
- **uart_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the UART hub.
|
|
|
|
- **data** (*Optional*, string or list of bytes): The data to send via UART. Either an ASCII string
|
|
|
|
or a list of bytes or one or both of the following nested options (see example above).
|
|
|
|
|
|
|
|
- **turn_on** (*Optional*, string or list of bytes): The data to send when turning on.
|
|
|
|
- **turn_off** (*Optional*, string or list of bytes): The data to send when turning off.
|
2021-02-27 23:53:29 +01:00
|
|
|
- **send_every** (*Optional*, :ref:`config-time`): Sends recurring data instead of sending once.
|
2019-02-17 12:28:17 +01:00
|
|
|
- All other options from :ref:`Switch <config-switch>`.
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
See Also
|
2018-08-24 22:44:01 +02:00
|
|
|
--------
|
2018-08-22 22:05:28 +02:00
|
|
|
|
2019-02-07 13:54:45 +01:00
|
|
|
- :doc:`/components/uart`
|
2019-05-12 22:44:59 +02:00
|
|
|
- :apiref:`uart/switch/uart_switch.h`
|
2019-02-07 13:54:45 +01:00
|
|
|
- :ghedit:`Edit`
|