diff --git a/esphomeyaml/components/binary_sensor/template.py b/esphomeyaml/components/binary_sensor/template.py index 663e82430f..29e5e7a8ad 100644 --- a/esphomeyaml/components/binary_sensor/template.py +++ b/esphomeyaml/components/binary_sensor/template.py @@ -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) diff --git a/esphomeyaml/components/cover/template.py b/esphomeyaml/components/cover/template.py index 4e85bded86..f771f89074 100644 --- a/esphomeyaml/components/cover/template.py +++ b/esphomeyaml/components/cover/template.py @@ -5,7 +5,7 @@ from esphomeyaml import automation from esphomeyaml.components import cover from esphomeyaml.const import CONF_CLOSE_ACTION, CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME, \ CONF_OPEN_ACTION, CONF_STOP_ACTION, CONF_OPTIMISTIC -from esphomeyaml.helpers import App, Application, NoArg, add, process_lambda, variable +from esphomeyaml.helpers import App, Application, NoArg, add, process_lambda, variable, optional MakeTemplateCover = Application.MakeTemplateCover @@ -25,7 +25,8 @@ def to_code(config): if CONF_LAMBDA in config: template_ = None - for template_ in process_lambda(config[CONF_LAMBDA], []): + for template_ in process_lambda(config[CONF_LAMBDA], [], + return_type=optional.template(cover.CoverState)): yield add(make.Ptemplate_.set_state_lambda(template_)) if CONF_OPEN_ACTION in config: diff --git a/esphomeyaml/components/output/ledc.py b/esphomeyaml/components/output/ledc.py index 60488e364c..107e788737 100644 --- a/esphomeyaml/components/output/ledc.py +++ b/esphomeyaml/components/output/ledc.py @@ -15,7 +15,7 @@ def validate_frequency_bit_depth(obj): bit_depth = obj.get(CONF_BIT_DEPTH, 12) max_freq = APB_CLOCK_FREQ / (2**bit_depth) if frequency > max_freq: - raise vol.Invalid('Maximum frequency for bit depth {} is {}'.format(bit_depth, max_freq)) + raise vol.Invalid('Maximum frequency for bit depth {} is {}Hz'.format(bit_depth, max_freq)) return obj diff --git a/esphomeyaml/components/sensor/template.py b/esphomeyaml/components/sensor/template.py index 78ae6b7021..6b2ced2d5b 100644 --- a/esphomeyaml/components/sensor/template.py +++ b/esphomeyaml/components/sensor/template.py @@ -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)) diff --git a/esphomeyaml/components/switch/template.py b/esphomeyaml/components/switch/template.py index 1aed25db0a..cbad5833c6 100644 --- a/esphomeyaml/components/switch/template.py +++ b/esphomeyaml/components/switch/template.py @@ -5,7 +5,8 @@ from esphomeyaml import automation from esphomeyaml.components import switch from esphomeyaml.const import CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME, CONF_TURN_OFF_ACTION, \ CONF_TURN_ON_ACTION, CONF_OPTIMISTIC -from esphomeyaml.helpers import App, Application, process_lambda, variable, NoArg, add +from esphomeyaml.helpers import App, Application, process_lambda, variable, NoArg, add, bool_, \ + optional MakeTemplateSwitch = Application.MakeTemplateSwitch @@ -24,7 +25,8 @@ def to_code(config): if CONF_LAMBDA in 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 add(make.Ptemplate_.set_state_lambda(template_)) if CONF_TURN_OFF_ACTION in config: