1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-21 12:42:21 +01:00

Fix optional returns from templates

This commit is contained in:
Otto Winter
2018-06-06 09:48:59 +02:00
parent c82a44d541
commit 7068808d4f
5 changed files with 14 additions and 9 deletions

View File

@@ -3,7 +3,7 @@ import voluptuous as vol
import esphomeyaml.config_validation as cv
from esphomeyaml.components import binary_sensor
from esphomeyaml.const import CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME
from esphomeyaml.helpers import App, Application, process_lambda, variable
from esphomeyaml.helpers import App, Application, process_lambda, variable, optional, bool_
MakeTemplateBinarySensor = Application.MakeTemplateBinarySensor
@@ -15,7 +15,8 @@ PLATFORM_SCHEMA = binary_sensor.PLATFORM_SCHEMA.extend({
def to_code(config):
template_ = None
for template_ in process_lambda(config[CONF_LAMBDA], []):
for template_ in process_lambda(config[CONF_LAMBDA], [],
return_type=optional.template(bool_)):
yield
rhs = App.make_template_binary_sensor(config[CONF_NAME], template_)
make = variable(config[CONF_MAKE_ID], rhs)