ScottS
April 15, 2022, 5:37am
1
I see this isn’t possible in the Automation UI, but wondering about doing this in yaml code?
An alternative I guess would be an Automation run multiple scripts?
Here’s an existing Automation I would like to add to…
alias: Computer - Status-Locked
description: ''
trigger:
- platform: mqtt
topic: iotlink/home/haf922/windows-monitor/status
payload: SessionLock
value_template: '{{ states.sensor.my_computer_session_status.state }}'
condition: []
action:
- type: turn_off
device_id: 49dc7efaec0941a1a9a0470e8424c3f7
entity_id: light.office_desk_lamp
domain: light
- service: rest_command.computer_locked
data: {}
mode: single
2 Likes
You can it via the UI. There is a “choose” action type.
1 Like
ScottS
April 15, 2022, 1:53pm
3
Although that does allow multiple Actions, they can’t/won’t all fire… It’s an either/or. At least that’s what I’ve found.
What I’m looking to do… Based on a Trigger, fire Action 1 w/ a Condition, fire Action 2 w/ a different Condition, etc.
Any reason you wouldn’t want to make it separate automations?
ScottS
April 15, 2022, 3:54pm
5
No reason, other than make it more streamlined. Trigger on an event once, instead of multiple triggers for the same event.
I’m so used to using my beloved Tasker Android app
1 Like
ScottS:
they can’t/won’t all fire… It’s an either/or…
… Based on a Trigger, fire Action 1 w/ a Condition, fire Action 2 w/ a different Condition, etc.
Use multiple Choose actions…
Using multiple Choose actions allows the automation to evaluate each option (or group of options) and execute their sequences of actions independently:
action:
- choose:
- alias: Option 1
conditions:
- condition: 1
sequence:
- action 1
- choose:
- alias: Option 2
conditions:
- condition: 2
sequence:
- action 2
default: []
2 Likes
ScottS
April 15, 2022, 5:07pm
7
That’s not how I find it… I find that it’s a ‘choose’.
Assume the below test Automation is set up correctly, I only receive TEST 1 from Option 1, Option 2 is ignored. What I want is both Option 1 & Option 2 fire, sending TEST 1 & TEST 2 messages.
alias: New Automation
description: ''
trigger:
- platform: device
type: changed_states
device_id: 8e020108f0f9a30ec6e30d6d16c53698
entity_id: switch.study_light
domain: switch
condition: []
action:
- choose:
- conditions:
- condition: sun
before: sunset
after: sunrise
sequence:
- service: notify.mobile_app_sas22
data:
message: TEST 1
- type: toggle
device_id: 49dc7efaec0941a1a9a0470e8424c3f7
entity_id: light.office_desk_lamp
domain: light
- conditions:
- condition: sun
before: sunset
after: sunrise
sequence:
- service: notify.mobile_app_sas22
data:
message: TEST 2
- type: toggle
device_id: 49dc7efaec0941a1a9a0470e8424c3f7
entity_id: light.office_desk_lamp
domain: light
default: []
mode: single
Yes, that is how it works if you only use one Choose action… if you use multiple Choose actions (not just multiple options within a single Choose) they are evaluated and executed independently.
alias: New Automation
description: ''
trigger:
- platform: device
type: changed_states
device_id: 8e020108f0f9a30ec6e30d6d16c53698
entity_id: switch.study_light
domain: switch
condition: []
action:
- choose:
- conditions:
- condition: sun
before: sunset
after: sunrise
sequence:
- service: notify.mobile_app_sas22
data:
message: TEST 1
- type: toggle
device_id: 49dc7efaec0941a1a9a0470e8424c3f7
entity_id: light.office_desk_lamp
domain: light
default: []
- choose:
- conditions:
- condition: sun
before: sunset
after: sunrise
sequence:
- service: notify.mobile_app_sas22
data:
message: TEST 2
- type: toggle
device_id: 49dc7efaec0941a1a9a0470e8424c3f7
entity_id: light.office_desk_lamp
domain: light
default: []
mode: single
ScottS
April 15, 2022, 5:15pm
9
Ah, thank you, I get it now!
1 Like
I have setup automatisation with 6-7 choose actions and 15 triggers. Now for some fine tuning i need to know which Trigger fired which Choose and in Logbook there is only name of the Authomatisation and what it has thone e.g. Light Livingroom ON. But I have more then one scenario in Choose which will triger same event. Is there any ID to be put for every Choose so the Logbook has more info?
Why are you using the Logbook instead of the automation’s debug trace?
ScottS
April 12, 2024, 6:08am
12
Just go into the Automation…
Settings/Automations
Select the Automation
3-bar menu/Traces
This will show you what triggered it, when, etc.