The drawback to events is that you lose context. Which is exactly what OP is asking for.
@zombies.aaargh
I have a feeling you’re not going to respond to me about my proposition, so I’ll just provide an example.
Lets take these 2 automations:
Using automation.trigger and passing values between automations
- alias: A
trigger:
- platform: state
entity_id: binary_sensor.a
to: 'on'
condition:
- condition: state
entity_id: light.a
state: 'off'
action:
- service: input_text.set_value
target:
entity_id: input_text.my_message
data:
value: My Message From Automation A
- service: light.turn_on
target:
entity_id: light.a
- service: automation.trigger
target:
entity_id: automation.b
- alias: B
trigger:
- platform: state
entity_id: binary_sensor.b
to: 'on'
condition:
- condition: state
entity_id: light.b
state: 'off'
action:
- service: persistent_notification.create
data:
message: "{{ states('input_text.my_message') }}"
- service: light.turn_on
target:
entity_id: light.b
Automation A triggers automation B and uses an input text (A global variable of sorts) to pass a message from automation A to B before it triggers. When automation B is triggered, only the actions fire. So the trigger and condition in automation B are skipped.
Using Scripts instead of automation.trigger
Now lets look at the equivalent with a script and automations that do the exact same things without a global variable.
- alias: A
trigger:
- platform: state
entity_id: binary_sensor.a
to: 'on'
condition:
- condition: state
entity_id: light.a
state: 'off'
action:
- service: light.turn_on
target:
entity_id: light.a
- service: script.turn_on
target:
entity_id: script.b
data:
variables:
message: My Message From Automation A
b:
sequence:
- service: persistent_notification.create
data:
message: "{{ message }}"
- service: light.turn_on
target:
entity_id: light.b
- alias: B
trigger:
- platform: state
entity_id: binary_sensor.b
to: 'on'
condition:
- condition: state
entity_id: light.b
state: 'off'
action:
- service: script.b
data:
message: My Message From Automation B
These 2 examples are identical. The difference is that your logbook will contain the context for what called the script. You won’t need a global variable. And you can still have your 2 automations. If you don’t need the second automation, great, get rid of it. I’m saying this because you mentioned having dummy triggers for automations, you won’t need those dummy triggers with a script. A script is an automation without triggers. In fact, both automations and scripts run the exact same code. One is not more stable than the other.
script.turn_on will not block automation A from running. When you call a script using the scripts name like this is doing in script.b
, the automation will wait for the script to finish (blocks).