Add ability to set rpi_rf tx_repeats
attribute (#5070)
* Add ability to set rpi_rf `tx_repeats` attribute Uses the current `rpi_rf` default of 10 Closes home-assistant/home-assistant#5069 * Use `signal_repetitions` instead of `repeats` for consistency
This commit is contained in:
parent
ebfb2c9b26
commit
b78cf4772d
1 changed files with 7 additions and 1 deletions
|
@ -21,13 +21,17 @@ CONF_CODE_ON = 'code_on'
|
|||
CONF_GPIO = 'gpio'
|
||||
CONF_PROTOCOL = 'protocol'
|
||||
CONF_PULSELENGTH = 'pulselength'
|
||||
CONF_SIGNAL_REPETITIONS = 'signal_repetitions'
|
||||
|
||||
DEFAULT_PROTOCOL = 1
|
||||
DEFAULT_SIGNAL_REPETITIONS = 10
|
||||
|
||||
SWITCH_SCHEMA = vol.Schema({
|
||||
vol.Required(CONF_CODE_OFF): cv.positive_int,
|
||||
vol.Required(CONF_CODE_ON): cv.positive_int,
|
||||
vol.Optional(CONF_PULSELENGTH): cv.positive_int,
|
||||
vol.Optional(CONF_SIGNAL_REPETITIONS,
|
||||
default=DEFAULT_SIGNAL_REPETITIONS): cv.positive_int,
|
||||
vol.Optional(CONF_PROTOCOL, default=DEFAULT_PROTOCOL): cv.positive_int,
|
||||
})
|
||||
|
||||
|
@ -55,6 +59,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
rfdevice,
|
||||
properties.get(CONF_PROTOCOL),
|
||||
properties.get(CONF_PULSELENGTH),
|
||||
properties.get(CONF_SIGNAL_REPETITIONS),
|
||||
properties.get(CONF_CODE_ON),
|
||||
properties.get(CONF_CODE_OFF)
|
||||
)
|
||||
|
@ -69,7 +74,7 @@ class RPiRFSwitch(SwitchDevice):
|
|||
"""Representation of a GPIO RF switch."""
|
||||
|
||||
def __init__(self, hass, name, rfdevice, protocol, pulselength,
|
||||
code_on, code_off):
|
||||
signal_repetitions, code_on, code_off):
|
||||
"""Initialize the switch."""
|
||||
self._hass = hass
|
||||
self._name = name
|
||||
|
@ -79,6 +84,7 @@ class RPiRFSwitch(SwitchDevice):
|
|||
self._pulselength = pulselength
|
||||
self._code_on = code_on
|
||||
self._code_off = code_off
|
||||
self._rfdevice.tx_repeat = signal_repetitions
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue