mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Fix optional returns from templates
This commit is contained in:
		| @@ -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)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user