I’ve got automations which use trigger IDs and then choose and triggered by, so that multiple triggers selectively run bits of the automations.
Is there any way to trigger one automation from another, passing the ID?
To give an example and some context, I have an automation that turns various things on/off when I feed the fish in my aquarium.
It’s initially triggered by the time (with one ID), and as long as I’m at home, sends a notification to my phone and gives me options to feed or dismiss (with other IDs).
If I’m out at the usual trigger time though, I’d like my ‘get home’ automation to trigger the feeding automation with the ID that sends me the notification.
I’m aware it might make sense to split things out into scripts, but that’d mean re-thinking some (complex, at least for me) automations and isn’t what I’m hoping to do.
You can’t overwrite the trigger variable, so you may need to make some modifications to the automation. But, different triggers can share the same ID, so it may only be a very small change… you’ll need to share the automations if you need more specific guidance.
I haven’t been lucky having a quick play, so I guess I’ve got some reading to do
edit:
I would have shared an example automation, but tbh they’re getting a bit big so I thought it’d just complicate things. Thanks for not taking the ‘yaml or it’s impossible to help’ approach.
and now I’ve less reading since you kindly added links
Also check out actionable notifications in the companion app’s docs. You can pass custom payloads. It relates to D’s suggestion of events, and this mechanism uses events.
Pretty sure I’ve got it doing what I want. When I manually run the action that creates the event, the corresponding trigger fires. I’m yet to use it while actually out and then getting home, that’ll be the proper test.
If I’m out while my washing finishes, the fish need feeding, or past my usual bedtime, all of those automations should give me a prod as I get back home (and then remind be every 30 mins until I do or dismiss them)
It feels like I’m missing something though, as I couldn’t get the trigger to fire when using any event data. It does when I only set a unique event type.
Should setting only a unique event type be OK, or is it likely to cause trouble somehow?
There isnt anything set other then type in the example here, so I’m probably over-thinking it just because the field’s there.
Current action:
event: Ask fish feeding
event_data: {}
Current trigger:
trigger: event
event_type: Ask fish feeding
id: time to feed
It’s fine to do it that way, but you should be able to include event data.
For this kind of thing I usually use a more general custom event type, then include a more specific value in the event data. I almost always include the targets’ entity IDs in the event data, so I have a clue where else I may need to look if something isn’t working as expected.
id: time to feed
trigger: event
event_type: custom_automation_trigger
event_data:
automation: Ask fish feeding
It’s not necessary, but it does make debugging a bit easier if you have one event type to listen for in the Event tool that covers all your custom trigger events.
Cracked it before I’d read your last message, then saw you kindly spelled it out.
The effect seems to be the same as the ones above, but these more closely match how the actionable notifications to my mobile work.
Action:
event: custom event
event_data:
action: Ask fish feeding
Trigger:
trigger: event
event_type: custom event
id: time to feed
event_data:
action: Ask fish feeding
I notice the different labels we’ve used though, action vs automation. I just copied what I had in my actionable notifications.
Are we free to use whatever unique label makes sense, as long as the action and trigger match?
This fish feeding automation’s got 11 triggers and 7 different IDs used in a choose now, for turning pumps, CO2 and heaters on and off. I might have over done it a little
In case anyone’s really bored (but I dont recommend it tbh):
I can’t think of any quick wins to simplify it though, there’s just various ways to trigger it and it does stuff in different stages. I’d rather it all be in the one automation instead of spread over a few.