I have an automation which is launched by two triggers. At the same time this automation can be launched by other automations.
The sequence of actions currently is conditioned (in options) by the mentioned triggers.
I want to add other options that will determine if the automation was launched by other automations AND I want to know which exactly automation caused this automation to run.
Frankly speaking I’ve searched the community to find a workaround for this but with no success. I will really appreciate any help on that!
The trace functionality will show you which trigger started an automation.
In the photo below I have an automation that has 4 triggers (see the red box). The trace shows graphically which one started the automation, and to the right shows the name of the trigger.
To find if another automation called it then you would need to look at those automations OR you could set a trigger that if that other automation is running then to launch that one.
Say Automation A is the one you want to see what triggered it.
In Automation A set a trigger to if Automation B is running then to trigger. In Automation B remove the call for Automation A to run since it is now a trigger for B.
If Automation B has a bunch of conditions and such you may need to put a dummy Automation in place for tracking to do this.
Such as:
In Automation A set a trigger to if Automation C is running then to trigger.
In Automation B change the call for Automation A to run and make it Automation C to run.
Setup Automation C.
Thanks for the trick! It really looks interesting although a bit complicated.
I was wondering if there was another possibility to do that. I’m sure that there must be some information in HA about how or what exactly launched the automation. May be something like a registered event which carries this info?
The solution suggested by @reotto is really nice and I appreciate it.
Basically, instead of creating a dummy automation it would be easier to create a dummy input_boolean which can be change by Automaiton A which in its turn can trigger the Automation B.
I just thought there could be another way to approach it. I think that is why this community exists is to share thoughts, no?
Thanks for your note on manually written automations!
Seems harsh , I think he might have been after some automated ‘else’ type code that could log and identify the additional call for debug and not have to manually inspect
The simplest solution if you can do it is to add the other automations as triggers for the main automation so you can see them.
I do software stuff for a living, and this is a common “misunderstanding.” Many things that are super easy to explain in layman terms, but require multiple pieces to make work.
Here is a very simple example that I have.
I have a string of LED lights on my bar, and I put in a wall switch. It is just a dummy switch, only has power and all the “work” is through HA. I have 4 automations to make it work the way I want.
When switch turns on, turn on the LED strip.
When switch turns off, turn off the LED strip.
When LED strip turns on, turn on the switch.
When LED strip turns off, turn off the switch.
Could I have done some constant polling automation that runs constantly for status of each and then update the other? Sure, but it took me 5 minutes to write those automations and they are simple and effective.
Moral of the story: Break your automations into simple pieces, create them…and if you get good later then you can try to combine them.