HA newbie struggling with some automations not working as expected. I have some rules that are using ‘Perform action’ > ‘automation-trigger automation’ and they’re not behaving as expected. When my automation has a step to trigger another automation it does so, but then doesn’t continue with its own remaining steps. The trace just stops at that point. I’m getting nowhere with ChatGPT. It initially said that the called rule had to be completed before the initiating rule would continue to the next step, but then said that wasn’t the case. Example:
The automation(s) just stop without explanation or error after Action 3
In some automations (those without delayed actions steps) I can change the order so that triggering other automations is the last step but that’s a sticking plaster fix. Perhaps I’d be better splitting things out into smaller automations using the KISS approach…
Automations are intended to be triggered by events. If you find yourself needing to launch automations without the events happening, you haven’t thought it through properly.
Some of it could be replaced by scripts but I was trying to avoid conflicts between different automations. I just can’t understand why a rule that calls another rule doesn’t complete itself/halts.
I have a Goodnight automation that I want to turn on 3 rooms lights immediately and then off a couple of minutes later. However I also have motion lighting automations for those same rooms. I was trying to avoid the goodnight automation sending the off command to a light that has (within the two minute window) been triggered by its motion rule, because the off from the goodnight rule will occur regardless. Likewise I don’t want to remove the off command from the goodnight rule either, as then if I don’t trigger the rooms motion rule it’s lights will remain on. For that reason I substituted ‘lights on’ in the Goodnight automation with running the motion rules actions (it seemed a good idea in principle)
Yeah, to be honest I’ve done nothing but think it through. For perspective I’ve just switched from Hubitat to HA after 6 years and done it one hit trying to recreate around a hundred rules. I’d become proficient in Rule Machine there and there are some overlaps in logic but it will be a steep learning curve for me. In Hubitat I used wait for event (something happening), or wait for condition (state). In HA it seems there is no latter without a bit of code while using Wait For Template.
Well… sending an “off” command to a device that is already off makes no difference - nothing happens. I think most people would just send it regardless.
Sorry what I meant was:
Goodnight - turns on bathroom, turns it off after 2 minutes
Bathroom Motion - different rule.
So after pressing goodnight and I walk into the bathroom within that 2 minutes my motion rule triggers and won’t turn the light off until I’ve cleared the room. However the scheduled off from the previous rule will kill the lights briefly at 2 minutes, until I re-trigger the motion rule (resulting in low WAF)
So you’re ex rule machine. How was your WebCore Skill?
Think of HA automations more like WebCore triggers it’ll help.
You need a trigger to do anything. So you’re triggering every time it possibly matters…
You restrict with a condition to shut down the stuff that doesn’t matter.
So if you need a thing that catches after 7p I need over x temp to…
Then you need triggers for the thing changing temp AND when the time changes or it won’t trigger for the time change and youll be sitting there wondering why your thing didn’t thing. They both trigger and the conditions restrict what happens. (this is very much how WebCore worked on both SmartThings and Hubitat, it’s also how HA thinks so get the pattern in your head. )
Automations are basically scripts that trigger. Scripts are basically a series of activities that need to BE TRIGGERED and can contain variables.
So for most of mine (Ex ST WebCore guy btw) trigger file to capture all the relevant goings on for a thing for a concept. Then I send it to a script with all the vars that make the thing I wanted happen. (o er time that led me to a lot of reusable scripts for things and my triggers started centering around one trigger set per room.) you can arrange them how you like. This works for me.
When I went through my old ST automation I broke everything down into what I wanted to happen then figured out the triggers for all that and started there. I put those triggers in an automation and once I had the trigger working reliably I wrote scripts and sent the triggers on thier way.
Last hint forget how Hubitat did stuff. You may have the results on your head of final goal but spend the time learning how ha does it from scratch rather than assuming how Hubitat or ST does it… It save a lot of grief.
Post what you have. Many of us have been through this.
You need to share your YAML to really get help. but the #1 stumble block with people starting and stumbling with triggers is this. Posting it in case it affects you…
That’s two automations, right? Two different events (triggers).
That’s a condition. That is a condition on the turn-off lights automation from above.
You essentially want to turn the lights off at some time but, on the condition that the room is not occupied. What if you turn the lights on and then immediately leave the room? Should the lights stay on until their normal off time?
As for the details of how to determine when motion was triggered in a time window takes some thought – and there’s probably more than one way accomplish that. What you really are saying in your condition is “is the room occupied?” A motion sensor doesn’t do that by itself.
Personally, I might write a template sensor for “occupied” that has a delay_off.
How are you now accomplishing the delay for when the motion sensor turns off? With a template sensor for “occupied” it gets simpler.
If you really need something like this that isn’t the Wait for Template action, the custom integration Spook (a side project of HA’s lead engineer) will add a Wait for Condition action.
FWIW, it is best to avoid waits whenever possible. Every long-term user has their own criteria for how long a wait is acceptable for their circumstances, but most of us keep it well under an hour. If your wait is likely to be longer, you should consider if there is a way use a separate trigger instead.
Thanks everyone for the responses. Plenty for me to think about.
Bookmarked that and will have a good read. Thanks.
I never used WebCore though many Hubitat users favoured it. As clunky as Rule Machine was, when you got to know it, it worked well and I could always figure a way of automating something with it. As much as HA is a struggle for me right now, I appreciate that there as something I can actually see (the YAML) and interpret.
That was something that Hubitats Rule Machine creator (Bruce Ravenel) advised a lot.
Regardless of what the automations are to accomplish, the issue I was trying to understand was why automation 1’s action of triggering automations 2’s actions would halt automation 1. Below is one of the automations where this occurred yesterday. It’s not the Goodnight automation but the issue is the same. The automation has 3 triggers with choices based on those triggers. It triggered at 16:45 and correctly did not complete, as a condition was false. Its second run at Sunset +15 also triggered but did not complete, it went as far as triggering the other automation then stopped without error.
The biggest problem is the wait_for_trigger combined with mode: single…
Every successful branch eventually does this:
- wait_for_trigger:
- trigger: time
at: '23:59:00'
That means if the automation fires at 16:45 or sunset, that automation instance stays alive until 23:59. Because it is mode: single, any later trigger is ignored while that instance is still running
So the 21:30 safety trigger is effectively dead whenever an earlier branch ran successfully.
Home Assistant explicitly treats single as one active run at a time
Fourth trigger with its own conditions (if needed) or a separate automation which simply turns input_boolean.curtain off.
Either way, I’m not sure whether the error reported in the trace is correct. It ran at 21:34, which is 4 minutes later than the cc_late trigger. Maybe there’s another automation (maybe automation.curtain_close_master)which is interfering with this long-running wait, but it’s certainly not this one. If it were, it’s would have failed at 21:30 & left a clearer message in the logs.
Yeah that was intentional. Whichever of the 3 runs is successful turns that boolean on. A subsequent run same day checks that boolean. It ran at 16:45 and exited (sunset not true), it ran again at sunset +15 and completed all actions before the wait, it ran again at 21:30 and exited due to the boolean being on (triggered by the sunset +15 run) as expected.
21:34 is the sunset +15 run stopping. The ‘cc late’ trigger started a run which exited as it should:
This automation is my newb attempt to close the curtains no early than 17:00, no later than 21:30, sunset +15 if between those times. I couldn’t find a better way. The boolean was to turn on first successful run and prevent a subsequent running doing anything. 23:59 turn off of boolean in every run was to reset for following days run.
The 16:45 has occurred again today and completed/exited (boolean off true sunset false), sunset +15 trigger will be in around 45 mins from now
Yes. The targeted automations that close the curtains all have actions ‘if cover open, close cover’ so effectively that boolean probably wasn’t needed - no harm in the rule triggering and doing nothing…Guess I was just trying to prevent anything being processed unnecessarily.
While using trigger IDs and Choose actions is a handy method, all three of your Choose options have essentially the same action sequence, so you really just need to set up the conditions block to effect the right filtering:
As others have mentioned, I would move the action sequence contained in automation.curtain_close_master into a script and have both this automation and that one call that script instead on using automation.trigger.
Thanks for the reply. For sh*ts and giggles I just made 2 very simple rules (turn on light 1 and turn on light 2) and a third (turn on light master) with actions to run those 2 rules, wait a couple of minutes and turn the lights off. It worked exactly as it should so clearly it’s a valid method but there is something in my posted rule that is causing it to fail. I’ll follow the advice to put the actions in a script.