Add option to Automation for how to respond to exception

There are a couple of posts on this but all seem to address the cause, not handling the exception.

Use case: I have an integration that throws random exceptions but ultimately works. The integration developer is unresponsive. When the integration doesn’t handle the exception my whole automation fails as subsequent steps don’t occur.

Suggestion: Add option to automations “What to do on error” with options “Stop Execution”, “Continue to next step”

You can already do this now by putting the likely to fail actions in a script and calling it using the script.turn_on service rather than directly:

https://www.home-assistant.io/integrations/script/#waiting-for-script-to-complete

Ah, hadn’t seen/processed this feature. I’ll go this route as it’s a nice work-around, but still ultimately a work-around.

Not really. Having a faulty integration is the problem that should be fixed.

This is implemented in:

Should be part of Home Assistant 2022.5

2 Likes

Nice. Would it be possible to apply it to all actions in a sequence rather than having to specify it for each one?

Yes, but you have to wrap it in another action (e.g. any action that accepts another sequence) and next you can set it on that one. Please note, that in that case, that subsequence will stop half way if one of those action nodes fails)

“Ignore” an error is one element from the set of possible ways to handle and error, so I’d argue that there’s still a case for implementing OP’s suggestion. For example, the user might want to be alerted that the automation failed.

I ran into this need when I had an automation that snapshotted the states of a bunch of my lights when I left my house (and then turned them off) so that I could restore the scene when I returned. Problem was: the entities that the scene records are manually entered, and one of my entity names got changed.

This broke the whole leaving automation. HA was never actually turning my lights off after I left and restoring them when I returned. They were just left on the whole time. So, it would have been nice if there were some kind of on-error action (like pushing a notification to a voice assistant or my phone).

It might also be worthwhile to allow for a more global error handler, like a notification of any script fails, or if any automation fails, to save people from having to create the same error handler for each automation.

As I think about this more, since this info is only of use to the person who is configuring HA, maybe it could just be in the Developer Tools, where we could set a service call to make and then checkboxes for which errors types (scripts, automations, Zwave, Zigbee, etc) we want to be notified about.

Would this be applicable to a TTS script to handle devices that aren’t available?
If so, how?
I tried adding “continue_on_error: true” to the script but it still wouldn’t work when a device wasn’t available.

You can go even further and react to any error however you like.