Allow old remote_transmitter repeat schema (#601)

Fixes https://github.com/esphome/issues/issues/389
This commit is contained in:
Otto Winter 2019-06-02 15:27:32 +02:00 committed by GitHub
parent c97a9d83c6
commit ec9cc72320
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -83,14 +83,20 @@ def register_dumper(name, type):
return decorator
def register_action(name, type_, schema):
validator = templatize(schema).extend({
cv.GenerateID(CONF_TRANSMITTER_ID): cv.use_id(RemoteTransmitterBase),
cv.Optional(CONF_REPEAT): cv.Schema({
def validate_repeat(value):
if isinstance(value, dict):
return cv.Schema({
cv.Required(CONF_TIMES): cv.templatable(cv.positive_int),
cv.Optional(CONF_WAIT_TIME, default='10ms'):
cv.templatable(cv.positive_time_period_milliseconds),
}),
})(value)
return validate_repeat({CONF_TIMES: value})
def register_action(name, type_, schema):
validator = templatize(schema).extend({
cv.GenerateID(CONF_TRANSMITTER_ID): cv.use_id(RemoteTransmitterBase),
cv.Optional(CONF_REPEAT): validate_repeat,
})
registerer = automation.register_action('remote_transmitter.transmit_{}'.format(name),
type_, validator)