mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Simplify coroutine syntax (#503)
* Simplify coroutine syntax * More * Lint * Fix * More * Lint
This commit is contained in:
		| @@ -6,7 +6,7 @@ import esphome.config_validation as cv | |||||||
| from esphome.const import CONF_ABOVE, CONF_ACTION_ID, CONF_AND, CONF_AUTOMATION_ID, CONF_BELOW, \ | from esphome.const import CONF_ABOVE, CONF_ACTION_ID, CONF_AND, CONF_AUTOMATION_ID, CONF_BELOW, \ | ||||||
|     CONF_CONDITION, CONF_CONDITION_ID, CONF_DELAY, CONF_ELSE, CONF_ID, CONF_IF, CONF_LAMBDA, \ |     CONF_CONDITION, CONF_CONDITION_ID, CONF_DELAY, CONF_ELSE, CONF_ID, CONF_IF, CONF_LAMBDA, \ | ||||||
|     CONF_OR, CONF_RANGE, CONF_THEN, CONF_TRIGGER_ID, CONF_WAIT_UNTIL, CONF_WHILE |     CONF_OR, CONF_RANGE, CONF_THEN, CONF_TRIGGER_ID, CONF_WAIT_UNTIL, CONF_WHILE | ||||||
| from esphome.core import CORE | from esphome.core import CORE, coroutine | ||||||
| from esphome.cpp_generator import Pvariable, TemplateArguments, add, get_variable, \ | from esphome.cpp_generator import Pvariable, TemplateArguments, add, get_variable, \ | ||||||
|     process_lambda, templatable |     process_lambda, templatable | ||||||
| from esphome.cpp_types import Action, App, Component, PollingComponent, Trigger, bool_, \ | from esphome.cpp_types import Action, App, Component, PollingComponent, Trigger, bool_, \ | ||||||
| @@ -167,8 +167,7 @@ AND_CONDITION_SCHEMA = validate_recursive_condition | |||||||
|  |  | ||||||
| @CONDITION_REGISTRY.register(CONF_AND, AND_CONDITION_SCHEMA) | @CONDITION_REGISTRY.register(CONF_AND, AND_CONDITION_SCHEMA) | ||||||
| def and_condition_to_code(config, condition_id, template_arg, args): | def and_condition_to_code(config, condition_id, template_arg, args): | ||||||
|     for conditions in build_conditions(config, template_arg, args): |     conditions = yield build_conditions(config, template_arg, args) | ||||||
|         yield |  | ||||||
|     rhs = AndCondition.new(template_arg, conditions) |     rhs = AndCondition.new(template_arg, conditions) | ||||||
|     type = AndCondition.template(template_arg) |     type = AndCondition.template(template_arg) | ||||||
|     yield Pvariable(condition_id, rhs, type=type) |     yield Pvariable(condition_id, rhs, type=type) | ||||||
| @@ -179,8 +178,7 @@ OR_CONDITION_SCHEMA = validate_recursive_condition | |||||||
|  |  | ||||||
| @CONDITION_REGISTRY.register(CONF_OR, OR_CONDITION_SCHEMA) | @CONDITION_REGISTRY.register(CONF_OR, OR_CONDITION_SCHEMA) | ||||||
| def or_condition_to_code(config, condition_id, template_arg, args): | def or_condition_to_code(config, condition_id, template_arg, args): | ||||||
|     for conditions in build_conditions(config, template_arg, args): |     conditions = yield build_conditions(config, template_arg, args) | ||||||
|         yield |  | ||||||
|     rhs = OrCondition.new(template_arg, conditions) |     rhs = OrCondition.new(template_arg, conditions) | ||||||
|     type = OrCondition.template(template_arg) |     type = OrCondition.template(template_arg) | ||||||
|     yield Pvariable(condition_id, rhs, type=type) |     yield Pvariable(condition_id, rhs, type=type) | ||||||
| @@ -194,18 +192,15 @@ RANGE_CONDITION_SCHEMA = vol.All(cv.Schema({ | |||||||
|  |  | ||||||
| @CONDITION_REGISTRY.register(CONF_RANGE, RANGE_CONDITION_SCHEMA) | @CONDITION_REGISTRY.register(CONF_RANGE, RANGE_CONDITION_SCHEMA) | ||||||
| def range_condition_to_code(config, condition_id, template_arg, args): | def range_condition_to_code(config, condition_id, template_arg, args): | ||||||
|     for conditions in build_conditions(config, template_arg, args): |     conditions = yield build_conditions(config, template_arg, args) | ||||||
|         yield |  | ||||||
|     rhs = RangeCondition.new(template_arg, conditions) |     rhs = RangeCondition.new(template_arg, conditions) | ||||||
|     type = RangeCondition.template(template_arg) |     type = RangeCondition.template(template_arg) | ||||||
|     condition = Pvariable(condition_id, rhs, type=type) |     condition = Pvariable(condition_id, rhs, type=type) | ||||||
|     if CONF_ABOVE in config: |     if CONF_ABOVE in config: | ||||||
|         for template_ in templatable(config[CONF_ABOVE], args, float_): |         template_ = yield templatable(config[CONF_ABOVE], args, float_) | ||||||
|             yield |  | ||||||
|         condition.set_min(template_) |         condition.set_min(template_) | ||||||
|     if CONF_BELOW in config: |     if CONF_BELOW in config: | ||||||
|         for template_ in templatable(config[CONF_BELOW], args, float_): |         template_ = yield templatable(config[CONF_BELOW], args, float_) | ||||||
|             yield |  | ||||||
|         condition.set_max(template_) |         condition.set_max(template_) | ||||||
|     yield condition |     yield condition | ||||||
|  |  | ||||||
| @@ -218,8 +213,7 @@ def delay_action_to_code(config, action_id, template_arg, args): | |||||||
|     rhs = App.register_component(DelayAction.new(template_arg)) |     rhs = App.register_component(DelayAction.new(template_arg)) | ||||||
|     type = DelayAction.template(template_arg) |     type = DelayAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config, args, uint32): |     template_ = yield templatable(config, args, uint32) | ||||||
|         yield |  | ||||||
|     add(action.set_delay(template_)) |     add(action.set_delay(template_)) | ||||||
|     yield action |     yield action | ||||||
|  |  | ||||||
| @@ -233,18 +227,15 @@ IF_ACTION_SCHEMA = vol.All({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_IF, IF_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_IF, IF_ACTION_SCHEMA) | ||||||
| def if_action_to_code(config, action_id, template_arg, args): | def if_action_to_code(config, action_id, template_arg, args): | ||||||
|     for conditions in build_conditions(config[CONF_CONDITION], template_arg, args): |     conditions = yield build_conditions(config[CONF_CONDITION], template_arg, args) | ||||||
|         yield None |  | ||||||
|     rhs = IfAction.new(template_arg, conditions) |     rhs = IfAction.new(template_arg, conditions) | ||||||
|     type = IfAction.template(template_arg) |     type = IfAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     if CONF_THEN in config: |     if CONF_THEN in config: | ||||||
|         for actions in build_actions(config[CONF_THEN], template_arg, args): |         actions = yield build_actions(config[CONF_THEN], template_arg, args) | ||||||
|             yield None |  | ||||||
|         add(action.add_then(actions)) |         add(action.add_then(actions)) | ||||||
|     if CONF_ELSE in config: |     if CONF_ELSE in config: | ||||||
|         for actions in build_actions(config[CONF_ELSE], template_arg, args): |         actions = yield build_actions(config[CONF_ELSE], template_arg, args) | ||||||
|             yield None |  | ||||||
|         add(action.add_else(actions)) |         add(action.add_else(actions)) | ||||||
|     yield action |     yield action | ||||||
|  |  | ||||||
| @@ -257,13 +248,11 @@ WHILE_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_WHILE, WHILE_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_WHILE, WHILE_ACTION_SCHEMA) | ||||||
| def while_action_to_code(config, action_id, template_arg, args): | def while_action_to_code(config, action_id, template_arg, args): | ||||||
|     for conditions in build_conditions(config[CONF_CONDITION], template_arg, args): |     conditions = yield build_conditions(config[CONF_CONDITION], template_arg, args) | ||||||
|         yield None |  | ||||||
|     rhs = WhileAction.new(template_arg, conditions) |     rhs = WhileAction.new(template_arg, conditions) | ||||||
|     type = WhileAction.template(template_arg) |     type = WhileAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for actions in build_actions(config[CONF_THEN], template_arg, args): |     actions = yield build_actions(config[CONF_THEN], template_arg, args) | ||||||
|         yield None |  | ||||||
|     add(action.add_then(actions)) |     add(action.add_then(actions)) | ||||||
|     yield action |     yield action | ||||||
|  |  | ||||||
| @@ -282,8 +271,7 @@ WAIT_UNTIL_ACTION_SCHEMA = validate_wait_until | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_WAIT_UNTIL, WAIT_UNTIL_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_WAIT_UNTIL, WAIT_UNTIL_ACTION_SCHEMA) | ||||||
| def wait_until_action_to_code(config, action_id, template_arg, args): | def wait_until_action_to_code(config, action_id, template_arg, args): | ||||||
|     for conditions in build_conditions(config[CONF_CONDITION], template_arg, args): |     conditions = yield build_conditions(config[CONF_CONDITION], template_arg, args) | ||||||
|         yield None |  | ||||||
|     rhs = WaitUntilAction.new(template_arg, conditions) |     rhs = WaitUntilAction.new(template_arg, conditions) | ||||||
|     type = WaitUntilAction.template(template_arg) |     type = WaitUntilAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
| @@ -296,8 +284,7 @@ LAMBDA_ACTION_SCHEMA = cv.lambda_ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_LAMBDA, LAMBDA_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_LAMBDA, LAMBDA_ACTION_SCHEMA) | ||||||
| def lambda_action_to_code(config, action_id, template_arg, args): | def lambda_action_to_code(config, action_id, template_arg, args): | ||||||
|     for lambda_ in process_lambda(config, args, return_type=void): |     lambda_ = yield process_lambda(config, args, return_type=void) | ||||||
|         yield None |  | ||||||
|     rhs = LambdaAction.new(template_arg, lambda_) |     rhs = LambdaAction.new(template_arg, lambda_) | ||||||
|     type = LambdaAction.template(template_arg) |     type = LambdaAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -308,8 +295,7 @@ LAMBDA_CONDITION_SCHEMA = cv.lambda_ | |||||||
|  |  | ||||||
| @CONDITION_REGISTRY.register(CONF_LAMBDA, LAMBDA_CONDITION_SCHEMA) | @CONDITION_REGISTRY.register(CONF_LAMBDA, LAMBDA_CONDITION_SCHEMA) | ||||||
| def lambda_condition_to_code(config, condition_id, template_arg, args): | def lambda_condition_to_code(config, condition_id, template_arg, args): | ||||||
|     for lambda_ in process_lambda(config, args, return_type=bool_): |     lambda_ = yield process_lambda(config, args, return_type=bool_) | ||||||
|         yield |  | ||||||
|     rhs = LambdaCondition.new(template_arg, lambda_) |     rhs = LambdaCondition.new(template_arg, lambda_) | ||||||
|     type = LambdaCondition.template(template_arg) |     type = LambdaCondition.template(template_arg) | ||||||
|     yield Pvariable(condition_id, rhs, type=type) |     yield Pvariable(condition_id, rhs, type=type) | ||||||
| @@ -323,59 +309,56 @@ COMPONENT_UPDATE_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_COMPONENT_UPDATE, COMPONENT_UPDATE_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_COMPONENT_UPDATE, COMPONENT_UPDATE_ACTION_SCHEMA) | ||||||
| def component_update_action_to_code(config, action_id, template_arg, args): | def component_update_action_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = UpdateComponentAction.new(template_arg, var) |     rhs = UpdateComponentAction.new(template_arg, var) | ||||||
|     type = UpdateComponentAction.template(template_arg) |     type = UpdateComponentAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def build_action(full_config, template_arg, args): | def build_action(full_config, template_arg, args): | ||||||
|     action_id = full_config[CONF_ACTION_ID] |     action_id = full_config[CONF_ACTION_ID] | ||||||
|     key, config = next((k, v) for k, v in full_config.items() if k in ACTION_REGISTRY) |     key, config = next((k, v) for k, v in full_config.items() if k in ACTION_REGISTRY) | ||||||
|  |  | ||||||
|     builder = ACTION_REGISTRY[key][1] |     builder = coroutine(ACTION_REGISTRY[key][1]) | ||||||
|     for result in builder(config, action_id, template_arg, args): |     yield builder(config, action_id, template_arg, args) | ||||||
|         yield None |  | ||||||
|     yield result |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def build_actions(config, templ, arg_type): | def build_actions(config, templ, arg_type): | ||||||
|     actions = [] |     actions = [] | ||||||
|     for conf in config: |     for conf in config: | ||||||
|         for action in build_action(conf, templ, arg_type): |         action = yield build_action(conf, templ, arg_type) | ||||||
|             yield None |  | ||||||
|         actions.append(action) |         actions.append(action) | ||||||
|     yield actions |     yield actions | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def build_condition(full_config, template_arg, args): | def build_condition(full_config, template_arg, args): | ||||||
|     action_id = full_config[CONF_CONDITION_ID] |     action_id = full_config[CONF_CONDITION_ID] | ||||||
|     key, config = next((k, v) for k, v in full_config.items() if k in CONDITION_REGISTRY) |     key, config = next((k, v) for k, v in full_config.items() if k in CONDITION_REGISTRY) | ||||||
|  |  | ||||||
|     builder = CONDITION_REGISTRY[key][1] |     builder = coroutine(CONDITION_REGISTRY[key][1]) | ||||||
|     for result in builder(config, action_id, template_arg, args): |     yield builder(config, action_id, template_arg, args) | ||||||
|         yield None |  | ||||||
|     yield result |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def build_conditions(config, templ, args): | def build_conditions(config, templ, args): | ||||||
|     conditions = [] |     conditions = [] | ||||||
|     for conf in config: |     for conf in config: | ||||||
|         for condition in build_condition(conf, templ, args): |         condition = yield build_condition(conf, templ, args) | ||||||
|             yield None |  | ||||||
|         conditions.append(condition) |         conditions.append(condition) | ||||||
|     yield conditions |     yield conditions | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def build_automation_(trigger, args, config): | def build_automation_(trigger, args, config): | ||||||
|     arg_types = [arg[0] for arg in args] |     arg_types = [arg[0] for arg in args] | ||||||
|     templ = TemplateArguments(*arg_types) |     templ = TemplateArguments(*arg_types) | ||||||
|     rhs = App.make_automation(templ, trigger) |     rhs = App.make_automation(templ, trigger) | ||||||
|     type = Automation.template(templ) |     type = Automation.template(templ) | ||||||
|     obj = Pvariable(config[CONF_AUTOMATION_ID], rhs, type=type) |     obj = Pvariable(config[CONF_AUTOMATION_ID], rhs, type=type) | ||||||
|     for actions in build_actions(config[CONF_THEN], templ, args): |     actions = yield build_actions(config[CONF_THEN], templ, args) | ||||||
|         yield None |  | ||||||
|     add(obj.add_actions(actions)) |     add(obj.add_actions(actions)) | ||||||
|     yield obj |     yield obj | ||||||
|  |  | ||||||
|   | |||||||
| @@ -108,8 +108,7 @@ HOMEASSISTANT_SERVIC_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_HOMEASSISTANT_SERVICE, HOMEASSISTANT_SERVIC_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_HOMEASSISTANT_SERVICE, HOMEASSISTANT_SERVIC_ACTION_SCHEMA) | ||||||
| def homeassistant_service_to_code(config, action_id, template_arg, args): | def homeassistant_service_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_home_assistant_service_call_action(template_arg) |     rhs = var.make_home_assistant_service_call_action(template_arg) | ||||||
|     type = HomeAssistantServiceCallAction.template(template_arg) |     type = HomeAssistantServiceCallAction.template(template_arg) | ||||||
|     act = Pvariable(action_id, rhs, type=type) |     act = Pvariable(action_id, rhs, type=type) | ||||||
| @@ -123,8 +122,7 @@ def homeassistant_service_to_code(config, action_id, template_arg, args): | |||||||
|     if CONF_VARIABLES in config: |     if CONF_VARIABLES in config: | ||||||
|         datas = [] |         datas = [] | ||||||
|         for key, value in config[CONF_VARIABLES].items(): |         for key, value in config[CONF_VARIABLES].items(): | ||||||
|             for value_ in process_lambda(value, []): |             value_ = yield process_lambda(value, []) | ||||||
|                 yield None |  | ||||||
|             datas.append(TemplatableKeyValuePair(key, value_)) |             datas.append(TemplatableKeyValuePair(key, value_)) | ||||||
|         add(act.set_variables(datas)) |         add(act.set_variables(datas)) | ||||||
|     yield act |     yield act | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ from esphome.const import CONF_DELAYED_OFF, CONF_DELAYED_ON, CONF_DEVICE_CLASS, | |||||||
|     CONF_LAMBDA, CONF_MAX_LENGTH, CONF_MIN_LENGTH, CONF_MQTT_ID, CONF_ON_CLICK, \ |     CONF_LAMBDA, CONF_MAX_LENGTH, CONF_MIN_LENGTH, CONF_MQTT_ID, CONF_ON_CLICK, \ | ||||||
|     CONF_ON_DOUBLE_CLICK, CONF_ON_MULTI_CLICK, CONF_ON_PRESS, CONF_ON_RELEASE, CONF_ON_STATE, \ |     CONF_ON_DOUBLE_CLICK, CONF_ON_MULTI_CLICK, CONF_ON_PRESS, CONF_ON_RELEASE, CONF_ON_STATE, \ | ||||||
|     CONF_STATE, CONF_TIMING, CONF_TRIGGER_ID, CONF_FOR |     CONF_STATE, CONF_TIMING, CONF_TRIGGER_ID, CONF_FOR | ||||||
| from esphome.core import CORE | from esphome.core import CORE, coroutine | ||||||
| from esphome.cpp_generator import Pvariable, StructInitializer, add, get_variable, process_lambda | from esphome.cpp_generator import Pvariable, StructInitializer, add, get_variable, process_lambda | ||||||
| from esphome.cpp_types import App, Component, Nameable, Trigger, bool_, esphome_ns, optional | from esphome.cpp_types import App, Component, Nameable, Trigger, bool_, esphome_ns, optional | ||||||
| from esphome.py_compat import string_types | from esphome.py_compat import string_types | ||||||
| @@ -196,6 +196,7 @@ BINARY_SENSOR_SCHEMA = cv.MQTT_COMPONENT_SCHEMA.extend({ | |||||||
| BINARY_SENSOR_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(BINARY_SENSOR_SCHEMA.schema) | BINARY_SENSOR_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(BINARY_SENSOR_SCHEMA.schema) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def setup_filter(config): | def setup_filter(config): | ||||||
|     if CONF_INVERT in config: |     if CONF_INVERT in config: | ||||||
|         yield InvertFilter.new() |         yield InvertFilter.new() | ||||||
| @@ -204,21 +205,20 @@ def setup_filter(config): | |||||||
|     elif CONF_DELAYED_ON in config: |     elif CONF_DELAYED_ON in config: | ||||||
|         yield App.register_component(DelayedOnFilter.new(config[CONF_DELAYED_ON])) |         yield App.register_component(DelayedOnFilter.new(config[CONF_DELAYED_ON])) | ||||||
|     elif CONF_LAMBDA in config: |     elif CONF_LAMBDA in config: | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], [(bool_, 'x')], |         lambda_ = yield process_lambda(config[CONF_LAMBDA], [(bool_, 'x')], | ||||||
|                                       return_type=optional.template(bool_)): |                                        return_type=optional.template(bool_)) | ||||||
|             yield None |  | ||||||
|         yield LambdaFilter.new(lambda_) |         yield LambdaFilter.new(lambda_) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def setup_filters(config): | def setup_filters(config): | ||||||
|     filters = [] |     filters = [] | ||||||
|     for conf in config: |     for conf in config: | ||||||
|         for filter in setup_filter(conf): |         filters.append((yield setup_filter(conf))) | ||||||
|             yield None |  | ||||||
|         filters.append(filter) |  | ||||||
|     yield filters |     yield filters | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def setup_binary_sensor_core_(binary_sensor_var, config): | def setup_binary_sensor_core_(binary_sensor_var, config): | ||||||
|     if CONF_INTERNAL in config: |     if CONF_INTERNAL in config: | ||||||
|         add(binary_sensor_var.set_internal(CONF_INTERNAL)) |         add(binary_sensor_var.set_internal(CONF_INTERNAL)) | ||||||
| @@ -227,8 +227,7 @@ def setup_binary_sensor_core_(binary_sensor_var, config): | |||||||
|     if CONF_INVERTED in config: |     if CONF_INVERTED in config: | ||||||
|         add(binary_sensor_var.set_inverted(config[CONF_INVERTED])) |         add(binary_sensor_var.set_inverted(config[CONF_INVERTED])) | ||||||
|     if CONF_FILTERS in config: |     if CONF_FILTERS in config: | ||||||
|         for filters in setup_filters(config[CONF_FILTERS]): |         filters = yield setup_filters(config[CONF_FILTERS]) | ||||||
|             yield |  | ||||||
|         add(binary_sensor_var.add_filters(filters)) |         add(binary_sensor_var.add_filters(filters)) | ||||||
|  |  | ||||||
|     for conf in config.get(CONF_ON_PRESS, []): |     for conf in config.get(CONF_ON_PRESS, []): | ||||||
| @@ -298,8 +297,7 @@ BINARY_SENSOR_IS_ON_CONDITION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @CONDITION_REGISTRY.register(CONF_BINARY_SENSOR_IS_ON, BINARY_SENSOR_IS_ON_CONDITION_SCHEMA) | @CONDITION_REGISTRY.register(CONF_BINARY_SENSOR_IS_ON, BINARY_SENSOR_IS_ON_CONDITION_SCHEMA) | ||||||
| def binary_sensor_is_on_to_code(config, condition_id, template_arg, args): | def binary_sensor_is_on_to_code(config, condition_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_binary_sensor_is_on_condition(template_arg, config.get(CONF_FOR)) |     rhs = var.make_binary_sensor_is_on_condition(template_arg, config.get(CONF_FOR)) | ||||||
|     type = BinarySensorCondition.template(template_arg) |     type = BinarySensorCondition.template(template_arg) | ||||||
|     yield Pvariable(condition_id, rhs, type=type) |     yield Pvariable(condition_id, rhs, type=type) | ||||||
| @@ -314,8 +312,7 @@ BINARY_SENSOR_IS_OFF_CONDITION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @CONDITION_REGISTRY.register(CONF_BINARY_SENSOR_IS_OFF, BINARY_SENSOR_IS_OFF_CONDITION_SCHEMA) | @CONDITION_REGISTRY.register(CONF_BINARY_SENSOR_IS_OFF, BINARY_SENSOR_IS_OFF_CONDITION_SCHEMA) | ||||||
| def binary_sensor_is_off_to_code(config, condition_id, template_arg, args): | def binary_sensor_is_off_to_code(config, condition_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_binary_sensor_is_off_condition(template_arg, config.get(CONF_FOR)) |     rhs = var.make_binary_sensor_is_off_condition(template_arg, config.get(CONF_FOR)) | ||||||
|     type = BinarySensorCondition.template(template_arg) |     type = BinarySensorCondition.template(template_arg) | ||||||
|     yield Pvariable(condition_id, rhs, type=type) |     yield Pvariable(condition_id, rhs, type=type) | ||||||
|   | |||||||
| @@ -25,8 +25,7 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_APDS9960_ID]): |     hub = yield get_variable(config[CONF_APDS9960_ID]) | ||||||
|         yield |  | ||||||
|     func = getattr(hub, DIRECTIONS[config[CONF_DIRECTION]]) |     func = getattr(hub, DIRECTIONS[config[CONF_DIRECTION]]) | ||||||
|     rhs = func(config[CONF_NAME]) |     rhs = func(config[CONF_NAME]) | ||||||
|     binary_sensor.register_binary_sensor(rhs, config) |     binary_sensor.register_binary_sensor(rhs, config) | ||||||
|   | |||||||
| @@ -20,9 +20,8 @@ PLATFORM_SCHEMA = binary_sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for template_ in process_lambda(config[CONF_LAMBDA], [], |     template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                     return_type=std_vector.template(binary_sensor.BinarySensorPtr)): |                                      return_type=std_vector.template(binary_sensor.BinarySensorPtr)) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = CustomBinarySensorConstructor(template_) |     rhs = CustomBinarySensorConstructor(template_) | ||||||
|     custom = variable(config[CONF_ID], rhs) |     custom = variable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_ESP32_BLE_ID]): |     hub = yield get_variable(config[CONF_ESP32_BLE_ID]) | ||||||
|         yield |  | ||||||
|     rhs = hub.make_presence_sensor(config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS])) |     rhs = hub.make_presence_sensor(config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS])) | ||||||
|     binary_sensor.register_binary_sensor(rhs, config) |     binary_sensor.register_binary_sensor(rhs, config) | ||||||
|   | |||||||
| @@ -47,9 +47,7 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     hub = None |     hub = yield get_variable(config[CONF_ESP32_TOUCH_ID]) | ||||||
|     for hub in get_variable(config[CONF_ESP32_TOUCH_ID]): |  | ||||||
|         yield |  | ||||||
|     touch_pad = TOUCH_PADS[config[CONF_PIN]] |     touch_pad = TOUCH_PADS[config[CONF_PIN]] | ||||||
|     rhs = hub.make_touch_pad(config[CONF_NAME], touch_pad, config[CONF_THRESHOLD]) |     rhs = hub.make_touch_pad(config[CONF_NAME], touch_pad, config[CONF_THRESHOLD]) | ||||||
|     binary_sensor.register_binary_sensor(rhs, config) |     binary_sensor.register_binary_sensor(rhs, config) | ||||||
|   | |||||||
| @@ -19,9 +19,7 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     pin = None |     pin = yield gpio_input_pin_expression(config[CONF_PIN]) | ||||||
|     for pin in gpio_input_pin_expression(config[CONF_PIN]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_gpio_binary_sensor(config[CONF_NAME], pin) |     rhs = App.make_gpio_binary_sensor(config[CONF_NAME], pin) | ||||||
|     gpio = Pvariable(config[CONF_ID], rhs) |     gpio = Pvariable(config[CONF_ID], rhs) | ||||||
|     binary_sensor.setup_binary_sensor(gpio, config) |     binary_sensor.setup_binary_sensor(gpio, config) | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_MPR121_ID]): |     hub = yield get_variable(config[CONF_MPR121_ID]) | ||||||
|         yield |  | ||||||
|     rhs = MPR121Channel.new(config[CONF_NAME], config[CONF_CHANNEL]) |     rhs = MPR121Channel.new(config[CONF_NAME], config[CONF_CHANNEL]) | ||||||
|     binary_sensor.register_binary_sensor(hub.add_channel(rhs), config) |     binary_sensor.register_binary_sensor(hub.add_channel(rhs), config) | ||||||
|   | |||||||
| @@ -22,8 +22,7 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_NEXTION_ID]): |     hub = yield get_variable(config[CONF_NEXTION_ID]) | ||||||
|         yield |  | ||||||
|     rhs = hub.make_touch_component(config[CONF_NAME], config[CONF_PAGE_ID], |     rhs = hub.make_touch_component(config[CONF_NAME], config[CONF_PAGE_ID], | ||||||
|                                    config[CONF_COMPONENT_ID]) |                                    config[CONF_COMPONENT_ID]) | ||||||
|     binary_sensor.register_binary_sensor(rhs, config) |     binary_sensor.register_binary_sensor(rhs, config) | ||||||
|   | |||||||
| @@ -38,8 +38,7 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_PN532_ID]): |     hub = yield get_variable(config[CONF_PN532_ID]) | ||||||
|         yield |  | ||||||
|     addr = [HexInt(int(x, 16)) for x in config[CONF_UID].split('-')] |     addr = [HexInt(int(x, 16)) for x in config[CONF_UID].split('-')] | ||||||
|     rhs = hub.make_tag(config[CONF_NAME], addr) |     rhs = hub.make_tag(config[CONF_NAME], addr) | ||||||
|     binary_sensor.register_binary_sensor(rhs, config) |     binary_sensor.register_binary_sensor(rhs, config) | ||||||
|   | |||||||
| @@ -20,7 +20,6 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_RDM6300_ID]): |     hub = yield get_variable(config[CONF_RDM6300_ID]) | ||||||
|         yield |  | ||||||
|     rhs = hub.make_card(config[CONF_NAME], config[CONF_UID]) |     rhs = hub.make_card(config[CONF_NAME], config[CONF_UID]) | ||||||
|     binary_sensor.register_binary_sensor(rhs, config) |     binary_sensor.register_binary_sensor(rhs, config) | ||||||
|   | |||||||
| @@ -136,8 +136,7 @@ def receiver_base(full_config): | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for remote in get_variable(config[CONF_REMOTE_RECEIVER_ID]): |     remote = yield get_variable(config[CONF_REMOTE_RECEIVER_ID]) | ||||||
|         yield |  | ||||||
|     rhs = receiver_base(config) |     rhs = receiver_base(config) | ||||||
|     receiver = Pvariable(config[CONF_RECEIVER_ID], rhs) |     receiver = Pvariable(config[CONF_RECEIVER_ID], rhs) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -27,9 +27,8 @@ def to_code(config): | |||||||
|     setup_component(var, config) |     setup_component(var, config) | ||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for template_ in process_lambda(config[CONF_LAMBDA], [], |         template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                         return_type=optional.template(bool_)): |                                          return_type=optional.template(bool_)) | ||||||
|             yield |  | ||||||
|         add(var.set_template(template_)) |         add(var.set_template(template_)) | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -45,12 +44,10 @@ BINARY_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA = cv.Schema({ | |||||||
| @ACTION_REGISTRY.register(CONF_BINARY_SENSOR_TEMPLATE_PUBLISH, | @ACTION_REGISTRY.register(CONF_BINARY_SENSOR_TEMPLATE_PUBLISH, | ||||||
|                           BINARY_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA) |                           BINARY_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA) | ||||||
| def binary_sensor_template_publish_to_code(config, action_id, template_arg, args): | def binary_sensor_template_publish_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_binary_sensor_publish_action(template_arg) |     rhs = var.make_binary_sensor_publish_action(template_arg) | ||||||
|     type = BinarySensorPublishAction.template(template_arg) |     type = BinarySensorPublishAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config[CONF_STATE], args, bool_): |     template_ = yield templatable(config[CONF_STATE], args, bool_) | ||||||
|         yield None |  | ||||||
|     add(action.set_state(template_)) |     add(action.set_state(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -18,7 +18,6 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_TTP229_ID]): |     hub = yield get_variable(config[CONF_TTP229_ID]) | ||||||
|         yield |  | ||||||
|     rhs = TTP229Channel.new(config[CONF_NAME], config[CONF_CHANNEL]) |     rhs = TTP229Channel.new(config[CONF_NAME], config[CONF_CHANNEL]) | ||||||
|     binary_sensor.register_binary_sensor(hub.add_channel(rhs), config) |     binary_sensor.register_binary_sensor(hub.add_channel(rhs), config) | ||||||
|   | |||||||
| @@ -1,6 +1,5 @@ | |||||||
| import voluptuous as vol | import voluptuous as vol | ||||||
|  |  | ||||||
| from esphome import core |  | ||||||
| from esphome.automation import ACTION_REGISTRY | from esphome.automation import ACTION_REGISTRY | ||||||
| from esphome.components import mqtt | from esphome.components import mqtt | ||||||
| from esphome.components.mqtt import setup_mqtt_component | from esphome.components.mqtt import setup_mqtt_component | ||||||
| @@ -8,7 +7,7 @@ import esphome.config_validation as cv | |||||||
| from esphome.const import CONF_AWAY, CONF_ID, CONF_INTERNAL, CONF_MAX_TEMPERATURE, \ | from esphome.const import CONF_AWAY, CONF_ID, CONF_INTERNAL, CONF_MAX_TEMPERATURE, \ | ||||||
|     CONF_MIN_TEMPERATURE, CONF_MODE, CONF_MQTT_ID, CONF_TARGET_TEMPERATURE, \ |     CONF_MIN_TEMPERATURE, CONF_MODE, CONF_MQTT_ID, CONF_TARGET_TEMPERATURE, \ | ||||||
|     CONF_TARGET_TEMPERATURE_HIGH, CONF_TARGET_TEMPERATURE_LOW, CONF_TEMPERATURE_STEP, CONF_VISUAL |     CONF_TARGET_TEMPERATURE_HIGH, CONF_TARGET_TEMPERATURE_LOW, CONF_TEMPERATURE_STEP, CONF_VISUAL | ||||||
| from esphome.core import CORE | from esphome.core import CORE, coroutine | ||||||
| from esphome.cpp_generator import Pvariable, add, get_variable, templatable | from esphome.cpp_generator import Pvariable, add, get_variable, templatable | ||||||
| from esphome.cpp_types import Action, App, Nameable, bool_, esphome_ns, float_ | from esphome.cpp_types import Action, App, Nameable, bool_, esphome_ns, float_ | ||||||
|  |  | ||||||
| @@ -49,6 +48,7 @@ CLIMATE_SCHEMA = cv.MQTT_COMMAND_COMPONENT_SCHEMA.extend({ | |||||||
| CLIMATE_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(CLIMATE_SCHEMA.schema) | CLIMATE_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(CLIMATE_SCHEMA.schema) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def setup_climate_core_(climate_var, config): | def setup_climate_core_(climate_var, config): | ||||||
|     if CONF_INTERNAL in config: |     if CONF_INTERNAL in config: | ||||||
|         add(climate_var.set_internal(config[CONF_INTERNAL])) |         add(climate_var.set_internal(config[CONF_INTERNAL])) | ||||||
| @@ -84,32 +84,24 @@ CLIMATE_CONTROL_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_CLIMATE_CONTROL, CLIMATE_CONTROL_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_CLIMATE_CONTROL, CLIMATE_CONTROL_ACTION_SCHEMA) | ||||||
| def climate_control_to_code(config, action_id, template_arg, args): | def climate_control_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = ControlAction.template(template_arg) |     type = ControlAction.template(template_arg) | ||||||
|     rhs = type.new(var) |     rhs = type.new(var) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     if CONF_MODE in config: |     if CONF_MODE in config: | ||||||
|         if isinstance(config[CONF_MODE], core.Lambda): |         template_ = yield templatable(config[CONF_MODE], args, ClimateMode, | ||||||
|             for template_ in templatable(config[CONF_MODE], args, ClimateMode): |                                       to_exp=CLIMATE_MODES) | ||||||
|                 yield None |  | ||||||
|         add(action.set_mode(template_)) |         add(action.set_mode(template_)) | ||||||
|         else: |  | ||||||
|             add(action.set_mode(CLIMATE_MODES[config[CONF_MODE]])) |  | ||||||
|     if CONF_TARGET_TEMPERATURE in config: |     if CONF_TARGET_TEMPERATURE in config: | ||||||
|         for template_ in templatable(config[CONF_TARGET_TEMPERATURE], args, float_): |         template_ = yield templatable(config[CONF_TARGET_TEMPERATURE], args, float_) | ||||||
|             yield None |  | ||||||
|         add(action.set_target_temperature(template_)) |         add(action.set_target_temperature(template_)) | ||||||
|     if CONF_TARGET_TEMPERATURE_LOW in config: |     if CONF_TARGET_TEMPERATURE_LOW in config: | ||||||
|         for template_ in templatable(config[CONF_TARGET_TEMPERATURE_LOW], args, float_): |         template_ = yield templatable(config[CONF_TARGET_TEMPERATURE_LOW], args, float_) | ||||||
|             yield None |  | ||||||
|         add(action.set_target_temperature_low(template_)) |         add(action.set_target_temperature_low(template_)) | ||||||
|     if CONF_TARGET_TEMPERATURE_HIGH in config: |     if CONF_TARGET_TEMPERATURE_HIGH in config: | ||||||
|         for template_ in templatable(config[CONF_TARGET_TEMPERATURE_HIGH], args, float_): |         template_ = yield templatable(config[CONF_TARGET_TEMPERATURE_HIGH], args, float_) | ||||||
|             yield None |  | ||||||
|         add(action.set_target_temperature_high(template_)) |         add(action.set_target_temperature_high(template_)) | ||||||
|     if CONF_AWAY in config: |     if CONF_AWAY in config: | ||||||
|         for template_ in templatable(config[CONF_AWAY], args, bool_): |         template_ = yield templatable(config[CONF_AWAY], args, bool_) | ||||||
|             yield None |  | ||||||
|         add(action.set_away(template_)) |         add(action.set_away(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -35,8 +35,7 @@ def to_code(config): | |||||||
|     climate.register_climate(control, config) |     climate.register_climate(control, config) | ||||||
|     setup_component(control, config) |     setup_component(control, config) | ||||||
|  |  | ||||||
|     for var in get_variable(config[CONF_SENSOR]): |     var = yield get_variable(config[CONF_SENSOR]) | ||||||
|         yield |  | ||||||
|     add(control.set_sensor(var)) |     add(control.set_sensor(var)) | ||||||
|  |  | ||||||
|     normal_config = BangBangClimateTargetTempConfig( |     normal_config = BangBangClimateTargetTempConfig( | ||||||
|   | |||||||
| @@ -87,8 +87,7 @@ COVER_OPEN_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_COVER_OPEN, COVER_OPEN_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_COVER_OPEN, COVER_OPEN_ACTION_SCHEMA) | ||||||
| def cover_open_to_code(config, action_id, template_arg, args): | def cover_open_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = OpenAction.template(template_arg) |     type = OpenAction.template(template_arg) | ||||||
|     rhs = type.new(var) |     rhs = type.new(var) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -102,8 +101,7 @@ COVER_CLOSE_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_COVER_CLOSE, COVER_CLOSE_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_COVER_CLOSE, COVER_CLOSE_ACTION_SCHEMA) | ||||||
| def cover_close_to_code(config, action_id, template_arg, args): | def cover_close_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = CloseAction.template(template_arg) |     type = CloseAction.template(template_arg) | ||||||
|     rhs = type.new(var) |     rhs = type.new(var) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -117,8 +115,7 @@ COVER_STOP_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_COVER_STOP, COVER_STOP_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_COVER_STOP, COVER_STOP_ACTION_SCHEMA) | ||||||
| def cover_stop_to_code(config, action_id, template_arg, args): | def cover_stop_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = StopAction.template(template_arg) |     type = StopAction.template(template_arg) | ||||||
|     rhs = type.new(var) |     rhs = type.new(var) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -136,26 +133,21 @@ COVER_CONTROL_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_COVER_CONTROL, COVER_CONTROL_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_COVER_CONTROL, COVER_CONTROL_ACTION_SCHEMA) | ||||||
| def cover_control_to_code(config, action_id, template_arg, args): | def cover_control_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = StopAction.template(template_arg) |     type = StopAction.template(template_arg) | ||||||
|     rhs = type.new(var) |     rhs = type.new(var) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     if CONF_STOP in config: |     if CONF_STOP in config: | ||||||
|         for template_ in templatable(config[CONF_STOP], args, bool): |         template_ = yield templatable(config[CONF_STOP], args, bool) | ||||||
|             yield None |  | ||||||
|         add(action.set_stop(template_)) |         add(action.set_stop(template_)) | ||||||
|     if CONF_STATE in config: |     if CONF_STATE in config: | ||||||
|         for template_ in templatable(config[CONF_STATE], args, float, |         template_ = yield templatable(config[CONF_STATE], args, float, | ||||||
|                                      to_exp=COVER_STATES): |                                       to_exp=COVER_STATES) | ||||||
|             yield None |  | ||||||
|         add(action.set_position(template_)) |         add(action.set_position(template_)) | ||||||
|     if CONF_POSITION in config: |     if CONF_POSITION in config: | ||||||
|         for template_ in templatable(config[CONF_POSITION], args, float): |         template_ = yield templatable(config[CONF_POSITION], args, float) | ||||||
|             yield None |  | ||||||
|         add(action.set_position(template_)) |         add(action.set_position(template_)) | ||||||
|     if CONF_TILT in config: |     if CONF_TILT in config: | ||||||
|         for template_ in templatable(config[CONF_TILT], args, float): |         template_ = yield templatable(config[CONF_TILT], args, float) | ||||||
|             yield None |  | ||||||
|         add(action.set_tilt(template_)) |         add(action.set_tilt(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -36,15 +36,13 @@ def to_code(config): | |||||||
|     automation.build_automations(var.get_stop_trigger(), [], |     automation.build_automations(var.get_stop_trigger(), [], | ||||||
|                                  config[CONF_STOP_ACTION]) |                                  config[CONF_STOP_ACTION]) | ||||||
|  |  | ||||||
|     for bin in get_variable(config[CONF_OPEN_ENDSTOP]): |     bin = yield get_variable(config[CONF_OPEN_ENDSTOP]) | ||||||
|         yield |  | ||||||
|     add(var.set_open_endstop(bin)) |     add(var.set_open_endstop(bin)) | ||||||
|     add(var.set_open_duration(config[CONF_OPEN_DURATION])) |     add(var.set_open_duration(config[CONF_OPEN_DURATION])) | ||||||
|     automation.build_automations(var.get_open_trigger(), [], |     automation.build_automations(var.get_open_trigger(), [], | ||||||
|                                  config[CONF_OPEN_ACTION]) |                                  config[CONF_OPEN_ACTION]) | ||||||
|  |  | ||||||
|     for bin in get_variable(config[CONF_CLOSE_ENDSTOP]): |     bin = yield get_variable(config[CONF_CLOSE_ENDSTOP]) | ||||||
|         yield |  | ||||||
|     add(var.set_close_endstop(bin)) |     add(var.set_close_endstop(bin)) | ||||||
|     add(var.set_close_duration(config[CONF_CLOSE_DURATION])) |     add(var.set_close_duration(config[CONF_CLOSE_DURATION])) | ||||||
|     automation.build_automations(var.get_close_trigger(), [], |     automation.build_automations(var.get_close_trigger(), [], | ||||||
|   | |||||||
| @@ -4,9 +4,9 @@ from esphome import automation | |||||||
| from esphome.automation import ACTION_REGISTRY | from esphome.automation import ACTION_REGISTRY | ||||||
| from esphome.components import cover | from esphome.components import cover | ||||||
| import esphome.config_validation as cv | import esphome.config_validation as cv | ||||||
| from esphome.const import CONF_ASSUMED_STATE, CONF_CLOSE_ACTION, CONF_ID, CONF_LAMBDA, CONF_NAME, \ | from esphome.const import CONF_ASSUMED_STATE, CONF_CLOSE_ACTION, CONF_CURRENT_OPERATION, CONF_ID, \ | ||||||
|     CONF_OPEN_ACTION, CONF_OPTIMISTIC, CONF_STATE, CONF_STOP_ACTION, CONF_POSITION, \ |     CONF_LAMBDA, CONF_NAME, CONF_OPEN_ACTION, CONF_OPTIMISTIC, CONF_POSITION, CONF_RESTORE_MODE, \ | ||||||
|     CONF_CURRENT_OPERATION, CONF_RESTORE_MODE |     CONF_STATE, CONF_STOP_ACTION | ||||||
| from esphome.cpp_generator import Pvariable, add, get_variable, process_lambda, templatable | from esphome.cpp_generator import Pvariable, add, get_variable, process_lambda, templatable | ||||||
| from esphome.cpp_helpers import setup_component | from esphome.cpp_helpers import setup_component | ||||||
| from esphome.cpp_types import Action, App, optional | from esphome.cpp_types import Action, App, optional | ||||||
| @@ -40,9 +40,8 @@ def to_code(config): | |||||||
|     setup_component(var, config) |     setup_component(var, config) | ||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for template_ in process_lambda(config[CONF_LAMBDA], [], |         template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                         return_type=optional.template(float)): |                                          return_type=optional.template(float)) | ||||||
|             yield |  | ||||||
|         add(var.set_state_lambda(template_)) |         add(var.set_state_lambda(template_)) | ||||||
|     if CONF_OPEN_ACTION in config: |     if CONF_OPEN_ACTION in config: | ||||||
|         automation.build_automations(var.get_open_trigger(), [], |         automation.build_automations(var.get_open_trigger(), [], | ||||||
| @@ -75,24 +74,20 @@ COVER_TEMPLATE_PUBLISH_ACTION_SCHEMA = cv.Schema({ | |||||||
| @ACTION_REGISTRY.register(CONF_COVER_TEMPLATE_PUBLISH, | @ACTION_REGISTRY.register(CONF_COVER_TEMPLATE_PUBLISH, | ||||||
|                           COVER_TEMPLATE_PUBLISH_ACTION_SCHEMA) |                           COVER_TEMPLATE_PUBLISH_ACTION_SCHEMA) | ||||||
| def cover_template_publish_to_code(config, action_id, template_arg, args): | def cover_template_publish_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = CoverPublishAction.template(template_arg) |     type = CoverPublishAction.template(template_arg) | ||||||
|     rhs = type.new(var) |     rhs = type.new(var) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     if CONF_STATE in config: |     if CONF_STATE in config: | ||||||
|         for template_ in templatable(config[CONF_STATE], args, float, |         template_ = yield templatable(config[CONF_STATE], args, float, | ||||||
|                                      to_exp=cover.COVER_STATES): |                                       to_exp=cover.COVER_STATES) | ||||||
|             yield None |  | ||||||
|         add(action.set_position(template_)) |         add(action.set_position(template_)) | ||||||
|     if CONF_POSITION in config: |     if CONF_POSITION in config: | ||||||
|         for template_ in templatable(config[CONF_POSITION], args, float, |         template_ = yield templatable(config[CONF_POSITION], args, float, | ||||||
|                                      to_exp=cover.COVER_STATES): |                                       to_exp=cover.COVER_STATES) | ||||||
|             yield None |  | ||||||
|         add(action.set_position(template_)) |         add(action.set_position(template_)) | ||||||
|     if CONF_CURRENT_OPERATION in config: |     if CONF_CURRENT_OPERATION in config: | ||||||
|         for template_ in templatable(config[CONF_CURRENT_OPERATION], args, cover.CoverOperation, |         template_ = yield templatable(config[CONF_CURRENT_OPERATION], args, cover.CoverOperation, | ||||||
|                                      to_exp=cover.COVER_OPERATIONS): |                                       to_exp=cover.COVER_OPERATIONS) | ||||||
|             yield None |  | ||||||
|         add(action.set_current_operation(template_)) |         add(action.set_current_operation(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -19,9 +19,8 @@ CONFIG_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for template_ in process_lambda(config[CONF_LAMBDA], [], |     template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                     return_type=std_vector.template(ComponentPtr)): |                                      return_type=std_vector.template(ComponentPtr)) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = CustomComponentConstructor(template_) |     rhs = CustomComponentConstructor(template_) | ||||||
|     custom = variable(config[CONF_ID], rhs) |     custom = variable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -63,8 +63,7 @@ def to_code(config): | |||||||
|     if CONF_SLEEP_DURATION in config: |     if CONF_SLEEP_DURATION in config: | ||||||
|         add(deep_sleep.set_sleep_duration(config[CONF_SLEEP_DURATION])) |         add(deep_sleep.set_sleep_duration(config[CONF_SLEEP_DURATION])) | ||||||
|     if CONF_WAKEUP_PIN in config: |     if CONF_WAKEUP_PIN in config: | ||||||
|         for pin in gpio_input_pin_expression(config[CONF_WAKEUP_PIN]): |         pin = yield gpio_input_pin_expression(config[CONF_WAKEUP_PIN]) | ||||||
|             yield |  | ||||||
|         add(deep_sleep.set_wakeup_pin(pin)) |         add(deep_sleep.set_wakeup_pin(pin)) | ||||||
|     if CONF_WAKEUP_PIN_MODE in config: |     if CONF_WAKEUP_PIN_MODE in config: | ||||||
|         add(deep_sleep.set_wakeup_pin_mode(WAKEUP_PIN_MODES[config[CONF_WAKEUP_PIN_MODE]])) |         add(deep_sleep.set_wakeup_pin_mode(WAKEUP_PIN_MODES[config[CONF_WAKEUP_PIN_MODE]])) | ||||||
| @@ -96,8 +95,7 @@ DEEP_SLEEP_ENTER_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_DEEP_SLEEP_ENTER, DEEP_SLEEP_ENTER_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_DEEP_SLEEP_ENTER, DEEP_SLEEP_ENTER_ACTION_SCHEMA) | ||||||
| def deep_sleep_enter_to_code(config, action_id, template_arg, args): | def deep_sleep_enter_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_enter_deep_sleep_action(template_arg) |     rhs = var.make_enter_deep_sleep_action(template_arg) | ||||||
|     type = EnterDeepSleepAction.template(template_arg) |     type = EnterDeepSleepAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -111,8 +109,7 @@ DEEP_SLEEP_PREVENT_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_DEEP_SLEEP_PREVENT, DEEP_SLEEP_PREVENT_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_DEEP_SLEEP_PREVENT, DEEP_SLEEP_PREVENT_ACTION_SCHEMA) | ||||||
| def deep_sleep_prevent_to_code(config, action_id, template_arg, args): | def deep_sleep_prevent_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_prevent_deep_sleep_action(template_arg) |     rhs = var.make_prevent_deep_sleep_action(template_arg) | ||||||
|     type = PreventDeepSleepAction.template(template_arg) |     type = PreventDeepSleepAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
|   | |||||||
| @@ -4,10 +4,10 @@ import voluptuous as vol | |||||||
| from esphome import core | from esphome import core | ||||||
| from esphome.automation import ACTION_REGISTRY, maybe_simple_id | from esphome.automation import ACTION_REGISTRY, maybe_simple_id | ||||||
| import esphome.config_validation as cv | import esphome.config_validation as cv | ||||||
| from esphome.const import CONF_LAMBDA, CONF_ROTATION, CONF_UPDATE_INTERVAL, CONF_PAGES, CONF_ID | from esphome.const import CONF_ID, CONF_LAMBDA, CONF_PAGES, CONF_ROTATION, CONF_UPDATE_INTERVAL | ||||||
| from esphome.core import CORE | from esphome.core import CORE | ||||||
| from esphome.cpp_generator import add, process_lambda, Pvariable, templatable, get_variable | from esphome.cpp_generator import Pvariable, add, get_variable, process_lambda, templatable | ||||||
| from esphome.cpp_types import esphome_ns, void, Action | from esphome.cpp_types import Action, esphome_ns, void | ||||||
|  |  | ||||||
| PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({ | PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({ | ||||||
|  |  | ||||||
| @@ -63,9 +63,8 @@ def setup_display_core_(display_var, config): | |||||||
|     if CONF_PAGES in config: |     if CONF_PAGES in config: | ||||||
|         pages = [] |         pages = [] | ||||||
|         for conf in config[CONF_PAGES]: |         for conf in config[CONF_PAGES]: | ||||||
|             for lambda_ in process_lambda(conf[CONF_LAMBDA], [(DisplayBufferRef, 'it')], |             lambda_ = yield process_lambda(conf[CONF_LAMBDA], [(DisplayBufferRef, 'it')], | ||||||
|                                           return_type=void): |                                            return_type=void) | ||||||
|                 yield |  | ||||||
|             var = Pvariable(conf[CONF_ID], DisplayPage.new(lambda_)) |             var = Pvariable(conf[CONF_ID], DisplayPage.new(lambda_)) | ||||||
|             pages.append(var) |             pages.append(var) | ||||||
|         add(display_var.set_pages(pages)) |         add(display_var.set_pages(pages)) | ||||||
| @@ -82,12 +81,10 @@ def display_page_show_to_code(config, action_id, template_arg, args): | |||||||
|     type = DisplayPageShowAction.template(template_arg) |     type = DisplayPageShowAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, type.new(), type=type) |     action = Pvariable(action_id, type.new(), type=type) | ||||||
|     if isinstance(config[CONF_ID], core.Lambda): |     if isinstance(config[CONF_ID], core.Lambda): | ||||||
|         for template_ in templatable(config[CONF_ID], args, DisplayPagePtr): |         template_ = yield templatable(config[CONF_ID], args, DisplayPagePtr) | ||||||
|             yield None |  | ||||||
|         add(action.set_page(template_)) |         add(action.set_page(template_)) | ||||||
|     else: |     else: | ||||||
|         for var in get_variable(config[CONF_ID]): |         var = yield get_variable(config[CONF_ID]) | ||||||
|             yield None |  | ||||||
|         add(action.set_page(var)) |         add(action.set_page(var)) | ||||||
|     yield action |     yield action | ||||||
|  |  | ||||||
| @@ -100,8 +97,7 @@ DISPLAY_PAGE_SHOW_NEXT_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_DISPLAY_PAGE_SHOW_NEXT, DISPLAY_PAGE_SHOW_NEXT_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_DISPLAY_PAGE_SHOW_NEXT, DISPLAY_PAGE_SHOW_NEXT_ACTION_SCHEMA) | ||||||
| def display_page_show_next_to_code(config, action_id, template_arg, args): | def display_page_show_next_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = DisplayPageShowNextAction.template(template_arg) |     type = DisplayPageShowNextAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, type.new(var), type=type) |     yield Pvariable(action_id, type.new(var), type=type) | ||||||
|  |  | ||||||
| @@ -114,8 +110,7 @@ DISPLAY_PAGE_SHOW_PREVIOUS_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_DISPLAY_PAGE_SHOW_PREVIOUS, DISPLAY_PAGE_SHOW_PREVIOUS_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_DISPLAY_PAGE_SHOW_PREVIOUS, DISPLAY_PAGE_SHOW_PREVIOUS_ACTION_SCHEMA) | ||||||
| def display_page_show_previous_to_code(config, action_id, template_arg, args): | def display_page_show_previous_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = DisplayPageShowPrevAction.template(template_arg) |     type = DisplayPageShowPrevAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, type.new(var), type=type) |     yield Pvariable(action_id, type.new(var), type=type) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -46,27 +46,21 @@ def to_code(config): | |||||||
|     lcd = Pvariable(config[CONF_ID], rhs) |     lcd = Pvariable(config[CONF_ID], rhs) | ||||||
|     pins_ = [] |     pins_ = [] | ||||||
|     for conf in config[CONF_DATA_PINS]: |     for conf in config[CONF_DATA_PINS]: | ||||||
|         for pin in gpio_output_pin_expression(conf): |         pins_.append((yield gpio_output_pin_expression(conf))) | ||||||
|             yield |  | ||||||
|         pins_.append(pin) |  | ||||||
|     add(lcd.set_data_pins(*pins_)) |     add(lcd.set_data_pins(*pins_)) | ||||||
|     for enable in gpio_output_pin_expression(config[CONF_ENABLE_PIN]): |     enable = yield gpio_output_pin_expression(config[CONF_ENABLE_PIN]) | ||||||
|         yield |  | ||||||
|     add(lcd.set_enable_pin(enable)) |     add(lcd.set_enable_pin(enable)) | ||||||
|  |  | ||||||
|     for rs in gpio_output_pin_expression(config[CONF_RS_PIN]): |     rs = yield gpio_output_pin_expression(config[CONF_RS_PIN]) | ||||||
|         yield |  | ||||||
|     add(lcd.set_rs_pin(rs)) |     add(lcd.set_rs_pin(rs)) | ||||||
|  |  | ||||||
|     if CONF_RW_PIN in config: |     if CONF_RW_PIN in config: | ||||||
|         for rw in gpio_output_pin_expression(config[CONF_RW_PIN]): |         rw = yield gpio_output_pin_expression(config[CONF_RW_PIN]) | ||||||
|             yield |  | ||||||
|         add(lcd.set_rw_pin(rw)) |         add(lcd.set_rw_pin(rw)) | ||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], [(LCDDisplayRef, 'it')], |         lambda_ = yield process_lambda(config[CONF_LAMBDA], [(LCDDisplayRef, 'it')], | ||||||
|                                       return_type=void): |                                        return_type=void) | ||||||
|             yield |  | ||||||
|         add(lcd.set_writer(lambda_)) |         add(lcd.set_writer(lambda_)) | ||||||
|  |  | ||||||
|     display.setup_display(lcd, config) |     display.setup_display(lcd, config) | ||||||
|   | |||||||
| @@ -28,9 +28,8 @@ def to_code(config): | |||||||
|         add(lcd.set_address(config[CONF_ADDRESS])) |         add(lcd.set_address(config[CONF_ADDRESS])) | ||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], [(LCDDisplayRef, 'it')], |         lambda_ = yield process_lambda(config[CONF_LAMBDA], [(LCDDisplayRef, 'it')], | ||||||
|                                       return_type=void): |                                        return_type=void) | ||||||
|             yield |  | ||||||
|         add(lcd.set_writer(lambda_)) |         add(lcd.set_writer(lambda_)) | ||||||
|  |  | ||||||
|     display.setup_display(lcd, config) |     display.setup_display(lcd, config) | ||||||
|   | |||||||
| @@ -26,10 +26,8 @@ PLATFORM_SCHEMA = display.BASIC_DISPLAY_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for spi_ in get_variable(config[CONF_SPI_ID]): |     spi_ = yield get_variable(config[CONF_SPI_ID]) | ||||||
|         yield |     cs = yield gpio_output_pin_expression(config[CONF_CS_PIN]) | ||||||
|     for cs in gpio_output_pin_expression(config[CONF_CS_PIN]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_max7219(spi_, cs) |     rhs = App.make_max7219(spi_, cs) | ||||||
|     max7219 = Pvariable(config[CONF_ID], rhs) |     max7219 = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
| @@ -39,9 +37,8 @@ def to_code(config): | |||||||
|         add(max7219.set_intensity(config[CONF_INTENSITY])) |         add(max7219.set_intensity(config[CONF_INTENSITY])) | ||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], [(MAX7219ComponentRef, 'it')], |         lambda_ = yield process_lambda(config[CONF_LAMBDA], [(MAX7219ComponentRef, 'it')], | ||||||
|                                       return_type=void): |                                        return_type=void) | ||||||
|             yield |  | ||||||
|         add(max7219.set_writer(lambda_)) |         add(max7219.set_writer(lambda_)) | ||||||
|  |  | ||||||
|     display.setup_display(max7219, config) |     display.setup_display(max7219, config) | ||||||
|   | |||||||
| @@ -18,15 +18,13 @@ PLATFORM_SCHEMA = display.BASIC_DISPLAY_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for uart_ in get_variable(config[CONF_UART_ID]): |     uart_ = yield get_variable(config[CONF_UART_ID]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_nextion(uart_) |     rhs = App.make_nextion(uart_) | ||||||
|     nextion = Pvariable(config[CONF_ID], rhs) |     nextion = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], [(NextionRef, 'it')], |         lambda_ = yield process_lambda(config[CONF_LAMBDA], [(NextionRef, 'it')], | ||||||
|                                       return_type=void): |                                        return_type=void) | ||||||
|             yield |  | ||||||
|         add(nextion.set_writer(lambda_)) |         add(nextion.set_writer(lambda_)) | ||||||
|  |  | ||||||
|     display.setup_display(nextion, config) |     display.setup_display(nextion, config) | ||||||
|   | |||||||
| @@ -28,17 +28,15 @@ def to_code(config): | |||||||
|     add(ssd.set_model(ssd1306_spi.MODELS[config[CONF_MODEL]])) |     add(ssd.set_model(ssd1306_spi.MODELS[config[CONF_MODEL]])) | ||||||
|  |  | ||||||
|     if CONF_RESET_PIN in config: |     if CONF_RESET_PIN in config: | ||||||
|         for reset in gpio_output_pin_expression(config[CONF_RESET_PIN]): |         reset = yield gpio_output_pin_expression(config[CONF_RESET_PIN]) | ||||||
|             yield |  | ||||||
|         add(ssd.set_reset_pin(reset)) |         add(ssd.set_reset_pin(reset)) | ||||||
|     if CONF_EXTERNAL_VCC in config: |     if CONF_EXTERNAL_VCC in config: | ||||||
|         add(ssd.set_external_vcc(config[CONF_EXTERNAL_VCC])) |         add(ssd.set_external_vcc(config[CONF_EXTERNAL_VCC])) | ||||||
|     if CONF_ADDRESS in config: |     if CONF_ADDRESS in config: | ||||||
|         add(ssd.set_address(config[CONF_ADDRESS])) |         add(ssd.set_address(config[CONF_ADDRESS])) | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], |         lambda_ = yield process_lambda(config[CONF_LAMBDA], | ||||||
|                                       [(display.DisplayBufferRef, 'it')], return_type=void): |                                        [(display.DisplayBufferRef, 'it')], return_type=void) | ||||||
|             yield |  | ||||||
|         add(ssd.set_writer(lambda_)) |         add(ssd.set_writer(lambda_)) | ||||||
|  |  | ||||||
|     display.setup_display(ssd, config) |     display.setup_display(ssd, config) | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ from esphome.components import display, spi | |||||||
| from esphome.components.spi import SPIComponent | from esphome.components.spi import SPIComponent | ||||||
| import esphome.config_validation as cv | import esphome.config_validation as cv | ||||||
| from esphome.const import CONF_CS_PIN, CONF_DC_PIN, CONF_EXTERNAL_VCC, CONF_ID, CONF_LAMBDA, \ | from esphome.const import CONF_CS_PIN, CONF_DC_PIN, CONF_EXTERNAL_VCC, CONF_ID, CONF_LAMBDA, \ | ||||||
|     CONF_MODEL, CONF_RESET_PIN, CONF_SPI_ID, CONF_PAGES |     CONF_MODEL, CONF_PAGES, CONF_RESET_PIN, CONF_SPI_ID | ||||||
| from esphome.cpp_generator import Pvariable, add, get_variable, process_lambda | from esphome.cpp_generator import Pvariable, add, get_variable, process_lambda | ||||||
| from esphome.cpp_helpers import gpio_output_pin_expression, setup_component | from esphome.cpp_helpers import gpio_output_pin_expression, setup_component | ||||||
| from esphome.cpp_types import App, PollingComponent, void | from esphome.cpp_types import App, PollingComponent, void | ||||||
| @@ -41,27 +41,22 @@ PLATFORM_SCHEMA = vol.All(display.FULL_DISPLAY_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for spi_ in get_variable(config[CONF_SPI_ID]): |     spi_ = yield get_variable(config[CONF_SPI_ID]) | ||||||
|         yield |     cs = yield gpio_output_pin_expression(config[CONF_CS_PIN]) | ||||||
|     for cs in gpio_output_pin_expression(config[CONF_CS_PIN]): |     dc = yield gpio_output_pin_expression(config[CONF_DC_PIN]) | ||||||
|         yield |  | ||||||
|     for dc in gpio_output_pin_expression(config[CONF_DC_PIN]): |  | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = App.make_spi_ssd1306(spi_, cs, dc) |     rhs = App.make_spi_ssd1306(spi_, cs, dc) | ||||||
|     ssd = Pvariable(config[CONF_ID], rhs) |     ssd = Pvariable(config[CONF_ID], rhs) | ||||||
|     add(ssd.set_model(MODELS[config[CONF_MODEL]])) |     add(ssd.set_model(MODELS[config[CONF_MODEL]])) | ||||||
|  |  | ||||||
|     if CONF_RESET_PIN in config: |     if CONF_RESET_PIN in config: | ||||||
|         for reset in gpio_output_pin_expression(config[CONF_RESET_PIN]): |         reset = yield gpio_output_pin_expression(config[CONF_RESET_PIN]) | ||||||
|             yield |  | ||||||
|         add(ssd.set_reset_pin(reset)) |         add(ssd.set_reset_pin(reset)) | ||||||
|     if CONF_EXTERNAL_VCC in config: |     if CONF_EXTERNAL_VCC in config: | ||||||
|         add(ssd.set_external_vcc(config[CONF_EXTERNAL_VCC])) |         add(ssd.set_external_vcc(config[CONF_EXTERNAL_VCC])) | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], |         lambda_ = yield process_lambda(config[CONF_LAMBDA], | ||||||
|                                       [(display.DisplayBufferRef, 'it')], return_type=void): |                                        [(display.DisplayBufferRef, 'it')], return_type=void) | ||||||
|             yield |  | ||||||
|         add(ssd.set_writer(lambda_)) |         add(ssd.set_writer(lambda_)) | ||||||
|  |  | ||||||
|     display.setup_display(ssd, config) |     display.setup_display(ssd, config) | ||||||
|   | |||||||
| @@ -53,12 +53,9 @@ PLATFORM_SCHEMA = vol.All(display.FULL_DISPLAY_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for spi_ in get_variable(config[CONF_SPI_ID]): |     spi_ = yield get_variable(config[CONF_SPI_ID]) | ||||||
|         yield |     cs = yield gpio_output_pin_expression(config[CONF_CS_PIN]) | ||||||
|     for cs in gpio_output_pin_expression(config[CONF_CS_PIN]): |     dc = yield gpio_output_pin_expression(config[CONF_DC_PIN]) | ||||||
|         yield |  | ||||||
|     for dc in gpio_output_pin_expression(config[CONF_DC_PIN]): |  | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     model_type, model = MODELS[config[CONF_MODEL]] |     model_type, model = MODELS[config[CONF_MODEL]] | ||||||
|     if model_type == 'a': |     if model_type == 'a': | ||||||
| @@ -71,17 +68,14 @@ def to_code(config): | |||||||
|         raise NotImplementedError() |         raise NotImplementedError() | ||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], [(display.DisplayBufferRef, 'it')], |         lambda_ = yield process_lambda(config[CONF_LAMBDA], [(display.DisplayBufferRef, 'it')], | ||||||
|                                       return_type=void): |                                        return_type=void) | ||||||
|             yield |  | ||||||
|         add(epaper.set_writer(lambda_)) |         add(epaper.set_writer(lambda_)) | ||||||
|     if CONF_RESET_PIN in config: |     if CONF_RESET_PIN in config: | ||||||
|         for reset in gpio_output_pin_expression(config[CONF_RESET_PIN]): |         reset = yield gpio_output_pin_expression(config[CONF_RESET_PIN]) | ||||||
|             yield |  | ||||||
|         add(epaper.set_reset_pin(reset)) |         add(epaper.set_reset_pin(reset)) | ||||||
|     if CONF_BUSY_PIN in config: |     if CONF_BUSY_PIN in config: | ||||||
|         for reset in gpio_input_pin_expression(config[CONF_BUSY_PIN]): |         reset = yield gpio_input_pin_expression(config[CONF_BUSY_PIN]) | ||||||
|             yield |  | ||||||
|         add(epaper.set_busy_pin(reset)) |         add(epaper.set_busy_pin(reset)) | ||||||
|     if CONF_FULL_UPDATE_EVERY in config: |     if CONF_FULL_UPDATE_EVERY in config: | ||||||
|         add(epaper.set_full_update_every(config[CONF_FULL_UPDATE_EVERY])) |         add(epaper.set_full_update_every(config[CONF_FULL_UPDATE_EVERY])) | ||||||
|   | |||||||
| @@ -74,8 +74,7 @@ def to_code(config): | |||||||
|     add(eth.set_use_address(config[CONF_USE_ADDRESS])) |     add(eth.set_use_address(config[CONF_USE_ADDRESS])) | ||||||
|  |  | ||||||
|     if CONF_POWER_PIN in config: |     if CONF_POWER_PIN in config: | ||||||
|         for pin in gpio_output_pin_expression(config[CONF_POWER_PIN]): |         pin = yield gpio_output_pin_expression(config[CONF_POWER_PIN]) | ||||||
|             yield |  | ||||||
|         add(eth.set_power_pin(pin)) |         add(eth.set_power_pin(pin)) | ||||||
|  |  | ||||||
|     if CONF_MANUAL_IP in config: |     if CONF_MANUAL_IP in config: | ||||||
|   | |||||||
| @@ -10,7 +10,6 @@ from esphome.const import CONF_ID, CONF_INTERNAL, CONF_MQTT_ID, CONF_OSCILLATING | |||||||
| from esphome.core import CORE | from esphome.core import CORE | ||||||
| from esphome.cpp_generator import Pvariable, add, get_variable, templatable | from esphome.cpp_generator import Pvariable, add, get_variable, templatable | ||||||
| from esphome.cpp_types import Action, Application, Component, Nameable, bool_, esphome_ns | from esphome.cpp_types import Action, Application, Component, Nameable, bool_, esphome_ns | ||||||
| from esphome.py_compat import string_types |  | ||||||
|  |  | ||||||
| PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({ | PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({ | ||||||
|  |  | ||||||
| @@ -82,8 +81,7 @@ FAN_TOGGLE_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_FAN_TOGGLE, FAN_TOGGLE_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_FAN_TOGGLE, FAN_TOGGLE_ACTION_SCHEMA) | ||||||
| def fan_toggle_to_code(config, action_id, template_arg, args): | def fan_toggle_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_toggle_action(template_arg) |     rhs = var.make_toggle_action(template_arg) | ||||||
|     type = ToggleAction.template(template_arg) |     type = ToggleAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -97,8 +95,7 @@ FAN_TURN_OFF_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_FAN_TURN_OFF, FAN_TURN_OFF_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_FAN_TURN_OFF, FAN_TURN_OFF_ACTION_SCHEMA) | ||||||
| def fan_turn_off_to_code(config, action_id, template_arg, args): | def fan_turn_off_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_turn_off_action(template_arg) |     rhs = var.make_turn_off_action(template_arg) | ||||||
|     type = TurnOffAction.template(template_arg) |     type = TurnOffAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -114,19 +111,15 @@ FAN_TURN_ON_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_FAN_TURN_ON, FAN_TURN_ON_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_FAN_TURN_ON, FAN_TURN_ON_ACTION_SCHEMA) | ||||||
| def fan_turn_on_to_code(config, action_id, template_arg, args): | def fan_turn_on_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_turn_on_action(template_arg) |     rhs = var.make_turn_on_action(template_arg) | ||||||
|     type = TurnOnAction.template(template_arg) |     type = TurnOnAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     if CONF_OSCILLATING in config: |     if CONF_OSCILLATING in config: | ||||||
|         for template_ in templatable(config[CONF_OSCILLATING], args, bool_): |         template_ = yield templatable(config[CONF_OSCILLATING], args, bool_) | ||||||
|             yield None |  | ||||||
|         add(action.set_oscillating(template_)) |         add(action.set_oscillating(template_)) | ||||||
|     if CONF_SPEED in config: |     if CONF_SPEED in config: | ||||||
|         for template_ in templatable(config[CONF_SPEED], args, FanSpeed): |         template_ = yield templatable(config[CONF_SPEED], args, FanSpeed, | ||||||
|             yield None |                                       to_exp=FAN_SPEEDS) | ||||||
|         if isinstance(template_, string_types): |  | ||||||
|             template_ = FAN_SPEEDS[template_] |  | ||||||
|         add(action.set_speed(template_)) |         add(action.set_speed(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -15,15 +15,13 @@ PLATFORM_SCHEMA = cv.nameable(fan.FAN_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for output_ in get_variable(config[CONF_OUTPUT]): |     output_ = yield get_variable(config[CONF_OUTPUT]) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = App.make_fan(config[CONF_NAME]) |     rhs = App.make_fan(config[CONF_NAME]) | ||||||
|     fan_struct = variable(config[CONF_MAKE_ID], rhs) |     fan_struct = variable(config[CONF_MAKE_ID], rhs) | ||||||
|     add(fan_struct.Poutput.set_binary(output_)) |     add(fan_struct.Poutput.set_binary(output_)) | ||||||
|     if CONF_OSCILLATION_OUTPUT in config: |     if CONF_OSCILLATION_OUTPUT in config: | ||||||
|         for oscillation_output in get_variable(config[CONF_OSCILLATION_OUTPUT]): |         oscillation_output = yield get_variable(config[CONF_OSCILLATION_OUTPUT]) | ||||||
|             yield |  | ||||||
|         add(fan_struct.Poutput.set_oscillation(oscillation_output)) |         add(fan_struct.Poutput.set_oscillation(oscillation_output)) | ||||||
|  |  | ||||||
|     fan.setup_fan(fan_struct.Pstate, config) |     fan.setup_fan(fan_struct.Pstate, config) | ||||||
|   | |||||||
| @@ -23,8 +23,7 @@ PLATFORM_SCHEMA = cv.nameable(fan.FAN_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for output_ in get_variable(config[CONF_OUTPUT]): |     output_ = yield get_variable(config[CONF_OUTPUT]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_fan(config[CONF_NAME]) |     rhs = App.make_fan(config[CONF_NAME]) | ||||||
|     fan_struct = variable(config[CONF_MAKE_ID], rhs) |     fan_struct = variable(config[CONF_MAKE_ID], rhs) | ||||||
|     if CONF_SPEED in config: |     if CONF_SPEED in config: | ||||||
| @@ -37,8 +36,7 @@ def to_code(config): | |||||||
|         add(fan_struct.Poutput.set_speed(output_)) |         add(fan_struct.Poutput.set_speed(output_)) | ||||||
|  |  | ||||||
|     if CONF_OSCILLATION_OUTPUT in config: |     if CONF_OSCILLATION_OUTPUT in config: | ||||||
|         for oscillation_output in get_variable(config[CONF_OSCILLATION_OUTPUT]): |         oscillation_output = yield get_variable(config[CONF_OSCILLATION_OUTPUT]) | ||||||
|             yield |  | ||||||
|         add(fan_struct.Poutput.set_oscillation(oscillation_output)) |         add(fan_struct.Poutput.set_oscillation(oscillation_output)) | ||||||
|  |  | ||||||
|     fan.setup_fan(fan_struct.Pstate, config) |     fan.setup_fan(fan_struct.Pstate, config) | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ from esphome.const import CONF_ALPHA, CONF_BLUE, CONF_BRIGHTNESS, CONF_COLORS, C | |||||||
|     CONF_EFFECTS, CONF_EFFECT_ID, CONF_FLASH_LENGTH, CONF_GAMMA_CORRECT, CONF_GREEN, CONF_ID, \ |     CONF_EFFECTS, CONF_EFFECT_ID, CONF_FLASH_LENGTH, CONF_GAMMA_CORRECT, CONF_GREEN, CONF_ID, \ | ||||||
|     CONF_INTERNAL, CONF_LAMBDA, CONF_MQTT_ID, CONF_NAME, CONF_NUM_LEDS, CONF_RANDOM, CONF_RED, \ |     CONF_INTERNAL, CONF_LAMBDA, CONF_MQTT_ID, CONF_NAME, CONF_NUM_LEDS, CONF_RANDOM, CONF_RED, \ | ||||||
|     CONF_SPEED, CONF_STATE, CONF_TRANSITION_LENGTH, CONF_UPDATE_INTERVAL, CONF_WHITE, CONF_WIDTH |     CONF_SPEED, CONF_STATE, CONF_TRANSITION_LENGTH, CONF_UPDATE_INTERVAL, CONF_WHITE, CONF_WIDTH | ||||||
| from esphome.core import CORE | from esphome.core import CORE, coroutine | ||||||
| from esphome.cpp_generator import Pvariable, StructInitializer, add, get_variable, process_lambda, \ | from esphome.cpp_generator import Pvariable, StructInitializer, add, get_variable, process_lambda, \ | ||||||
|     templatable |     templatable | ||||||
| from esphome.cpp_types import Action, Application, Component, Nameable, esphome_ns, std_string, \ | from esphome.cpp_types import Action, Application, Component, Nameable, esphome_ns, std_string, \ | ||||||
| @@ -269,12 +269,11 @@ ADDRESSABLE_LIGHT_SCHEMA = RGB_LIGHT_SCHEMA.extend({ | |||||||
| }) | }) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def build_effect(full_config): | def build_effect(full_config): | ||||||
|     key, config = next(iter(full_config.items())) |     key, config = next(iter(full_config.items())) | ||||||
|     if key == CONF_LAMBDA: |     if key == CONF_LAMBDA: | ||||||
|         lambda_ = None |         lambda_ = yield process_lambda(config[CONF_LAMBDA], [], return_type=void) | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], [], return_type=void): |  | ||||||
|             yield None |  | ||||||
|         yield LambdaLightEffect.new(config[CONF_NAME], lambda_, config[CONF_UPDATE_INTERVAL]) |         yield LambdaLightEffect.new(config[CONF_NAME], lambda_, config[CONF_UPDATE_INTERVAL]) | ||||||
|     elif key == CONF_RANDOM: |     elif key == CONF_RANDOM: | ||||||
|         rhs = RandomLightEffect.new(config[CONF_NAME]) |         rhs = RandomLightEffect.new(config[CONF_NAME]) | ||||||
| @@ -309,8 +308,7 @@ def build_effect(full_config): | |||||||
|         yield effect |         yield effect | ||||||
|     elif key == CONF_ADDRESSABLE_LAMBDA: |     elif key == CONF_ADDRESSABLE_LAMBDA: | ||||||
|         args = [(AddressableLightRef, 'it')] |         args = [(AddressableLightRef, 'it')] | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], args, return_type=void): |         lambda_ = yield process_lambda(config[CONF_LAMBDA], args, return_type=void) | ||||||
|             yield None |  | ||||||
|         yield AddressableLambdaLightEffect.new(config[CONF_NAME], lambda_, |         yield AddressableLambdaLightEffect.new(config[CONF_NAME], lambda_, | ||||||
|                                                config[CONF_UPDATE_INTERVAL]) |                                                config[CONF_UPDATE_INTERVAL]) | ||||||
|     elif key == CONF_ADDRESSABLE_RAINBOW: |     elif key == CONF_ADDRESSABLE_RAINBOW: | ||||||
| @@ -388,6 +386,7 @@ def build_effect(full_config): | |||||||
|         raise NotImplementedError("Effect {} not implemented".format(next(config.keys()))) |         raise NotImplementedError("Effect {} not implemented".format(next(config.keys()))) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def setup_light_core_(light_var, output_var, config): | def setup_light_core_(light_var, output_var, config): | ||||||
|     if CONF_INTERNAL in config: |     if CONF_INTERNAL in config: | ||||||
|         add(light_var.set_internal(config[CONF_INTERNAL])) |         add(light_var.set_internal(config[CONF_INTERNAL])) | ||||||
| @@ -397,8 +396,7 @@ def setup_light_core_(light_var, output_var, config): | |||||||
|         add(light_var.set_gamma_correct(config[CONF_GAMMA_CORRECT])) |         add(light_var.set_gamma_correct(config[CONF_GAMMA_CORRECT])) | ||||||
|     effects = [] |     effects = [] | ||||||
|     for conf in config.get(CONF_EFFECTS, []): |     for conf in config.get(CONF_EFFECTS, []): | ||||||
|         for effect in build_effect(conf): |         effect = yield build_effect(conf) | ||||||
|             yield |  | ||||||
|         effects.append(effect) |         effects.append(effect) | ||||||
|     if effects: |     if effects: | ||||||
|         add(light_var.add_effects(effects)) |         add(light_var.add_effects(effects)) | ||||||
| @@ -425,14 +423,12 @@ LIGHT_TOGGLE_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_LIGHT_TOGGLE, LIGHT_TOGGLE_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_LIGHT_TOGGLE, LIGHT_TOGGLE_ACTION_SCHEMA) | ||||||
| def light_toggle_to_code(config, action_id, template_arg, args): | def light_toggle_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = ToggleAction.template(template_arg) |     type = ToggleAction.template(template_arg) | ||||||
|     rhs = type.new(var) |     rhs = type.new(var) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     if CONF_TRANSITION_LENGTH in config: |     if CONF_TRANSITION_LENGTH in config: | ||||||
|         for template_ in templatable(config[CONF_TRANSITION_LENGTH], args, uint32): |         template_ = yield templatable(config[CONF_TRANSITION_LENGTH], args, uint32) | ||||||
|             yield None |  | ||||||
|         add(action.set_transition_length(template_)) |         add(action.set_transition_length(template_)) | ||||||
|     yield action |     yield action | ||||||
|  |  | ||||||
| @@ -446,14 +442,12 @@ LIGHT_TURN_OFF_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_LIGHT_TURN_OFF, LIGHT_TURN_OFF_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_LIGHT_TURN_OFF, LIGHT_TURN_OFF_ACTION_SCHEMA) | ||||||
| def light_turn_off_to_code(config, action_id, template_arg, args): | def light_turn_off_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = LightControlAction.template(template_arg) |     type = LightControlAction.template(template_arg) | ||||||
|     rhs = type.new(var) |     rhs = type.new(var) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     if CONF_TRANSITION_LENGTH in config: |     if CONF_TRANSITION_LENGTH in config: | ||||||
|         for template_ in templatable(config[CONF_TRANSITION_LENGTH], args, uint32): |         template_ = yield templatable(config[CONF_TRANSITION_LENGTH], args, uint32) | ||||||
|             yield None |  | ||||||
|         add(action.set_transition_length(template_)) |         add(action.set_transition_length(template_)) | ||||||
|     yield action |     yield action | ||||||
|  |  | ||||||
| @@ -490,49 +484,38 @@ LIGHT_TURN_ON_ACTION_SCHEMA = maybe_simple_id(LIGHT_CONTROL_ACTION_SCHEMA.extend | |||||||
| @ACTION_REGISTRY.register(CONF_LIGHT_TURN_ON, LIGHT_TURN_ON_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_LIGHT_TURN_ON, LIGHT_TURN_ON_ACTION_SCHEMA) | ||||||
| @ACTION_REGISTRY.register(CONF_LIGHT_CONTROL, LIGHT_CONTROL_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_LIGHT_CONTROL, LIGHT_CONTROL_ACTION_SCHEMA) | ||||||
| def light_control_to_code(config, action_id, template_arg, args): | def light_control_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     type = LightControlAction.template(template_arg) |     type = LightControlAction.template(template_arg) | ||||||
|     rhs = type.new(var) |     rhs = type.new(var) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     if CONF_STATE in config: |     if CONF_STATE in config: | ||||||
|         for template_ in templatable(config[CONF_STATE], args, bool): |         template_ = yield templatable(config[CONF_STATE], args, bool) | ||||||
|             yield None |  | ||||||
|         add(action.set_state(template_)) |         add(action.set_state(template_)) | ||||||
|     if CONF_TRANSITION_LENGTH in config: |     if CONF_TRANSITION_LENGTH in config: | ||||||
|         for template_ in templatable(config[CONF_TRANSITION_LENGTH], args, uint32): |         template_ = yield templatable(config[CONF_TRANSITION_LENGTH], args, uint32) | ||||||
|             yield None |  | ||||||
|         add(action.set_transition_length(template_)) |         add(action.set_transition_length(template_)) | ||||||
|     if CONF_FLASH_LENGTH in config: |     if CONF_FLASH_LENGTH in config: | ||||||
|         for template_ in templatable(config[CONF_FLASH_LENGTH], args, uint32): |         template_ = yield templatable(config[CONF_FLASH_LENGTH], args, uint32) | ||||||
|             yield None |  | ||||||
|         add(action.set_flash_length(template_)) |         add(action.set_flash_length(template_)) | ||||||
|     if CONF_BRIGHTNESS in config: |     if CONF_BRIGHTNESS in config: | ||||||
|         for template_ in templatable(config[CONF_BRIGHTNESS], args, float): |         template_ = yield templatable(config[CONF_BRIGHTNESS], args, float) | ||||||
|             yield None |  | ||||||
|         add(action.set_brightness(template_)) |         add(action.set_brightness(template_)) | ||||||
|     if CONF_RED in config: |     if CONF_RED in config: | ||||||
|         for template_ in templatable(config[CONF_RED], args, float): |         template_ = yield templatable(config[CONF_RED], args, float) | ||||||
|             yield None |  | ||||||
|         add(action.set_red(template_)) |         add(action.set_red(template_)) | ||||||
|     if CONF_GREEN in config: |     if CONF_GREEN in config: | ||||||
|         for template_ in templatable(config[CONF_GREEN], args, float): |         template_ = yield templatable(config[CONF_GREEN], args, float) | ||||||
|             yield None |  | ||||||
|         add(action.set_green(template_)) |         add(action.set_green(template_)) | ||||||
|     if CONF_BLUE in config: |     if CONF_BLUE in config: | ||||||
|         for template_ in templatable(config[CONF_BLUE], args, float): |         template_ = yield templatable(config[CONF_BLUE], args, float) | ||||||
|             yield None |  | ||||||
|         add(action.set_blue(template_)) |         add(action.set_blue(template_)) | ||||||
|     if CONF_WHITE in config: |     if CONF_WHITE in config: | ||||||
|         for template_ in templatable(config[CONF_WHITE], args, float): |         template_ = yield templatable(config[CONF_WHITE], args, float) | ||||||
|             yield None |  | ||||||
|         add(action.set_white(template_)) |         add(action.set_white(template_)) | ||||||
|     if CONF_COLOR_TEMPERATURE in config: |     if CONF_COLOR_TEMPERATURE in config: | ||||||
|         for template_ in templatable(config[CONF_COLOR_TEMPERATURE], args, float): |         template_ = yield templatable(config[CONF_COLOR_TEMPERATURE], args, float) | ||||||
|             yield None |  | ||||||
|         add(action.set_color_temperature(template_)) |         add(action.set_color_temperature(template_)) | ||||||
|     if CONF_EFFECT in config: |     if CONF_EFFECT in config: | ||||||
|         for template_ in templatable(config[CONF_EFFECT], args, std_string): |         template_ = yield templatable(config[CONF_EFFECT], args, std_string) | ||||||
|             yield None |  | ||||||
|         add(action.set_effect(template_)) |         add(action.set_effect(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -14,8 +14,7 @@ PLATFORM_SCHEMA = cv.nameable(light.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for output_ in get_variable(config[CONF_OUTPUT]): |     output_ = yield get_variable(config[CONF_OUTPUT]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_binary_light(config[CONF_NAME], output_) |     rhs = App.make_binary_light(config[CONF_NAME], output_) | ||||||
|     light_struct = variable(config[CONF_MAKE_ID], rhs) |     light_struct = variable(config[CONF_MAKE_ID], rhs) | ||||||
|     light.setup_light(light_struct.Pstate, light_struct.Poutput, config) |     light.setup_light(light_struct.Pstate, light_struct.Poutput, config) | ||||||
|   | |||||||
| @@ -20,10 +20,8 @@ PLATFORM_SCHEMA = cv.nameable(light.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for cold_white in get_variable(config[CONF_COLD_WHITE]): |     cold_white = yield get_variable(config[CONF_COLD_WHITE]) | ||||||
|         yield |     warm_white = yield get_variable(config[CONF_WARM_WHITE]) | ||||||
|     for warm_white in get_variable(config[CONF_WARM_WHITE]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_cwww_light(config[CONF_NAME], config[CONF_COLD_WHITE_COLOR_TEMPERATURE], |     rhs = App.make_cwww_light(config[CONF_NAME], config[CONF_COLD_WHITE_COLOR_TEMPERATURE], | ||||||
|                               config[CONF_WARM_WHITE_COLOR_TEMPERATURE], |                               config[CONF_WARM_WHITE_COLOR_TEMPERATURE], | ||||||
|                               cold_white, warm_white) |                               cold_white, warm_white) | ||||||
|   | |||||||
| @@ -85,8 +85,7 @@ def to_code(config): | |||||||
|         add(fast_led.set_max_refresh_rate(config[CONF_MAX_REFRESH_RATE])) |         add(fast_led.set_max_refresh_rate(config[CONF_MAX_REFRESH_RATE])) | ||||||
|  |  | ||||||
|     if CONF_POWER_SUPPLY in config: |     if CONF_POWER_SUPPLY in config: | ||||||
|         for power_supply in get_variable(config[CONF_POWER_SUPPLY]): |         power_supply = yield get_variable(config[CONF_POWER_SUPPLY]) | ||||||
|             yield |  | ||||||
|         add(fast_led.set_power_supply(power_supply)) |         add(fast_led.set_power_supply(power_supply)) | ||||||
|  |  | ||||||
|     light.setup_light(make.Pstate, make.Pfast_led, config) |     light.setup_light(make.Pstate, make.Pfast_led, config) | ||||||
|   | |||||||
| @@ -68,8 +68,7 @@ def to_code(config): | |||||||
|         add(fast_led.set_max_refresh_rate(config[CONF_MAX_REFRESH_RATE])) |         add(fast_led.set_max_refresh_rate(config[CONF_MAX_REFRESH_RATE])) | ||||||
|  |  | ||||||
|     if CONF_POWER_SUPPLY in config: |     if CONF_POWER_SUPPLY in config: | ||||||
|         for power_supply in get_variable(config[CONF_POWER_SUPPLY]): |         power_supply = yield get_variable(config[CONF_POWER_SUPPLY]) | ||||||
|             yield |  | ||||||
|         add(fast_led.set_power_supply(power_supply)) |         add(fast_led.set_power_supply(power_supply)) | ||||||
|  |  | ||||||
|     light.setup_light(make.Pstate, make.Pfast_led, config) |     light.setup_light(make.Pstate, make.Pfast_led, config) | ||||||
|   | |||||||
| @@ -14,8 +14,7 @@ PLATFORM_SCHEMA = cv.nameable(light.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for output_ in get_variable(config[CONF_OUTPUT]): |     output_ = yield get_variable(config[CONF_OUTPUT]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_monochromatic_light(config[CONF_NAME], output_) |     rhs = App.make_monochromatic_light(config[CONF_NAME], output_) | ||||||
|     light_struct = variable(config[CONF_MAKE_ID], rhs) |     light_struct = variable(config[CONF_MAKE_ID], rhs) | ||||||
|     light.setup_light(light_struct.Pstate, light_struct.Poutput, config) |     light.setup_light(light_struct.Pstate, light_struct.Poutput, config) | ||||||
|   | |||||||
| @@ -169,8 +169,7 @@ def to_code(config): | |||||||
|     add(output.set_pixel_order(getattr(ESPNeoPixelOrder, type_))) |     add(output.set_pixel_order(getattr(ESPNeoPixelOrder, type_))) | ||||||
|  |  | ||||||
|     if CONF_POWER_SUPPLY in config: |     if CONF_POWER_SUPPLY in config: | ||||||
|         for power_supply in get_variable(config[CONF_POWER_SUPPLY]): |         power_supply = yield get_variable(config[CONF_POWER_SUPPLY]) | ||||||
|             yield |  | ||||||
|         add(output.set_power_supply(power_supply)) |         add(output.set_power_supply(power_supply)) | ||||||
|  |  | ||||||
|     light.setup_light(make.Pstate, output, config) |     light.setup_light(make.Pstate, output, config) | ||||||
|   | |||||||
| @@ -34,8 +34,7 @@ PLATFORM_SCHEMA = cv.nameable(light.PLATFORM_SCHEMA.extend({ | |||||||
| def to_code(config): | def to_code(config): | ||||||
|     segments = [] |     segments = [] | ||||||
|     for conf in config[CONF_SEGMENTS]: |     for conf in config[CONF_SEGMENTS]: | ||||||
|         for var in get_variable(conf[CONF_ID]): |         var = yield get_variable(conf[CONF_ID]) | ||||||
|             yield |  | ||||||
|         segments.append(AddressableSegment(var, conf[CONF_FROM], |         segments.append(AddressableSegment(var, conf[CONF_FROM], | ||||||
|                                            conf[CONF_TO] - conf[CONF_FROM] + 1)) |                                            conf[CONF_TO] - conf[CONF_FROM] + 1)) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,12 +16,9 @@ PLATFORM_SCHEMA = cv.nameable(light.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for red in get_variable(config[CONF_RED]): |     red = yield get_variable(config[CONF_RED]) | ||||||
|         yield |     green = yield get_variable(config[CONF_GREEN]) | ||||||
|     for green in get_variable(config[CONF_GREEN]): |     blue = yield get_variable(config[CONF_BLUE]) | ||||||
|         yield |  | ||||||
|     for blue in get_variable(config[CONF_BLUE]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_rgb_light(config[CONF_NAME], red, green, blue) |     rhs = App.make_rgb_light(config[CONF_NAME], red, green, blue) | ||||||
|     light_struct = variable(config[CONF_MAKE_ID], rhs) |     light_struct = variable(config[CONF_MAKE_ID], rhs) | ||||||
|     light.setup_light(light_struct.Pstate, light_struct.Poutput, config) |     light.setup_light(light_struct.Pstate, light_struct.Poutput, config) | ||||||
|   | |||||||
| @@ -17,14 +17,10 @@ PLATFORM_SCHEMA = cv.nameable(light.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for red in get_variable(config[CONF_RED]): |     red = yield get_variable(config[CONF_RED]) | ||||||
|         yield |     green = yield get_variable(config[CONF_GREEN]) | ||||||
|     for green in get_variable(config[CONF_GREEN]): |     blue = yield get_variable(config[CONF_BLUE]) | ||||||
|         yield |     white = yield get_variable(config[CONF_WHITE]) | ||||||
|     for blue in get_variable(config[CONF_BLUE]): |  | ||||||
|         yield |  | ||||||
|     for white in get_variable(config[CONF_WHITE]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_rgbw_light(config[CONF_NAME], red, green, blue, white) |     rhs = App.make_rgbw_light(config[CONF_NAME], red, green, blue, white) | ||||||
|     light_struct = variable(config[CONF_MAKE_ID], rhs) |     light_struct = variable(config[CONF_MAKE_ID], rhs) | ||||||
|     light.setup_light(light_struct.Pstate, light_struct.Poutput, config) |     light.setup_light(light_struct.Pstate, light_struct.Poutput, config) | ||||||
|   | |||||||
| @@ -34,16 +34,11 @@ PLATFORM_SCHEMA = cv.nameable(light.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for red in get_variable(config[CONF_RED]): |     red = yield get_variable(config[CONF_RED]) | ||||||
|         yield |     green = yield get_variable(config[CONF_GREEN]) | ||||||
|     for green in get_variable(config[CONF_GREEN]): |     blue = yield get_variable(config[CONF_BLUE]) | ||||||
|         yield |     cold_white = yield get_variable(config[CONF_COLD_WHITE]) | ||||||
|     for blue in get_variable(config[CONF_BLUE]): |     warm_white = yield get_variable(config[CONF_WARM_WHITE]) | ||||||
|         yield |  | ||||||
|     for cold_white in get_variable(config[CONF_COLD_WHITE]): |  | ||||||
|         yield |  | ||||||
|     for warm_white in get_variable(config[CONF_WARM_WHITE]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_rgbww_light(config[CONF_NAME], config[CONF_COLD_WHITE_COLOR_TEMPERATURE], |     rhs = App.make_rgbww_light(config[CONF_NAME], config[CONF_COLD_WHITE_COLOR_TEMPERATURE], | ||||||
|                                config[CONF_WARM_WHITE_COLOR_TEMPERATURE], |                                config[CONF_WARM_WHITE_COLOR_TEMPERATURE], | ||||||
|                                red, green, blue, cold_white, warm_white) |                                red, green, blue, cold_white, warm_white) | ||||||
|   | |||||||
| @@ -177,8 +177,7 @@ def logger_log_action_to_code(config, action_id, template_arg, args): | |||||||
|  |  | ||||||
|     text = text_type(statement(esp_log(config[CONF_TAG], config[CONF_FORMAT], *args_))) |     text = text_type(statement(esp_log(config[CONF_TAG], config[CONF_FORMAT], *args_))) | ||||||
|  |  | ||||||
|     for lambda_ in process_lambda(Lambda(text), args, return_type=void): |     lambda_ = yield process_lambda(Lambda(text), args, return_type=void) | ||||||
|         yield None |  | ||||||
|     rhs = LambdaAction.new(template_arg, lambda_) |     rhs = LambdaAction.new(template_arg, lambda_) | ||||||
|     type = LambdaAction.template(template_arg) |     type = LambdaAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
|   | |||||||
| @@ -203,25 +203,20 @@ MQTT_PUBLISH_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_MQTT_PUBLISH, MQTT_PUBLISH_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_MQTT_PUBLISH, MQTT_PUBLISH_ACTION_SCHEMA) | ||||||
| def mqtt_publish_action_to_code(config, action_id, template_arg, args): | def mqtt_publish_action_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_publish_action(template_arg) |     rhs = var.make_publish_action(template_arg) | ||||||
|     type = MQTTPublishAction.template(template_arg) |     type = MQTTPublishAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config[CONF_TOPIC], args, std_string): |     template_ = yield templatable(config[CONF_TOPIC], args, std_string) | ||||||
|         yield None |  | ||||||
|     add(action.set_topic(template_)) |     add(action.set_topic(template_)) | ||||||
|  |  | ||||||
|     for template_ in templatable(config[CONF_PAYLOAD], args, std_string): |     template_ = yield templatable(config[CONF_PAYLOAD], args, std_string) | ||||||
|         yield None |  | ||||||
|     add(action.set_payload(template_)) |     add(action.set_payload(template_)) | ||||||
|     if CONF_QOS in config: |     if CONF_QOS in config: | ||||||
|         for template_ in templatable(config[CONF_QOS], args, uint8): |         template_ = yield templatable(config[CONF_QOS], args, uint8) | ||||||
|             yield |  | ||||||
|         add(action.set_qos(template_)) |         add(action.set_qos(template_)) | ||||||
|     if CONF_RETAIN in config: |     if CONF_RETAIN in config: | ||||||
|         for template_ in templatable(config[CONF_RETAIN], args, bool_): |         template_ = yield templatable(config[CONF_RETAIN], args, bool_) | ||||||
|             yield None |  | ||||||
|         add(action.set_retain(template_)) |         add(action.set_retain(template_)) | ||||||
|     yield action |     yield action | ||||||
|  |  | ||||||
| @@ -238,18 +233,15 @@ MQTT_PUBLISH_JSON_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_MQTT_PUBLISH_JSON, MQTT_PUBLISH_JSON_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_MQTT_PUBLISH_JSON, MQTT_PUBLISH_JSON_ACTION_SCHEMA) | ||||||
| def mqtt_publish_json_action_to_code(config, action_id, template_arg, args): | def mqtt_publish_json_action_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_publish_json_action(template_arg) |     rhs = var.make_publish_json_action(template_arg) | ||||||
|     type = MQTTPublishJsonAction.template(template_arg) |     type = MQTTPublishJsonAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config[CONF_TOPIC], args, std_string): |     template_ = yield templatable(config[CONF_TOPIC], args, std_string) | ||||||
|         yield None |  | ||||||
|     add(action.set_topic(template_)) |     add(action.set_topic(template_)) | ||||||
|  |  | ||||||
|     args_ = args + [(JsonObjectRef, 'root')] |     args_ = args + [(JsonObjectRef, 'root')] | ||||||
|     for lambda_ in process_lambda(config[CONF_PAYLOAD], args_, return_type=void): |     lambda_ = yield process_lambda(config[CONF_PAYLOAD], args_, return_type=void) | ||||||
|         yield None |  | ||||||
|     add(action.set_payload(lambda_)) |     add(action.set_payload(lambda_)) | ||||||
|     if CONF_QOS in config: |     if CONF_QOS in config: | ||||||
|         add(action.set_qos(config[CONF_QOS])) |         add(action.set_qos(config[CONF_QOS])) | ||||||
|   | |||||||
| @@ -26,10 +26,8 @@ CONFIG_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for di in gpio_output_pin_expression(config[CONF_DATA_PIN]): |     di = yield gpio_output_pin_expression(config[CONF_DATA_PIN]) | ||||||
|         yield |     dcki = yield gpio_output_pin_expression(config[CONF_CLOCK_PIN]) | ||||||
|     for dcki in gpio_output_pin_expression(config[CONF_CLOCK_PIN]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_my9231_component(di, dcki) |     rhs = App.make_my9231_component(di, dcki) | ||||||
|     my9231 = Pvariable(config[CONF_ID], rhs) |     my9231 = Pvariable(config[CONF_ID], rhs) | ||||||
|     if CONF_NUM_CHANNELS in config: |     if CONF_NUM_CHANNELS in config: | ||||||
|   | |||||||
| @@ -43,9 +43,7 @@ def setup_output_platform_(obj, config, skip_power_supply=False): | |||||||
|     if CONF_INVERTED in config: |     if CONF_INVERTED in config: | ||||||
|         add(obj.set_inverted(config[CONF_INVERTED])) |         add(obj.set_inverted(config[CONF_INVERTED])) | ||||||
|     if not skip_power_supply and CONF_POWER_SUPPLY in config: |     if not skip_power_supply and CONF_POWER_SUPPLY in config: | ||||||
|         power_supply = None |         power_supply = yield get_variable(config[CONF_POWER_SUPPLY]) | ||||||
|         for power_supply in get_variable(config[CONF_POWER_SUPPLY]): |  | ||||||
|             yield |  | ||||||
|         add(obj.set_power_supply(power_supply)) |         add(obj.set_power_supply(power_supply)) | ||||||
|     if CONF_MAX_POWER in config: |     if CONF_MAX_POWER in config: | ||||||
|         add(obj.set_max_power(config[CONF_MAX_POWER])) |         add(obj.set_max_power(config[CONF_MAX_POWER])) | ||||||
| @@ -72,8 +70,7 @@ OUTPUT_TURN_ON_ACTION = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_OUTPUT_TURN_ON, OUTPUT_TURN_ON_ACTION) | @ACTION_REGISTRY.register(CONF_OUTPUT_TURN_ON, OUTPUT_TURN_ON_ACTION) | ||||||
| def output_turn_on_to_code(config, action_id, template_arg, args): | def output_turn_on_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_turn_on_action(template_arg) |     rhs = var.make_turn_on_action(template_arg) | ||||||
|     type = TurnOnAction.template(template_arg) |     type = TurnOnAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -87,8 +84,7 @@ OUTPUT_TURN_OFF_ACTION = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_OUTPUT_TURN_OFF, OUTPUT_TURN_OFF_ACTION) | @ACTION_REGISTRY.register(CONF_OUTPUT_TURN_OFF, OUTPUT_TURN_OFF_ACTION) | ||||||
| def output_turn_off_to_code(config, action_id, template_arg, args): | def output_turn_off_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_turn_off_action(template_arg) |     rhs = var.make_turn_off_action(template_arg) | ||||||
|     type = TurnOffAction.template(template_arg) |     type = TurnOffAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -103,12 +99,10 @@ OUTPUT_SET_LEVEL_ACTION = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_OUTPUT_SET_LEVEL, OUTPUT_SET_LEVEL_ACTION) | @ACTION_REGISTRY.register(CONF_OUTPUT_SET_LEVEL, OUTPUT_SET_LEVEL_ACTION) | ||||||
| def output_set_level_to_code(config, action_id, template_arg, args): | def output_set_level_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_set_level_action(template_arg) |     rhs = var.make_set_level_action(template_arg) | ||||||
|     type = SetLevelAction.template(template_arg) |     type = SetLevelAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config[CONF_LEVEL], args, float_): |     template_ = yield templatable(config[CONF_LEVEL], args, float_) | ||||||
|         yield None |  | ||||||
|     add(action.set_level(template_)) |     add(action.set_level(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -40,9 +40,7 @@ PLATFORM_SCHEMA = validate_copy_output | |||||||
| def to_code(config): | def to_code(config): | ||||||
|     outputs = [] |     outputs = [] | ||||||
|     for out in config[CONF_OUTPUTS]: |     for out in config[CONF_OUTPUTS]: | ||||||
|         for var in get_variable(out): |         outputs.append((yield get_variable(out))) | ||||||
|             yield |  | ||||||
|         outputs.append(var) |  | ||||||
|  |  | ||||||
|     klass = { |     klass = { | ||||||
|         'binary': BinaryCopyOutput, |         'binary': BinaryCopyOutput, | ||||||
|   | |||||||
| @@ -55,9 +55,8 @@ def to_code(config): | |||||||
|     else: |     else: | ||||||
|         ret_type = output.FloatOutputPtr |         ret_type = output.FloatOutputPtr | ||||||
|         klass = CustomFloatOutputConstructor |         klass = CustomFloatOutputConstructor | ||||||
|     for template_ in process_lambda(config[CONF_LAMBDA], [], |     template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                     return_type=std_vector.template(ret_type)): |                                      return_type=std_vector.template(ret_type)) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = klass(template_) |     rhs = klass(template_) | ||||||
|     custom = variable(config[CONF_ID], rhs) |     custom = variable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -27,8 +27,7 @@ PLATFORM_SCHEMA = output.FLOAT_OUTPUT_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin in gpio_output_pin_expression(config[CONF_PIN]): |     pin = yield gpio_output_pin_expression(config[CONF_PIN]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_esp8266_pwm_output(pin) |     rhs = App.make_esp8266_pwm_output(pin) | ||||||
|     gpio = Pvariable(config[CONF_ID], rhs) |     gpio = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -18,8 +18,7 @@ PLATFORM_SCHEMA = output.BINARY_OUTPUT_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin in gpio_output_pin_expression(config[CONF_PIN]): |     pin = yield gpio_output_pin_expression(config[CONF_PIN]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_gpio_output(pin) |     rhs = App.make_gpio_output(pin) | ||||||
|     gpio = Pvariable(config[CONF_ID], rhs) |     gpio = Pvariable(config[CONF_ID], rhs) | ||||||
|     output.setup_output_platform(gpio, config) |     output.setup_output_platform(gpio, config) | ||||||
|   | |||||||
| @@ -22,11 +22,8 @@ PLATFORM_SCHEMA = output.FLOAT_OUTPUT_PLATFORM_SCHEMA.extend({ | |||||||
| def to_code(config): | def to_code(config): | ||||||
|     power_supply = None |     power_supply = None | ||||||
|     if CONF_POWER_SUPPLY in config: |     if CONF_POWER_SUPPLY in config: | ||||||
|         for power_supply in get_variable(config[CONF_POWER_SUPPLY]): |         power_supply = yield get_variable(config[CONF_POWER_SUPPLY]) | ||||||
|             yield |     my9231 = yield get_variable(config[CONF_MY9231_ID]) | ||||||
|     my9231 = None |  | ||||||
|     for my9231 in get_variable(config[CONF_MY9231_ID]): |  | ||||||
|         yield |  | ||||||
|     rhs = my9231.create_channel(config[CONF_CHANNEL], power_supply) |     rhs = my9231.create_channel(config[CONF_CHANNEL], power_supply) | ||||||
|     out = Pvariable(config[CONF_ID], rhs) |     out = Pvariable(config[CONF_ID], rhs) | ||||||
|     output.setup_output_platform(out, config, skip_power_supply=True) |     output.setup_output_platform(out, config, skip_power_supply=True) | ||||||
|   | |||||||
| @@ -21,10 +21,8 @@ PLATFORM_SCHEMA = output.FLOAT_OUTPUT_PLATFORM_SCHEMA.extend({ | |||||||
| def to_code(config): | def to_code(config): | ||||||
|     power_supply = None |     power_supply = None | ||||||
|     if CONF_POWER_SUPPLY in config: |     if CONF_POWER_SUPPLY in config: | ||||||
|         for power_supply in get_variable(config[CONF_POWER_SUPPLY]): |         power_supply = yield get_variable(config[CONF_POWER_SUPPLY]) | ||||||
|             yield |     pca9685 = yield get_variable(config[CONF_PCA9685_ID]) | ||||||
|     for pca9685 in get_variable(config[CONF_PCA9685_ID]): |  | ||||||
|         yield |  | ||||||
|     rhs = pca9685.create_channel(config[CONF_CHANNEL], power_supply) |     rhs = pca9685.create_channel(config[CONF_CHANNEL], power_supply) | ||||||
|     out = Pvariable(config[CONF_ID], rhs) |     out = Pvariable(config[CONF_ID], rhs) | ||||||
|     output.setup_output_platform(out, config, skip_power_supply=True) |     output.setup_output_platform(out, config, skip_power_supply=True) | ||||||
|   | |||||||
| @@ -29,10 +29,8 @@ CONFIG_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for spi_ in get_variable(config[CONF_SPI_ID]): |     spi_ = yield get_variable(config[CONF_SPI_ID]) | ||||||
|         yield |     cs = yield gpio_output_pin_expression(config[CONF_CS_PIN]) | ||||||
|     for cs in gpio_output_pin_expression(config[CONF_CS_PIN]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_pn532_component(spi_, cs, config.get(CONF_UPDATE_INTERVAL)) |     rhs = App.make_pn532_component(spi_, cs, config.get(CONF_UPDATE_INTERVAL)) | ||||||
|     pn532 = Pvariable(config[CONF_ID], rhs) |     pn532 = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -20,8 +20,7 @@ CONFIG_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin in gpio_output_pin_expression(config[CONF_PIN]): |     pin = yield gpio_output_pin_expression(config[CONF_PIN]) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = App.make_power_supply(pin) |     rhs = App.make_power_supply(pin) | ||||||
|     psu = Pvariable(config[CONF_ID], rhs) |     psu = Pvariable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -17,8 +17,7 @@ CONFIG_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for uart_ in get_variable(config[CONF_UART_ID]): |     uart_ = yield get_variable(config[CONF_UART_ID]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_rdm6300_component(uart_) |     rhs = App.make_rdm6300_component(uart_) | ||||||
|     var = Pvariable(config[CONF_ID], rhs) |     var = Pvariable(config[CONF_ID], rhs) | ||||||
|     setup_component(var, config) |     setup_component(var, config) | ||||||
|   | |||||||
| @@ -54,8 +54,7 @@ CONFIG_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin in gpio_input_pin_expression(config[CONF_PIN]): |     pin = yield gpio_input_pin_expression(config[CONF_PIN]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_remote_receiver_component(pin) |     rhs = App.make_remote_receiver_component(pin) | ||||||
|     receiver = Pvariable(config[CONF_ID], rhs) |     receiver = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -106,8 +106,7 @@ def binary_code(value): | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin in gpio_output_pin_expression(config[CONF_PIN]): |     pin = yield gpio_output_pin_expression(config[CONF_PIN]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_remote_transmitter_component(pin) |     rhs = App.make_remote_transmitter_component(pin) | ||||||
|     transmitter = Pvariable(config[CONF_ID], rhs) |     transmitter = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -30,8 +30,7 @@ SCRIPT_EXECUTE_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_SCRIPT_EXECUTE, SCRIPT_EXECUTE_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_SCRIPT_EXECUTE, SCRIPT_EXECUTE_ACTION_SCHEMA) | ||||||
| def script_execute_action_to_code(config, action_id, template_arg, args): | def script_execute_action_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_execute_action(template_arg) |     rhs = var.make_execute_action(template_arg) | ||||||
|     type = ScriptExecuteAction.template(template_arg) |     type = ScriptExecuteAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -45,8 +44,7 @@ SCRIPT_STOP_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_SCRIPT_STOP, SCRIPT_STOP_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_SCRIPT_STOP, SCRIPT_STOP_ACTION_SCHEMA) | ||||||
| def script_stop_action_to_code(config, action_id, template_arg, args): | def script_stop_action_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_stop_action(template_arg) |     rhs = var.make_stop_action(template_arg) | ||||||
|     type = ScriptStopAction.template(template_arg) |     type = ScriptStopAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ from esphome.const import CONF_ABOVE, CONF_ACCURACY_DECIMALS, CONF_ALPHA, CONF_B | |||||||
|     CONF_SEND_EVERY, CONF_SEND_FIRST_AT, CONF_SLIDING_WINDOW_MOVING_AVERAGE, \ |     CONF_SEND_EVERY, CONF_SEND_FIRST_AT, CONF_SLIDING_WINDOW_MOVING_AVERAGE, \ | ||||||
|     CONF_THROTTLE, CONF_TO, CONF_TRIGGER_ID, CONF_UNIQUE, CONF_UNIT_OF_MEASUREMENT, \ |     CONF_THROTTLE, CONF_TO, CONF_TRIGGER_ID, CONF_UNIQUE, CONF_UNIT_OF_MEASUREMENT, \ | ||||||
|     CONF_WINDOW_SIZE |     CONF_WINDOW_SIZE | ||||||
| from esphome.core import CORE | from esphome.core import CORE, coroutine | ||||||
| from esphome.cpp_generator import Pvariable, add, get_variable, process_lambda, templatable | from esphome.cpp_generator import Pvariable, add, get_variable, process_lambda, templatable | ||||||
| from esphome.cpp_types import App, Component, Nameable, PollingComponent, Trigger, \ | from esphome.cpp_types import App, Component, Nameable, PollingComponent, Trigger, \ | ||||||
|     esphome_ns, float_, optional |     esphome_ns, float_, optional | ||||||
| @@ -143,6 +143,7 @@ SENSOR_SCHEMA = cv.MQTT_COMPONENT_SCHEMA.extend({ | |||||||
| SENSOR_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(SENSOR_SCHEMA.schema) | SENSOR_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(SENSOR_SCHEMA.schema) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def setup_filter(config): | def setup_filter(config): | ||||||
|     if CONF_OFFSET in config: |     if CONF_OFFSET in config: | ||||||
|         yield OffsetFilter.new(config[CONF_OFFSET]) |         yield OffsetFilter.new(config[CONF_OFFSET]) | ||||||
| @@ -158,17 +159,15 @@ def setup_filter(config): | |||||||
|         conf = config[CONF_EXPONENTIAL_MOVING_AVERAGE] |         conf = config[CONF_EXPONENTIAL_MOVING_AVERAGE] | ||||||
|         yield ExponentialMovingAverageFilter.new(conf[CONF_ALPHA], conf[CONF_SEND_EVERY]) |         yield ExponentialMovingAverageFilter.new(conf[CONF_ALPHA], conf[CONF_SEND_EVERY]) | ||||||
|     elif CONF_LAMBDA in config: |     elif CONF_LAMBDA in config: | ||||||
|         for lambda_ in process_lambda(config[CONF_LAMBDA], [(float_, 'x')], |         lambda_ = yield process_lambda(config[CONF_LAMBDA], [(float_, 'x')], | ||||||
|                                       return_type=optional.template(float_)): |                                        return_type=optional.template(float_)) | ||||||
|             yield None |  | ||||||
|         yield LambdaFilter.new(lambda_) |         yield LambdaFilter.new(lambda_) | ||||||
|     elif CONF_THROTTLE in config: |     elif CONF_THROTTLE in config: | ||||||
|         yield ThrottleFilter.new(config[CONF_THROTTLE]) |         yield ThrottleFilter.new(config[CONF_THROTTLE]) | ||||||
|     elif CONF_DELTA in config: |     elif CONF_DELTA in config: | ||||||
|         yield DeltaFilter.new(config[CONF_DELTA]) |         yield DeltaFilter.new(config[CONF_DELTA]) | ||||||
|     elif CONF_OR in config: |     elif CONF_OR in config: | ||||||
|         for filters in setup_filters(config[CONF_OR]): |         filters = yield setup_filters(config[CONF_OR]) | ||||||
|             yield None |  | ||||||
|         yield OrFilter.new(filters) |         yield OrFilter.new(filters) | ||||||
|     elif CONF_HEARTBEAT in config: |     elif CONF_HEARTBEAT in config: | ||||||
|         yield App.register_component(HeartbeatFilter.new(config[CONF_HEARTBEAT])) |         yield App.register_component(HeartbeatFilter.new(config[CONF_HEARTBEAT])) | ||||||
| @@ -181,15 +180,15 @@ def setup_filter(config): | |||||||
|         yield CalibrateLinearFilter.new(k, b) |         yield CalibrateLinearFilter.new(k, b) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def setup_filters(config): | def setup_filters(config): | ||||||
|     filters = [] |     filters = [] | ||||||
|     for conf in config: |     for conf in config: | ||||||
|         for filter in setup_filter(conf): |         filters.append((yield setup_filter(conf))) | ||||||
|             yield None |  | ||||||
|         filters.append(filter) |  | ||||||
|     yield filters |     yield filters | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @coroutine | ||||||
| def setup_sensor_core_(sensor_var, config): | def setup_sensor_core_(sensor_var, config): | ||||||
|     if CONF_INTERNAL in config: |     if CONF_INTERNAL in config: | ||||||
|         add(sensor_var.set_internal(config[CONF_INTERNAL])) |         add(sensor_var.set_internal(config[CONF_INTERNAL])) | ||||||
| @@ -200,8 +199,7 @@ def setup_sensor_core_(sensor_var, config): | |||||||
|     if CONF_ACCURACY_DECIMALS in config: |     if CONF_ACCURACY_DECIMALS in config: | ||||||
|         add(sensor_var.set_accuracy_decimals(config[CONF_ACCURACY_DECIMALS])) |         add(sensor_var.set_accuracy_decimals(config[CONF_ACCURACY_DECIMALS])) | ||||||
|     if CONF_FILTERS in config: |     if CONF_FILTERS in config: | ||||||
|         for filters in setup_filters(config[CONF_FILTERS]): |         filters = yield setup_filters(config[CONF_FILTERS]) | ||||||
|             yield |  | ||||||
|         add(sensor_var.set_filters(filters)) |         add(sensor_var.set_filters(filters)) | ||||||
|  |  | ||||||
|     for conf in config.get(CONF_ON_VALUE, []): |     for conf in config.get(CONF_ON_VALUE, []): | ||||||
| @@ -217,12 +215,10 @@ def setup_sensor_core_(sensor_var, config): | |||||||
|         trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) |         trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) | ||||||
|         add(App.register_component(trigger)) |         add(App.register_component(trigger)) | ||||||
|         if CONF_ABOVE in conf: |         if CONF_ABOVE in conf: | ||||||
|             for template_ in templatable(conf[CONF_ABOVE], float_, float_): |             template_ = yield templatable(conf[CONF_ABOVE], float_, float_) | ||||||
|                 yield |  | ||||||
|             add(trigger.set_min(template_)) |             add(trigger.set_min(template_)) | ||||||
|         if CONF_BELOW in conf: |         if CONF_BELOW in conf: | ||||||
|             for template_ in templatable(conf[CONF_BELOW], float_, float_): |             template_ = yield templatable(conf[CONF_BELOW], float_, float_) | ||||||
|                 yield |  | ||||||
|             add(trigger.set_max(template_)) |             add(trigger.set_max(template_)) | ||||||
|         automation.build_automations(trigger, [(float_, 'x')], conf) |         automation.build_automations(trigger, [(float_, 'x')], conf) | ||||||
|  |  | ||||||
| @@ -260,8 +256,7 @@ SENSOR_IN_RANGE_CONDITION_SCHEMA = vol.All({ | |||||||
|  |  | ||||||
| @CONDITION_REGISTRY.register(CONF_SENSOR_IN_RANGE, SENSOR_IN_RANGE_CONDITION_SCHEMA) | @CONDITION_REGISTRY.register(CONF_SENSOR_IN_RANGE, SENSOR_IN_RANGE_CONDITION_SCHEMA) | ||||||
| def sensor_in_range_to_code(config, condition_id, template_arg, args): | def sensor_in_range_to_code(config, condition_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_sensor_in_range_condition(template_arg) |     rhs = var.make_sensor_in_range_condition(template_arg) | ||||||
|     type = SensorInRangeCondition.template(template_arg) |     type = SensorInRangeCondition.template(template_arg) | ||||||
|     cond = Pvariable(condition_id, rhs, type=type) |     cond = Pvariable(condition_id, rhs, type=type) | ||||||
|   | |||||||
| @@ -60,8 +60,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_ADS1115_ID]): |     hub = yield get_variable(config[CONF_ADS1115_ID]) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     mux = MUX[config[CONF_MULTIPLEXER]] |     mux = MUX[config[CONF_MULTIPLEXER]] | ||||||
|     gain = GAIN[config[CONF_GAIN]] |     gain = GAIN[config[CONF_GAIN]] | ||||||
|   | |||||||
| @@ -24,8 +24,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_APDS9960_ID]): |     hub = yield get_variable(config[CONF_APDS9960_ID]) | ||||||
|         yield |  | ||||||
|     func = getattr(hub, TYPES[config[CONF_TYPE]]) |     func = getattr(hub, TYPES[config[CONF_TYPE]]) | ||||||
|     rhs = func(config[CONF_NAME]) |     rhs = func(config[CONF_NAME]) | ||||||
|     sensor.register_sensor(rhs, config) |     sensor.register_sensor(rhs, config) | ||||||
|   | |||||||
| @@ -20,7 +20,6 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_ESP32_BLE_ID]): |     hub = yield get_variable(config[CONF_ESP32_BLE_ID]) | ||||||
|         yield |  | ||||||
|     rhs = hub.make_rssi_sensor(config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS])) |     rhs = hub.make_rssi_sensor(config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS])) | ||||||
|     sensor.register_sensor(rhs, config) |     sensor.register_sensor(rhs, config) | ||||||
|   | |||||||
| @@ -38,8 +38,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for uart_ in get_variable(config[CONF_UART_ID]): |     uart_ = yield get_variable(config[CONF_UART_ID]) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = App.make_cse7766(uart_, config.get(CONF_UPDATE_INTERVAL)) |     rhs = App.make_cse7766(uart_, config.get(CONF_UPDATE_INTERVAL)) | ||||||
|     cse = Pvariable(config[CONF_ID], rhs) |     cse = Pvariable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -18,9 +18,8 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for template_ in process_lambda(config[CONF_LAMBDA], [], |     template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                     return_type=std_vector.template(sensor.SensorPtr)): |                                      return_type=std_vector.template(sensor.SensorPtr)) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = CustomSensorConstructor(template_) |     rhs = CustomSensorConstructor(template_) | ||||||
|     custom = variable(config[CONF_ID], rhs) |     custom = variable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -20,8 +20,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_DALLAS_ID]): |     hub = yield get_variable(config[CONF_DALLAS_ID]) | ||||||
|         yield |  | ||||||
|     if CONF_ADDRESS in config: |     if CONF_ADDRESS in config: | ||||||
|         address = HexIntLiteral(config[CONF_ADDRESS]) |         address = HexIntLiteral(config[CONF_ADDRESS]) | ||||||
|         rhs = hub.Pget_sensor_by_address(config[CONF_NAME], address, config.get(CONF_RESOLUTION)) |         rhs = hub.Pget_sensor_by_address(config[CONF_NAME], address, config.get(CONF_RESOLUTION)) | ||||||
|   | |||||||
| @@ -40,8 +40,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin in gpio_output_pin_expression(config[CONF_PIN]): |     pin = yield gpio_output_pin_expression(config[CONF_PIN]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_dht_sensor(config[CONF_TEMPERATURE][CONF_NAME], |     rhs = App.make_dht_sensor(config[CONF_TEMPERATURE][CONF_NAME], | ||||||
|                               config[CONF_HUMIDITY][CONF_NAME], |                               config[CONF_HUMIDITY][CONF_NAME], | ||||||
|                               pin, config.get(CONF_UPDATE_INTERVAL)) |                               pin, config.get(CONF_UPDATE_INTERVAL)) | ||||||
|   | |||||||
| @@ -19,8 +19,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin in gpio_input_pin_expression(config[CONF_PIN]): |     pin = yield gpio_input_pin_expression(config[CONF_PIN]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_duty_cycle_sensor(config[CONF_NAME], pin, |     rhs = App.make_duty_cycle_sensor(config[CONF_NAME], pin, | ||||||
|                                      config.get(CONF_UPDATE_INTERVAL)) |                                      config.get(CONF_UPDATE_INTERVAL)) | ||||||
|     duty = Pvariable(config[CONF_ID], rhs) |     duty = Pvariable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -40,8 +40,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for sel in gpio_output_pin_expression(config[CONF_SEL_PIN]): |     sel = yield gpio_output_pin_expression(config[CONF_SEL_PIN]) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = App.make_hlw8012(sel, config[CONF_CF_PIN], config[CONF_CF1_PIN], |     rhs = App.make_hlw8012(sel, config[CONF_CF_PIN], config[CONF_CF1_PIN], | ||||||
|                            config.get(CONF_UPDATE_INTERVAL)) |                            config.get(CONF_UPDATE_INTERVAL)) | ||||||
|   | |||||||
| @@ -30,10 +30,8 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for dout_pin in gpio_input_pin_expression(config[CONF_DOUT_PIN]): |     dout_pin = yield gpio_input_pin_expression(config[CONF_DOUT_PIN]) | ||||||
|         yield |     sck_pin = yield gpio_input_pin_expression(config[CONF_CLK_PIN]) | ||||||
|     for sck_pin in gpio_input_pin_expression(config[CONF_CLK_PIN]): |  | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = App.make_hx711_sensor(config[CONF_NAME], dout_pin, sck_pin, |     rhs = App.make_hx711_sensor(config[CONF_NAME], dout_pin, sck_pin, | ||||||
|                                 config.get(CONF_UPDATE_INTERVAL)) |                                 config.get(CONF_UPDATE_INTERVAL)) | ||||||
|   | |||||||
| @@ -21,10 +21,8 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for spi_ in get_variable(config[CONF_SPI_ID]): |     spi_ = yield get_variable(config[CONF_SPI_ID]) | ||||||
|         yield |     cs = yield gpio_output_pin_expression(config[CONF_CS_PIN]) | ||||||
|     for cs in gpio_output_pin_expression(config[CONF_CS_PIN]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_max31855_sensor(config[CONF_NAME], spi_, cs, |     rhs = App.make_max31855_sensor(config[CONF_NAME], spi_, cs, | ||||||
|                                    config.get(CONF_UPDATE_INTERVAL)) |                                    config.get(CONF_UPDATE_INTERVAL)) | ||||||
|     max31855 = Pvariable(config[CONF_ID], rhs) |     max31855 = Pvariable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -22,10 +22,8 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for spi_ in get_variable(config[CONF_SPI_ID]): |     spi_ = yield get_variable(config[CONF_SPI_ID]) | ||||||
|         yield |     cs = yield gpio_output_pin_expression(config[CONF_CS_PIN]) | ||||||
|     for cs in gpio_output_pin_expression(config[CONF_CS_PIN]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_max6675_sensor(config[CONF_NAME], spi_, cs, |     rhs = App.make_max6675_sensor(config[CONF_NAME], spi_, cs, | ||||||
|                                   config.get(CONF_UPDATE_INTERVAL)) |                                   config.get(CONF_UPDATE_INTERVAL)) | ||||||
|     max6675 = Pvariable(config[CONF_ID], rhs) |     max6675 = Pvariable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -30,8 +30,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for uart_ in get_variable(config[CONF_UART_ID]): |     uart_ = yield get_variable(config[CONF_UART_ID]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_mhz19_sensor(uart_, config[CONF_CO2][CONF_NAME], |     rhs = App.make_mhz19_sensor(uart_, config[CONF_CO2][CONF_NAME], | ||||||
|                                 config.get(CONF_UPDATE_INTERVAL)) |                                 config.get(CONF_UPDATE_INTERVAL)) | ||||||
|     mhz19 = Pvariable(config[CONF_ID], rhs) |     mhz19 = Pvariable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -61,8 +61,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for uart_ in get_variable(config[CONF_UART_ID]): |     uart_ = yield get_variable(config[CONF_UART_ID]) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = App.make_pmsx003(uart_, PMSX003_TYPES[config[CONF_TYPE]]) |     rhs = App.make_pmsx003(uart_, PMSX003_TYPES[config[CONF_TYPE]]) | ||||||
|     pms = Pvariable(config[CONF_ID], rhs) |     pms = Pvariable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -58,8 +58,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin in gpio_input_pin_expression(config[CONF_PIN]): |     pin = yield gpio_input_pin_expression(config[CONF_PIN]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_pulse_counter_sensor(config[CONF_NAME], pin, |     rhs = App.make_pulse_counter_sensor(config[CONF_NAME], pin, | ||||||
|                                         config.get(CONF_UPDATE_INTERVAL)) |                                         config.get(CONF_UPDATE_INTERVAL)) | ||||||
|     pcnt = Pvariable(config[CONF_ID], rhs) |     pcnt = Pvariable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -46,16 +46,13 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin_a in gpio_input_pin_expression(config[CONF_PIN_A]): |     pin_a = yield gpio_input_pin_expression(config[CONF_PIN_A]) | ||||||
|         yield |     pin_b = yield gpio_input_pin_expression(config[CONF_PIN_B]) | ||||||
|     for pin_b in gpio_input_pin_expression(config[CONF_PIN_B]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_rotary_encoder_sensor(config[CONF_NAME], pin_a, pin_b) |     rhs = App.make_rotary_encoder_sensor(config[CONF_NAME], pin_a, pin_b) | ||||||
|     encoder = Pvariable(config[CONF_ID], rhs) |     encoder = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|     if CONF_PIN_RESET in config: |     if CONF_PIN_RESET in config: | ||||||
|         for pin_i in gpio_input_pin_expression(config[CONF_PIN_RESET]): |         pin_i = yield gpio_input_pin_expression(config[CONF_PIN_RESET]) | ||||||
|             yield |  | ||||||
|         add(encoder.set_reset_pin(pin_i)) |         add(encoder.set_reset_pin(pin_i)) | ||||||
|     if CONF_RESOLUTION in config: |     if CONF_RESOLUTION in config: | ||||||
|         resolution = RESOLUTIONS[config[CONF_RESOLUTION]] |         resolution = RESOLUTIONS[config[CONF_RESOLUTION]] | ||||||
|   | |||||||
| @@ -46,8 +46,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for uart_ in get_variable(config[CONF_UART_ID]): |     uart_ = yield get_variable(config[CONF_UART_ID]) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = App.make_sds011(uart_) |     rhs = App.make_sds011(uart_) | ||||||
|     sds011 = Pvariable(config[CONF_ID], rhs) |     sds011 = Pvariable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -26,9 +26,8 @@ def to_code(config): | |||||||
|     setup_component(template, config) |     setup_component(template, config) | ||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for template_ in process_lambda(config[CONF_LAMBDA], [], |         template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                         return_type=optional.template(float_)): |                                          return_type=optional.template(float_)) | ||||||
|             yield |  | ||||||
|         add(template.set_template(template_)) |         add(template.set_template(template_)) | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -43,12 +42,10 @@ SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_SENSOR_TEMPLATE_PUBLISH, SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_SENSOR_TEMPLATE_PUBLISH, SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA) | ||||||
| def sensor_template_publish_to_code(config, action_id, template_arg, args): | def sensor_template_publish_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_sensor_publish_action(template_arg) |     rhs = var.make_sensor_publish_action(template_arg) | ||||||
|     type = SensorPublishAction.template(template_arg) |     type = SensorPublishAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config[CONF_STATE], args, float_): |     template_ = yield templatable(config[CONF_STATE], args, float_) | ||||||
|         yield None |  | ||||||
|     add(action.set_state(template_)) |     add(action.set_state(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -20,10 +20,8 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for time_ in get_variable(config[CONF_TIME_ID]): |     time_ = yield get_variable(config[CONF_TIME_ID]) | ||||||
|         yield |     sens = yield get_variable(config[CONF_POWER_ID]) | ||||||
|     for sens in get_variable(config[CONF_POWER_ID]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_total_daily_energy_sensor(config[CONF_NAME], time_, sens) |     rhs = App.make_total_daily_energy_sensor(config[CONF_NAME], time_, sens) | ||||||
|     total_energy = Pvariable(config[CONF_ID], rhs) |     total_energy = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -33,10 +33,8 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for trigger in gpio_output_pin_expression(config[CONF_TRIGGER_PIN]): |     trigger = yield gpio_output_pin_expression(config[CONF_TRIGGER_PIN]) | ||||||
|         yield |     echo = yield gpio_input_pin_expression(config[CONF_ECHO_PIN]) | ||||||
|     for echo in gpio_input_pin_expression(config[CONF_ECHO_PIN]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_ultrasonic_sensor(config[CONF_NAME], trigger, echo, |     rhs = App.make_ultrasonic_sensor(config[CONF_NAME], trigger, echo, | ||||||
|                                      config.get(CONF_UPDATE_INTERVAL)) |                                      config.get(CONF_UPDATE_INTERVAL)) | ||||||
|     ultrasonic = Pvariable(config[CONF_ID], rhs) |     ultrasonic = Pvariable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -23,8 +23,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_ESP32_BLE_ID]): |     hub = yield get_variable(config[CONF_ESP32_BLE_ID]) | ||||||
|         yield |  | ||||||
|     rhs = hub.make_xiaomi_device(make_address_array(config[CONF_MAC_ADDRESS])) |     rhs = hub.make_xiaomi_device(make_address_array(config[CONF_MAC_ADDRESS])) | ||||||
|     dev = Pvariable(config[CONF_ID], rhs) |     dev = Pvariable(config[CONF_ID], rhs) | ||||||
|     if CONF_TEMPERATURE in config: |     if CONF_TEMPERATURE in config: | ||||||
|   | |||||||
| @@ -21,8 +21,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for hub in get_variable(config[CONF_ESP32_BLE_ID]): |     hub = yield get_variable(config[CONF_ESP32_BLE_ID]) | ||||||
|         yield |  | ||||||
|     rhs = hub.make_xiaomi_device(make_address_array(config[CONF_MAC_ADDRESS])) |     rhs = hub.make_xiaomi_device(make_address_array(config[CONF_MAC_ADDRESS])) | ||||||
|     dev = Pvariable(config[CONF_MAKE_ID], rhs) |     dev = Pvariable(config[CONF_MAKE_ID], rhs) | ||||||
|     if CONF_TEMPERATURE in config: |     if CONF_TEMPERATURE in config: | ||||||
|   | |||||||
| @@ -24,8 +24,7 @@ CONFIG_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for out in get_variable(config[CONF_OUTPUT]): |     out = yield get_variable(config[CONF_OUTPUT]) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = App.register_component(Servo.new(out)) |     rhs = App.register_component(Servo.new(out)) | ||||||
|     servo = Pvariable(config[CONF_ID], rhs) |     servo = Pvariable(config[CONF_ID], rhs) | ||||||
| @@ -48,12 +47,10 @@ SERVO_WRITE_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_SERVO_WRITE, SERVO_WRITE_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_SERVO_WRITE, SERVO_WRITE_ACTION_SCHEMA) | ||||||
| def servo_write_to_code(config, action_id, template_arg, args): | def servo_write_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = ServoWriteAction.new(template_arg, var) |     rhs = ServoWriteAction.new(template_arg, var) | ||||||
|     type = ServoWriteAction.template(template_arg) |     type = ServoWriteAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config[CONF_LEVEL], args, float_): |     template_ = yield templatable(config[CONF_LEVEL], args, float_) | ||||||
|         yield None |  | ||||||
|     add(action.set_value(template_)) |     add(action.set_value(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -21,17 +21,14 @@ CONFIG_SCHEMA = vol.All(cv.Schema({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for clk in gpio_output_pin_expression(config[CONF_CLK_PIN]): |     clk = yield gpio_output_pin_expression(config[CONF_CLK_PIN]) | ||||||
|         yield |  | ||||||
|     rhs = App.init_spi(clk) |     rhs = App.init_spi(clk) | ||||||
|     spi = Pvariable(config[CONF_ID], rhs) |     spi = Pvariable(config[CONF_ID], rhs) | ||||||
|     if CONF_MISO_PIN in config: |     if CONF_MISO_PIN in config: | ||||||
|         for miso in gpio_input_pin_expression(config[CONF_MISO_PIN]): |         miso = yield gpio_input_pin_expression(config[CONF_MISO_PIN]) | ||||||
|             yield |  | ||||||
|         add(spi.set_miso(miso)) |         add(spi.set_miso(miso)) | ||||||
|     if CONF_MOSI_PIN in config: |     if CONF_MOSI_PIN in config: | ||||||
|         for mosi in gpio_input_pin_expression(config[CONF_MOSI_PIN]): |         mosi = yield gpio_input_pin_expression(config[CONF_MOSI_PIN]) | ||||||
|             yield |  | ||||||
|         add(spi.set_mosi(mosi)) |         add(spi.set_mosi(mosi)) | ||||||
|  |  | ||||||
|     setup_component(spi, config) |     setup_component(spi, config) | ||||||
|   | |||||||
| @@ -15,8 +15,7 @@ CONFIG_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin in gpio_output_pin_expression(config[CONF_PIN]): |     pin = yield gpio_output_pin_expression(config[CONF_PIN]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_status_led(pin) |     rhs = App.make_status_led(pin) | ||||||
|     var = Pvariable(config[CONF_ID], rhs) |     var = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -93,13 +93,11 @@ STEPPER_SET_TARGET_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_STEPPER_SET_TARGET, STEPPER_SET_TARGET_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_STEPPER_SET_TARGET, STEPPER_SET_TARGET_ACTION_SCHEMA) | ||||||
| def stepper_set_target_to_code(config, action_id, template_arg, args): | def stepper_set_target_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_set_target_action(template_arg) |     rhs = var.make_set_target_action(template_arg) | ||||||
|     type = SetTargetAction.template(template_arg) |     type = SetTargetAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config[CONF_TARGET], args, int32): |     template_ = yield templatable(config[CONF_TARGET], args, int32) | ||||||
|         yield None |  | ||||||
|     add(action.set_target(template_)) |     add(action.set_target(template_)) | ||||||
|     yield action |     yield action | ||||||
|  |  | ||||||
| @@ -113,12 +111,10 @@ STEPPER_REPORT_POSITION_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_STEPPER_REPORT_POSITION, STEPPER_REPORT_POSITION_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_STEPPER_REPORT_POSITION, STEPPER_REPORT_POSITION_ACTION_SCHEMA) | ||||||
| def stepper_report_position_to_code(config, action_id, template_arg, args): | def stepper_report_position_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_report_position_action(template_arg) |     rhs = var.make_report_position_action(template_arg) | ||||||
|     type = ReportPositionAction.template(template_arg) |     type = ReportPositionAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config[CONF_POSITION], args, int32): |     template_ = yield templatable(config[CONF_POSITION], args, int32) | ||||||
|         yield None |  | ||||||
|     add(action.set_position(template_)) |     add(action.set_position(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -19,16 +19,13 @@ PLATFORM_SCHEMA = stepper.STEPPER_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for step_pin in gpio_output_pin_expression(config[CONF_STEP_PIN]): |     step_pin = yield gpio_output_pin_expression(config[CONF_STEP_PIN]) | ||||||
|         yield |     dir_pin = yield gpio_output_pin_expression(config[CONF_DIR_PIN]) | ||||||
|     for dir_pin in gpio_output_pin_expression(config[CONF_DIR_PIN]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_a4988(step_pin, dir_pin) |     rhs = App.make_a4988(step_pin, dir_pin) | ||||||
|     a4988 = Pvariable(config[CONF_ID], rhs) |     a4988 = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|     if CONF_SLEEP_PIN in config: |     if CONF_SLEEP_PIN in config: | ||||||
|         for sleep_pin in gpio_output_pin_expression(config[CONF_SLEEP_PIN]): |         sleep_pin = yield gpio_output_pin_expression(config[CONF_SLEEP_PIN]) | ||||||
|             yield |  | ||||||
|         add(a4988.set_sleep_pin(sleep_pin)) |         add(a4988.set_sleep_pin(sleep_pin)) | ||||||
|  |  | ||||||
|     stepper.setup_stepper(a4988, config) |     stepper.setup_stepper(a4988, config) | ||||||
|   | |||||||
| @@ -31,14 +31,10 @@ PLATFORM_SCHEMA = stepper.STEPPER_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin_a in gpio_output_pin_expression(config[CONF_PIN_A]): |     pin_a = yield gpio_output_pin_expression(config[CONF_PIN_A]) | ||||||
|         yield |     pin_b = yield gpio_output_pin_expression(config[CONF_PIN_B]) | ||||||
|     for pin_b in gpio_output_pin_expression(config[CONF_PIN_B]): |     pin_c = yield gpio_output_pin_expression(config[CONF_PIN_C]) | ||||||
|         yield |     pin_d = yield gpio_output_pin_expression(config[CONF_PIN_D]) | ||||||
|     for pin_c in gpio_output_pin_expression(config[CONF_PIN_C]): |  | ||||||
|         yield |  | ||||||
|     for pin_d in gpio_output_pin_expression(config[CONF_PIN_D]): |  | ||||||
|         yield |  | ||||||
|     rhs = App.make_uln2003(pin_a, pin_b, pin_c, pin_d) |     rhs = App.make_uln2003(pin_a, pin_b, pin_c, pin_d) | ||||||
|     uln = Pvariable(config[CONF_ID], rhs) |     uln = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -84,8 +84,7 @@ SWITCH_TOGGLE_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_SWITCH_TOGGLE, SWITCH_TOGGLE_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_SWITCH_TOGGLE, SWITCH_TOGGLE_ACTION_SCHEMA) | ||||||
| def switch_toggle_to_code(config, action_id, template_arg, args): | def switch_toggle_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_toggle_action(template_arg) |     rhs = var.make_toggle_action(template_arg) | ||||||
|     type = ToggleAction.template(template_arg) |     type = ToggleAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -99,8 +98,7 @@ SWITCH_TURN_OFF_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_SWITCH_TURN_OFF, SWITCH_TURN_OFF_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_SWITCH_TURN_OFF, SWITCH_TURN_OFF_ACTION_SCHEMA) | ||||||
| def switch_turn_off_to_code(config, action_id, template_arg, args): | def switch_turn_off_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_turn_off_action(template_arg) |     rhs = var.make_turn_off_action(template_arg) | ||||||
|     type = TurnOffAction.template(template_arg) |     type = TurnOffAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -114,8 +112,7 @@ SWITCH_TURN_ON_ACTION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_SWITCH_TURN_ON, SWITCH_TURN_ON_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_SWITCH_TURN_ON, SWITCH_TURN_ON_ACTION_SCHEMA) | ||||||
| def switch_turn_on_to_code(config, action_id, template_arg, args): | def switch_turn_on_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_turn_on_action(template_arg) |     rhs = var.make_turn_on_action(template_arg) | ||||||
|     type = TurnOnAction.template(template_arg) |     type = TurnOnAction.template(template_arg) | ||||||
|     yield Pvariable(action_id, rhs, type=type) |     yield Pvariable(action_id, rhs, type=type) | ||||||
| @@ -129,8 +126,7 @@ SWITCH_IS_ON_CONDITION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @CONDITION_REGISTRY.register(CONF_SWITCH_IS_ON, SWITCH_IS_ON_CONDITION_SCHEMA) | @CONDITION_REGISTRY.register(CONF_SWITCH_IS_ON, SWITCH_IS_ON_CONDITION_SCHEMA) | ||||||
| def switch_is_on_to_code(config, condition_id, template_arg, args): | def switch_is_on_to_code(config, condition_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_switch_is_on_condition(template_arg) |     rhs = var.make_switch_is_on_condition(template_arg) | ||||||
|     type = SwitchCondition.template(template_arg) |     type = SwitchCondition.template(template_arg) | ||||||
|     yield Pvariable(condition_id, rhs, type=type) |     yield Pvariable(condition_id, rhs, type=type) | ||||||
| @@ -144,8 +140,7 @@ SWITCH_IS_OFF_CONDITION_SCHEMA = maybe_simple_id({ | |||||||
|  |  | ||||||
| @CONDITION_REGISTRY.register(CONF_SWITCH_IS_OFF, SWITCH_IS_OFF_CONDITION_SCHEMA) | @CONDITION_REGISTRY.register(CONF_SWITCH_IS_OFF, SWITCH_IS_OFF_CONDITION_SCHEMA) | ||||||
| def switch_is_off_to_code(config, condition_id, template_arg, args): | def switch_is_off_to_code(config, condition_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_switch_is_off_condition(template_arg) |     rhs = var.make_switch_is_off_condition(template_arg) | ||||||
|     type = SwitchCondition.template(template_arg) |     type = SwitchCondition.template(template_arg) | ||||||
|     yield Pvariable(condition_id, rhs, type=type) |     yield Pvariable(condition_id, rhs, type=type) | ||||||
|   | |||||||
| @@ -19,9 +19,8 @@ PLATFORM_SCHEMA = switch.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for template_ in process_lambda(config[CONF_LAMBDA], [], |     template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                     return_type=std_vector.template(switch.SwitchPtr)): |                                      return_type=std_vector.template(switch.SwitchPtr)) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = CustomSwitchConstructor(template_) |     rhs = CustomSwitchConstructor(template_) | ||||||
|     custom = variable(config[CONF_ID], rhs) |     custom = variable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -27,8 +27,7 @@ PLATFORM_SCHEMA = cv.nameable(switch.SWITCH_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for pin in gpio_output_pin_expression(config[CONF_PIN]): |     pin = yield gpio_output_pin_expression(config[CONF_PIN]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_gpio_switch(config[CONF_NAME], pin) |     rhs = App.make_gpio_switch(config[CONF_NAME], pin) | ||||||
|     gpio = Pvariable(config[CONF_ID], rhs) |     gpio = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
| @@ -38,8 +37,7 @@ def to_code(config): | |||||||
|     if CONF_INTERLOCK in config: |     if CONF_INTERLOCK in config: | ||||||
|         interlock = [] |         interlock = [] | ||||||
|         for it in config[CONF_INTERLOCK]: |         for it in config[CONF_INTERLOCK]: | ||||||
|             for lock in get_variable(it): |             lock = yield get_variable(it) | ||||||
|                 yield |  | ||||||
|             interlock.append(lock) |             interlock.append(lock) | ||||||
|         add(gpio.set_interlock(interlock)) |         add(gpio.set_interlock(interlock)) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,8 +16,7 @@ PLATFORM_SCHEMA = cv.nameable(switch.SWITCH_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for output_ in get_variable(config[CONF_OUTPUT]): |     output_ = yield get_variable(config[CONF_OUTPUT]) | ||||||
|         yield |  | ||||||
|     rhs = App.make_output_switch(config[CONF_NAME], output_) |     rhs = App.make_output_switch(config[CONF_NAME], output_) | ||||||
|     switch_ = Pvariable(config[CONF_ID], rhs) |     switch_ = Pvariable(config[CONF_ID], rhs) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -146,8 +146,7 @@ def transmitter_base(full_config): | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for remote in get_variable(config[CONF_REMOTE_TRANSMITTER_ID]): |     remote = yield get_variable(config[CONF_REMOTE_TRANSMITTER_ID]) | ||||||
|         yield |  | ||||||
|     rhs = transmitter_base(config) |     rhs = transmitter_base(config) | ||||||
|     transmitter = Pvariable(config[CONF_TRANSMITTER_ID], rhs) |     transmitter = Pvariable(config[CONF_TRANSMITTER_ID], rhs) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -31,9 +31,8 @@ def to_code(config): | |||||||
|     switch.setup_switch(template, config) |     switch.setup_switch(template, config) | ||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for template_ in process_lambda(config[CONF_LAMBDA], [], |         template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                         return_type=optional.template(bool_)): |                                          return_type=optional.template(bool_)) | ||||||
|             yield |  | ||||||
|         add(template.set_state_lambda(template_)) |         add(template.set_state_lambda(template_)) | ||||||
|     if CONF_TURN_OFF_ACTION in config: |     if CONF_TURN_OFF_ACTION in config: | ||||||
|         automation.build_automations(template.get_turn_off_trigger(), [], |         automation.build_automations(template.get_turn_off_trigger(), [], | ||||||
| @@ -63,12 +62,10 @@ SWITCH_TEMPLATE_PUBLISH_ACTION_SCHEMA = cv.Schema({ | |||||||
|  |  | ||||||
| @ACTION_REGISTRY.register(CONF_SWITCH_TEMPLATE_PUBLISH, SWITCH_TEMPLATE_PUBLISH_ACTION_SCHEMA) | @ACTION_REGISTRY.register(CONF_SWITCH_TEMPLATE_PUBLISH, SWITCH_TEMPLATE_PUBLISH_ACTION_SCHEMA) | ||||||
| def switch_template_publish_to_code(config, action_id, template_arg, args): | def switch_template_publish_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_switch_publish_action(template_arg) |     rhs = var.make_switch_publish_action(template_arg) | ||||||
|     type = SwitchPublishAction.template(template_arg) |     type = SwitchPublishAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config[CONF_STATE], args, bool_): |     template_ = yield templatable(config[CONF_STATE], args, bool_) | ||||||
|         yield None |  | ||||||
|     add(action.set_state(template_)) |     add(action.set_state(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -33,8 +33,7 @@ PLATFORM_SCHEMA = cv.nameable(switch.SWITCH_PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for uart_ in get_variable(config[CONF_UART_ID]): |     uart_ = yield get_variable(config[CONF_UART_ID]) | ||||||
|         yield |  | ||||||
|     data = config[CONF_DATA] |     data = config[CONF_DATA] | ||||||
|     if isinstance(data, str): |     if isinstance(data, str): | ||||||
|         data = [HexInt(ord(x)) for x in data] |         data = [HexInt(ord(x)) for x in data] | ||||||
|   | |||||||
| @@ -19,9 +19,8 @@ PLATFORM_SCHEMA = text_sensor.PLATFORM_SCHEMA.extend({ | |||||||
|  |  | ||||||
|  |  | ||||||
| def to_code(config): | def to_code(config): | ||||||
|     for template_ in process_lambda(config[CONF_LAMBDA], [], |     template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                     return_type=std_vector.template(text_sensor.TextSensorPtr)): |                                      return_type=std_vector.template(text_sensor.TextSensorPtr)) | ||||||
|         yield |  | ||||||
|  |  | ||||||
|     rhs = CustomTextSensorConstructor(template_) |     rhs = CustomTextSensorConstructor(template_) | ||||||
|     custom = variable(config[CONF_ID], rhs) |     custom = variable(config[CONF_ID], rhs) | ||||||
|   | |||||||
| @@ -26,9 +26,8 @@ def to_code(config): | |||||||
|     setup_component(template, config) |     setup_component(template, config) | ||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         for template_ in process_lambda(config[CONF_LAMBDA], [], |         template_ = yield process_lambda(config[CONF_LAMBDA], [], | ||||||
|                                         return_type=optional.template(std_string)): |                                          return_type=optional.template(std_string)) | ||||||
|             yield |  | ||||||
|         add(template.set_template(template_)) |         add(template.set_template(template_)) | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -44,12 +43,10 @@ TEXT_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA = cv.Schema({ | |||||||
| @ACTION_REGISTRY.register(CONF_TEXT_SENSOR_TEMPLATE_PUBLISH, | @ACTION_REGISTRY.register(CONF_TEXT_SENSOR_TEMPLATE_PUBLISH, | ||||||
|                           TEXT_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA) |                           TEXT_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA) | ||||||
| def text_sensor_template_publish_to_code(config, action_id, template_arg, args): | def text_sensor_template_publish_to_code(config, action_id, template_arg, args): | ||||||
|     for var in get_variable(config[CONF_ID]): |     var = yield get_variable(config[CONF_ID]) | ||||||
|         yield None |  | ||||||
|     rhs = var.make_text_sensor_publish_action(template_arg) |     rhs = var.make_text_sensor_publish_action(template_arg) | ||||||
|     type = TextSensorPublishAction.template(template_arg) |     type = TextSensorPublishAction.template(template_arg) | ||||||
|     action = Pvariable(action_id, rhs, type=type) |     action = Pvariable(action_id, rhs, type=type) | ||||||
|     for template_ in templatable(config[CONF_STATE], args, std_string): |     template_ = yield templatable(config[CONF_STATE], args, std_string) | ||||||
|         yield None |  | ||||||
|     add(action.set_state(template_)) |     add(action.set_state(template_)) | ||||||
|     yield action |     yield action | ||||||
|   | |||||||
| @@ -483,7 +483,7 @@ if IS_PY2: | |||||||
| def temperature(value): | def temperature(value): | ||||||
|     try: |     try: | ||||||
|         return _temperature_c(value) |         return _temperature_c(value) | ||||||
|     except vol.Invalid as orig_err: |     except vol.Invalid as orig_err:  # noqa | ||||||
|         pass |         pass | ||||||
|  |  | ||||||
|     try: |     try: | ||||||
| @@ -498,7 +498,7 @@ def temperature(value): | |||||||
|     except vol.Invalid: |     except vol.Invalid: | ||||||
|         pass |         pass | ||||||
|  |  | ||||||
|     raise orig_err |     raise orig_err  # noqa | ||||||
|  |  | ||||||
|  |  | ||||||
| _color_temperature_mireds = float_with_unit('Color Temperature', r'(mireds|Mireds)') | _color_temperature_mireds = float_with_unit('Color Temperature', r'(mireds|Mireds)') | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user