mirror of
https://github.com/esphome/esphome.git
synced 2026-09-21 12:08:38 +00:00
cleanup duplicate code
This commit is contained in:
@@ -197,16 +197,10 @@ async def setup_cover_core_(var, config):
|
||||
for conf in on_opens:
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
await automation.build_automation(trigger, [], conf)
|
||||
for on_op in OPERATIONS:
|
||||
if triggers := config.get(on_op):
|
||||
for conf in triggers:
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
await automation.build_automation(trigger, [], conf)
|
||||
for on_state in [CONF_ON_OPENED, CONF_ON_CLOSED]:
|
||||
if triggers := config.get(on_state):
|
||||
for conf in triggers:
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
await automation.build_automation(trigger, [], conf)
|
||||
for trigger_conf in (*OPERATIONS, CONF_ON_OPENED, CONF_ON_CLOSED):
|
||||
for conf in config.get(trigger_conf, []):
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
await automation.build_automation(trigger, [], conf)
|
||||
|
||||
if (mqtt_id := config.get(CONF_MQTT_ID)) is not None:
|
||||
mqtt_ = cg.new_Pvariable(mqtt_id, var)
|
||||
|
||||
Reference in New Issue
Block a user