1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-11 15:52:20 +01:00

Template lambda is optional

This commit is contained in:
Otto Winter
2019-02-16 13:12:49 +01:00
parent ef7b936d60
commit fcef3be5c7
3 changed files with 18 additions and 15 deletions

View File

@@ -16,7 +16,7 @@ BinarySensorPublishAction = binary_sensor.binary_sensor_ns.class_('BinarySensorP
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(TemplateBinarySensor),
vol.Required(CONF_LAMBDA): cv.lambda_,
vol.Optional(CONF_LAMBDA): cv.lambda_,
}).extend(cv.COMPONENT_SCHEMA.schema))
@@ -26,10 +26,11 @@ def to_code(config):
binary_sensor.setup_binary_sensor(var, config)
setup_component(var, config)
for template_ in process_lambda(config[CONF_LAMBDA], [],
return_type=optional.template(bool_)):
yield
add(var.set_template(template_))
if CONF_LAMBDA in config:
for template_ in process_lambda(config[CONF_LAMBDA], [],
return_type=optional.template(bool_)):
yield
add(var.set_template(template_))
BUILD_FLAGS = '-DUSE_TEMPLATE_BINARY_SENSOR'