mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Add RC5 IR code support (#432)
This commit is contained in:
parent
fcef3be5c7
commit
52c0b45f41
5 changed files with 25 additions and 4 deletions
|
@ -10,7 +10,7 @@ from esphome.const import CONF_ADDRESS, CONF_CHANNEL, CONF_CODE, CONF_COMMAND, C
|
|||
CONF_DEVICE, CONF_FAMILY, CONF_GROUP, CONF_ID, CONF_JVC, CONF_LG, CONF_NAME, CONF_NBITS, \
|
||||
CONF_NEC, CONF_PANASONIC, CONF_PROTOCOL, CONF_RAW, CONF_RC_SWITCH_RAW, CONF_RC_SWITCH_TYPE_A, \
|
||||
CONF_RC_SWITCH_TYPE_B, CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D, CONF_SAMSUNG, CONF_SONY, \
|
||||
CONF_STATE
|
||||
CONF_STATE, CONF_RC5
|
||||
from esphome.cpp_generator import Pvariable, get_variable, progmem_array
|
||||
from esphome.cpp_types import int32
|
||||
|
||||
|
@ -18,7 +18,7 @@ DEPENDENCIES = ['remote_receiver']
|
|||
|
||||
REMOTE_KEYS = [CONF_JVC, CONF_NEC, CONF_LG, CONF_SONY, CONF_PANASONIC, CONF_SAMSUNG, CONF_RAW,
|
||||
CONF_RC_SWITCH_RAW, CONF_RC_SWITCH_TYPE_A, CONF_RC_SWITCH_TYPE_B,
|
||||
CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D]
|
||||
CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D, CONF_RC5]
|
||||
|
||||
CONF_REMOTE_RECEIVER_ID = 'remote_receiver_id'
|
||||
CONF_RECEIVER_ID = 'receiver_id'
|
||||
|
@ -31,6 +31,7 @@ PanasonicReceiver = remote_ns.class_('PanasonicReceiver', RemoteReceiver)
|
|||
RawReceiver = remote_ns.class_('RawReceiver', RemoteReceiver)
|
||||
SamsungReceiver = remote_ns.class_('SamsungReceiver', RemoteReceiver)
|
||||
SonyReceiver = remote_ns.class_('SonyReceiver', RemoteReceiver)
|
||||
RC5Receiver = remote_ns.class_('RC5Receiver', RemoteReceiver)
|
||||
RCSwitchRawReceiver = remote_ns.class_('RCSwitchRawReceiver', RemoteReceiver)
|
||||
RCSwitchTypeAReceiver = remote_ns.class_('RCSwitchTypeAReceiver', RCSwitchRawReceiver)
|
||||
RCSwitchTypeBReceiver = remote_ns.class_('RCSwitchTypeBReceiver', RCSwitchRawReceiver)
|
||||
|
@ -73,6 +74,10 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend
|
|||
vol.Required(CONF_ADDRESS): cv.hex_uint16_t,
|
||||
vol.Required(CONF_COMMAND): cv.hex_uint32_t,
|
||||
}),
|
||||
vol.Optional(CONF_RC5): vol.Schema({
|
||||
vol.Required(CONF_ADDRESS): vol.All(cv.hex_int, vol.Range(min=0, max=0x1F)),
|
||||
vol.Required(CONF_COMMAND): vol.All(cv.hex_int, vol.Range(min=0, max=0x3F)),
|
||||
}),
|
||||
vol.Optional(CONF_RAW): validate_raw,
|
||||
vol.Optional(CONF_RC_SWITCH_RAW): RC_SWITCH_RAW_SCHEMA,
|
||||
vol.Optional(CONF_RC_SWITCH_TYPE_A): RC_SWITCH_TYPE_A_SCHEMA,
|
||||
|
@ -100,6 +105,8 @@ def receiver_base(full_config):
|
|||
return SamsungReceiver.new(name, config[CONF_DATA])
|
||||
if key == CONF_SONY:
|
||||
return SonyReceiver.new(name, config[CONF_DATA], config[CONF_NBITS])
|
||||
if key == CONF_RC5:
|
||||
return RC5Receiver.new(name, config[CONF_ADDRESS], config[CONF_COMMAND])
|
||||
if key == CONF_RAW:
|
||||
arr = progmem_array(config[CONF_ID], config[CONF_DATA])
|
||||
return RawReceiver.new(name, arr, len(config[CONF_DATA]))
|
||||
|
|
|
@ -28,6 +28,7 @@ DUMPERS = {
|
|||
'samsung': remote_ns.class_('SamsungDumper', RemoteReceiveDumper),
|
||||
'sony': remote_ns.class_('SonyDumper', RemoteReceiveDumper),
|
||||
'rc_switch': remote_ns.class_('RCSwitchDumper', RemoteReceiveDumper),
|
||||
'rc5': remote_ns.class_('RC5Dumper', RemoteReceiveDumper),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ from esphome.const import CONF_ADDRESS, CONF_CARRIER_FREQUENCY, CONF_CHANNEL, CO
|
|||
CONF_LG, CONF_NAME, CONF_NBITS, CONF_NEC, CONF_PANASONIC, CONF_PROTOCOL, CONF_RAW, \
|
||||
CONF_RC_SWITCH_RAW, CONF_RC_SWITCH_TYPE_A, CONF_RC_SWITCH_TYPE_B, CONF_RC_SWITCH_TYPE_C, \
|
||||
CONF_RC_SWITCH_TYPE_D, CONF_REPEAT, CONF_SAMSUNG, CONF_SONY, CONF_STATE, CONF_TIMES, \
|
||||
CONF_WAIT_TIME
|
||||
CONF_WAIT_TIME, CONF_RC5
|
||||
from esphome.cpp_generator import Pvariable, add, get_variable, progmem_array
|
||||
from esphome.cpp_types import int32
|
||||
|
||||
|
@ -20,7 +20,7 @@ DEPENDENCIES = ['remote_transmitter']
|
|||
|
||||
REMOTE_KEYS = [CONF_JVC, CONF_NEC, CONF_LG, CONF_SAMSUNG, CONF_SONY, CONF_PANASONIC, CONF_RAW,
|
||||
CONF_RC_SWITCH_RAW, CONF_RC_SWITCH_TYPE_A, CONF_RC_SWITCH_TYPE_B,
|
||||
CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D]
|
||||
CONF_RC_SWITCH_TYPE_C, CONF_RC_SWITCH_TYPE_D, CONF_RC5]
|
||||
|
||||
CONF_REMOTE_TRANSMITTER_ID = 'remote_transmitter_id'
|
||||
CONF_TRANSMITTER_ID = 'transmitter_id'
|
||||
|
@ -31,6 +31,7 @@ LGTransmitter = remote_ns.class_('LGTransmitter', RemoteTransmitter)
|
|||
NECTransmitter = remote_ns.class_('NECTransmitter', RemoteTransmitter)
|
||||
PanasonicTransmitter = remote_ns.class_('PanasonicTransmitter', RemoteTransmitter)
|
||||
RawTransmitter = remote_ns.class_('RawTransmitter', RemoteTransmitter)
|
||||
RC5Transmitter = remote_ns.class_('RC5Transmitter', RemoteTransmitter)
|
||||
SamsungTransmitter = remote_ns.class_('SamsungTransmitter', RemoteTransmitter)
|
||||
SonyTransmitter = remote_ns.class_('SonyTransmitter', RemoteTransmitter)
|
||||
RCSwitchRawTransmitter = remote_ns.class_('RCSwitchRawTransmitter', RemoteTransmitter)
|
||||
|
@ -76,6 +77,10 @@ PLATFORM_SCHEMA = cv.nameable(switch.SWITCH_PLATFORM_SCHEMA.extend({
|
|||
vol.Required(CONF_ADDRESS): cv.hex_uint16_t,
|
||||
vol.Required(CONF_COMMAND): cv.hex_uint32_t,
|
||||
}),
|
||||
vol.Optional(CONF_RC5): vol.Schema({
|
||||
vol.Required(CONF_ADDRESS): vol.All(cv.hex_int, vol.Range(min=0, max=0x1F)),
|
||||
vol.Required(CONF_COMMAND): vol.All(cv.hex_int, vol.Range(min=0, max=0x3F)),
|
||||
}),
|
||||
vol.Optional(CONF_RAW): validate_raw,
|
||||
vol.Optional(CONF_RC_SWITCH_RAW): RC_SWITCH_RAW_SCHEMA,
|
||||
vol.Optional(CONF_RC_SWITCH_TYPE_A): RC_SWITCH_TYPE_A_SCHEMA,
|
||||
|
@ -109,6 +114,8 @@ def transmitter_base(full_config):
|
|||
return SamsungTransmitter.new(name, config[CONF_DATA])
|
||||
if key == CONF_SONY:
|
||||
return SonyTransmitter.new(name, config[CONF_DATA], config[CONF_NBITS])
|
||||
if key == CONF_RC5:
|
||||
return RC5Transmitter.new(name, config[CONF_ADDRESS], config[CONF_COMMAND])
|
||||
if key == CONF_RAW:
|
||||
arr = progmem_array(config[CONF_ID], config[CONF_DATA])
|
||||
return RawTransmitter.new(name, arr, len(config[CONF_DATA]),
|
||||
|
|
|
@ -162,6 +162,7 @@ CONF_COMMAND = 'command'
|
|||
CONF_DATA = 'data'
|
||||
CONF_NBITS = 'nbits'
|
||||
CONF_JVC = 'jvc'
|
||||
CONF_RC5 = 'rc5'
|
||||
CONF_LG = 'lg'
|
||||
CONF_SAMSUNG = 'samsung'
|
||||
CONF_SONY = 'sony'
|
||||
|
|
|
@ -895,6 +895,11 @@ switch:
|
|||
group: 'a'
|
||||
device: 2
|
||||
state: True
|
||||
- platform: remote_transmitter
|
||||
name: "Panasonic TV Off"
|
||||
rc5:
|
||||
address: 0x00
|
||||
command: 0x0B
|
||||
- platform: remote_transmitter
|
||||
name: "Panasonic TV Off"
|
||||
id: living_room_lights_off
|
||||
|
|
Loading…
Reference in a new issue