brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: continue_on_error lets a Home Assistant script carry on past a failed step

Home Assistant
~/tips/tip-ha-continue-on-error

sequence:

Stops one unreachable device from cancelling the rest of a routine.

A bedtime routine that dies at step one because a smart plug dropped off the network never gets to locking the door. By default a failing step stops the whole run.

Mark the steps that are allowed to fail:

sequence:
  - action: switch.turn_off
    target:
      entity_id: switch.garden_lights
    continue_on_error: true
  - action: lock.lock
    target:
      entity_id: lock.front_door

If the switch call raises an error, the script moves on and locks the door. It works the same in the actions of an automation.

I use judgement about where it goes. The nice to have steps get it: lights, speakers, a status message. A step whose result the later steps depend on should still stop the run, because carrying on would be wrong. Sprinkling it on every action just hides problems until you wonder why nothing happens anymore.

It does not forgive everything. Mistakes in the configuration itself, such as a broken template, still surface as errors, so check the trace when a run behaves oddly. The trace also shows you which step failed even though the sequence continued.

For something important, I’d follow up with a condition that checks the state and send yourself a notification if the door did not report locked. Continuing past an error is fine; never finding out about it is not.

Further reading: Home Assistant script syntax

Going deeper: Guide: Home Assistant backups in Docker, with a failure alert on your phone and a copy off the box

More Home Assistant tips Trust X-Forwarded-For: on Unlimited login attempts: off automation: template: enabled: false All Home Assistant tips (11) All topics

Link