-**code** (**Required**, string): The code to send. Must be a string of 0s and 1s.
`For example <https://github.com/sui77/rc-switch/wiki/HowTo_OperateLowCostOutlets#type-d-status>`__``'001010011001111101011011'``.
-**protocol** (*Optional*, :ref:`RCSwitch protocol <rc_switch-protocol>`): The RCSwitch protocol to use. Defaults to ``1``.
-**rc_switch_type_a**: Send an RCSwitch `type A code <https://github.com/sui77/rc-switch/wiki/HowTo_OperateLowCostOutlets#type-a-10-pole-dip-switches>`__.
-**group** (**Required**, string): The group to address, usually the state of the first 5 DIP switches.
Must be a string of 0s and 1s. For example ``'11001``.
-**device** (**Required**, string): The device within the group, usually the state of the last 5 DIP switches.
Must be a string of 0s and 1s. For example ``'01000``.
-**state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch is triggered. See :ref:`remote_transmitter-on_off_template`.
-**protocol** (*Optional*, :ref:`RCSwitch protocol <rc_switch-protocol>`): The RCSwitch protocol to use. Defaults to ``1``.
-**rc_switch_type_b**: Send an RCSwitch `type B code <https://github.com/sui77/rc-switch/wiki/HowTo_OperateLowCostOutlets#type-b-two-rotarysliding-switches>`__.
-**address** (**Required**, int): The number of the first rotary switch. For example ``4``.
-**channel** (**Required**, int): The number of the first rotary switch. For example ``2``.
-**state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch is triggered. See :ref:`remote_transmitter-on_off_template`.
-**protocol** (*Optional*, :ref:`RCSwitch protocol <rc_switch-protocol>`): The RCSwitch protocol to use. Defaults to ``1``.
-**rc_switch_type_c**: Send an RCSwitch `type C code <https://github.com/sui77/rc-switch/wiki/HowTo_OperateLowCostOutlets#type-c-intertechno>`__.
-**family** (**Required**, string): The family of the device. Must be a character from ``a`` to ``p``.
-**group** (**Required**, int): The group of the device. For example ``4``.
-**address** (**Required**, int): The address of the device. For example ``2``.
-**state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch is triggered. See :ref:`remote_transmitter-on_off_template`.
-**protocol** (*Optional*, :ref:`RCSwitch protocol <rc_switch-protocol>`): The RCSwitch protocol to use. Defaults to ``1``.
-**rc_switch_type_d**: Send an RCSwitch type D code.
-**group** (**Required**, string): The group of the device. Must be a character from ``a`` to ``d``.
-**device** (**Required**, int): The address of the device. For example ``3``.
-**state** (**Required**, boolean): Whether to send a "turn on" or "turn off" signal when this switch is triggered. See :ref:`remote_transmitter-on_off_template`.
-**protocol** (*Optional*, :ref:`RCSwitch protocol <rc_switch-protocol>`): The RCSwitch protocol to use. Defaults to ``1``.
Starting with version 1.8.0 esphomelib can also recognize a bunch of 433MHz RF codes directly using `RCSwitch's <https://github.com/sui77/rc-switch>`__
remote protocol. If you have RF code dumping enabled for the receiver, you will then see log outputs like this one:
..code::
Received RCSwitch: protocol=1 data='0100010101'
Like before with raw codes, you can then use this code to create switches:
..code:: yaml
switch:
- platform: remote_transmitter
name: "Living Room Lights On"
rc_switch_raw:
code: '0100010101'
protocol: 1
Alternatively, you can use the information on `this page <https://github.com/sui77/rc-switch/wiki/HowTo_OperateLowCostOutlets>`__
to manually find the RCSwitch codes without having to first find them using the remote receiver. For example, this would
be the esphomelib equivalent of the first Type-A switch on that site:
..code:: yaml
switch:
- platform: remote_transmitter
name: "Living Room Lights On"
rc_switch_type_a:
group: '1101'
device: '0100'
state: True
.._remote_transmitter-on_off_template:
On/Off template
---------------
Each switch of the ``remote_transmitter`` platform only sends a pre-defined remote code when switched on.
For example the RCSwitch example above always **sends the turn on** RF code to the wall plug. In some cases
you might want to have switches that can do both things, i.e. turn a light on when switched on and turn a light off
when switched off. To do this, use the :doc:`/esphomeyaml/components/switch/template` like this:
..code:: yaml
switch:
- platform: remote_transmitter
id: living_room_lights_on
rc_switch_type_a:
group: '1101'
device: '0100'
state: True
- platform: remote_transmitter
id: living_room_lights_off
rc_switch_type_a:
group: '1101'
device: '0100'
state: False
- platform: template
name: Living Room Lights
optimistic: True
turn_on_action:
- switch.turn_on: living_room_lights_on
turn_off_action:
- switch.turn_on: living_room_lights_off
.._rc_switch-protocol:
RCSwitch Protocol
-----------------
RCSwitch transmitters/receivers all have a ``protocol:`` option that can be used to tell esphomelib what timings to use
for the transmission. This is necessary as many remotes use different timings to encode a logic zero or one.
RCSwitch has 7 built-in protocols that cover most use cases. You can however also choose to use custom parameters
for the protocol like so
..code:: yaml
# Use one of RCSwitch's pre-defined protocols (1-7)
protocol: 1
# Use a custom protocol:
protocol:
pulse_length: 175
sync: [1, 31]
zero: [1, 3]
one: [3, 1]
inverted: False
Configuration options for the custom variant:
-**pulse_length** (**Required**, int): The length of each pulse in microseconds.
-**sync** (*Optional*): The number of on and off pulses for a sync bit. Defaults to 1 pulse on and 31 pulses off.
-**zero** (*Optional*): The number of on and off pulses to encode a logic zero. Defaults to 1 pulse on and 3 pulses off.
-**one** (*Optional*): The number of on and off pulses to encode a logic one. Defaults to 3 pulses on and 1 pulse off.
-**inverted** (*Optional*, boolean): Whether to treat this protocol as inverted, i.e. encode all on pulses by logic LOWs