cleanup duplicate code

This commit is contained in:
J. Nick Koston
2026-02-04 10:16:07 +01:00
parent 21815ddfa0
commit 0714c5b7b8
+4 -10
View File
@@ -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)