mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 06:33:51 +00:00
Allow simpler automation syntax
This commit is contained in:
@@ -13,9 +13,9 @@ PLATFORM_SCHEMA = cv.nameable(cover.COVER_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTemplateCover),
|
||||
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
||||
vol.Optional(CONF_OPTIMISTIC): cv.boolean,
|
||||
vol.Optional(CONF_OPEN_ACTION): automation.ACTIONS_SCHEMA,
|
||||
vol.Optional(CONF_CLOSE_ACTION): automation.ACTIONS_SCHEMA,
|
||||
vol.Optional(CONF_STOP_ACTION): automation.ACTIONS_SCHEMA,
|
||||
vol.Optional(CONF_OPEN_ACTION): automation.validate_automation(),
|
||||
vol.Optional(CONF_CLOSE_ACTION): automation.validate_automation(),
|
||||
vol.Optional(CONF_STOP_ACTION): automation.validate_automation(),
|
||||
}), cv.has_at_least_one_key(CONF_LAMBDA, CONF_OPTIMISTIC))
|
||||
|
||||
|
||||
@@ -30,20 +30,14 @@ def to_code(config):
|
||||
yield
|
||||
add(make.Ptemplate_.set_state_lambda(template_))
|
||||
if CONF_OPEN_ACTION in config:
|
||||
actions = None
|
||||
for actions in automation.build_actions(config[CONF_OPEN_ACTION], NoArg):
|
||||
yield
|
||||
add(make.Ptemplate_.add_open_actions(actions))
|
||||
automation.build_automation(make.Ptemplate_.get_open_trigger(), NoArg,
|
||||
config[CONF_OPEN_ACTION])
|
||||
if CONF_CLOSE_ACTION in config:
|
||||
actions = None
|
||||
for actions in automation.build_actions(config[CONF_CLOSE_ACTION], NoArg):
|
||||
yield
|
||||
add(make.Ptemplate_.add_close_actions(actions))
|
||||
automation.build_automation(make.Ptemplate_.get_close_trigger(), NoArg,
|
||||
config[CONF_CLOSE_ACTION])
|
||||
if CONF_STOP_ACTION in config:
|
||||
actions = None
|
||||
for actions in automation.build_actions(config[CONF_STOP_ACTION], NoArg):
|
||||
yield
|
||||
add(make.Ptemplate_.add_stop_actions(actions))
|
||||
automation.build_automation(make.Ptemplate_.get_stop_trigger(), NoArg,
|
||||
config[CONF_STOP_ACTION])
|
||||
if CONF_OPTIMISTIC in config:
|
||||
add(make.Ptemplate_.set_optimistic(config[CONF_OPTIMISTIC]))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user