Tadies
(Tadies)
October 17, 2025, 5:37am
1
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…
An automation can have multiple triggers and action logic can be branched using If/Then or Choose actions.
Here’s an example from the Community Cookbook
That example uses templating with trigger IDs, but it could be done with If/Then with Trigger conditions as follows:
description: "Turn on lights at sunset and off at sunrise"
trigger:
- id: 'on'
platform: sun
event: sunset
- id: 'off'
platform: sun
event: sunrise
action:
- if:
- condition: trigger
id: …
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
Tadies
(Tadies)
October 17, 2025, 11:12am
3
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…
Troon
(Troon)
October 17, 2025, 11:28am
4
Yes. You can’t manually execute an automation that has variables in its trigger, as they will not be set.
Tadies
(Tadies)
October 17, 2025, 11:41am
5
Already learned something…
Thank you too Troon!