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 sensor
from esphomeyaml.const import CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL
from esphomeyaml.helpers import App, process_lambda, variable, Application
from esphomeyaml.helpers import App, process_lambda, variable, Application, float_, optional
MakeTemplateSensor = Application.MakeTemplateSensor
@@ -16,7 +16,8 @@ PLATFORM_SCHEMA = 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(float_)):
yield
rhs = App.make_template_sensor(config[CONF_NAME], template_,
config.get(CONF_UPDATE_INTERVAL))