A combo of 2 automation

How can i manage 2 automations in 1 file…
Goal is to set blinds at certain time on specific position > got that working
Code:

alias: Lamellen 46
description: Lamellen 46
triggers:
  - at: "06:00:00"
    trigger: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
conditions: []
actions:
  - metadata: {}
    data:
      position: 28
    target:
      device_id: f61a85f8547c400d148e5da0a720a512
    action: cover.set_cover_position
  - metadata: {}
    data:
      position: 53
    target:
      device_id: db31dc91cd29ddb3943331b60c208bf0
    action: cover.set_cover_position
mode: single

Part 2 > closing when sun goes down on specific position > works too…
Goal is to merge it in just 1 automation…but got stuck on it

Code part 2:

alias: "Lamellen Open "
description: Lamellen Open
triggers:
  - event: sunset
    trigger: sun
conditions: []
actions:
  - metadata: {}
    data:
      position: 4
    target:
      device_id: f61a85f8547c400d148e5da0a720a512
    action: cover.set_cover_position
  - metadata: {}
    data:
      position: 2
    target:
      device_id: db31dc91cd29ddb3943331b60c208bf0
    action: cover.set_cover_position
mode: single

Any idea how to do?
Thank you…

There are many different ways to accomplish this…


Since the action sequences are exactly the same except for the position values, I would probably go a slightly different route and use trigger-attached variables. These are variables that are defined at each individual trigger and only apply when that trigger is what starts the automation.

alias: Lamellen 46
description: Lamellen 46
triggers:
  - at: "06:00:00"
    trigger: time
    variables:
      f6: 28
      db: 53
  - event: sunset
    trigger: sun
    variables:
      f6: 4
      db: 2
conditions: []
actions:
  - metadata: {}
    data:
      position: "{{f6}}"
    target:
      device_id: f61a85f8547c400d148e5da0a720a512
    action: cover.set_cover_position
  - metadata: {}
    data:
      position: "{{db}}"
    target:
      device_id: db31dc91cd29ddb3943331b60c208bf0
    action: cover.set_cover_position
mode: single
2 Likes

Im not sure yet but copied your code
Nothing happend…
But saw an error in tracking

expected int for dictionary value @ data['position']

Is this my bad when i hit preform action for testing?
Thank you sofar Didgeridrew…:+1:

Yes. You can’t manually execute an automation that has variables in its trigger, as they will not be set.

Already learned something…
Thank you too Troon!