"Continue on error" not working

Hi everyone,

I currently have a script that perform a series of task to “close” the house when leaving, as shutting down all the lights, locking the door and activating the alarm. Sometimes some of these calls fail and I leave home half open (mostly nuki lock). I was really happy reading in the last update about the introduction of the “continue on error” function HERE and applied it to the relevant actions, for example:

  - continue_on_error: true
    service: lock.lock
    data: {}
    entity_id: lock.casa

Unfortunately nothing was solved as a failed call to the smart lock still stops my whole script without any notification… Can someone help?

2 Likes

Did you try to add, e.g., a notification after that part to confirm the script is actually stopping there?

I know the script stops there from the trace, I just cannot post an example because at every reboot I lose the script debug logs.
The Nuki integration throws an error and it doesn’t continue…

Might be worth opening an issue vs. the Nuki integration.
Maybe it fails in a way that is not understood by HA…

I did it too, let’s see if someone agree or I missed something

Encountered the same issue.

Stopped because an error was encountered at June 14, 2022, 9:13:51 AM (runtime: 1.35 seconds)

Error: Invalid stok value, Response: {“error_code”: -40401, “result”: {“data”: {“code”: -40407, “encrypt_type”: [“1”, “2”], “key”: “REDACTED”, “nonce”: “REDACTED”}}}

But I have this in YAML:

service: tapo_control.set_led_mode
data:
led_mode: ‘on’
target:
device_id: REDACTED
continue_on_error: true

Hi,

I also have the same kind of problem.
The action fails with an error but the automation does not continue.


image

I also tried to add continue_on_error: true on the choose but it did not change anything.

I had a look at the code, it states here:

        # Only Home Assistant errors can be ignored.
        if not isinstance(exception, exceptions.HomeAssistantError):
            raise exception

I guess that the integrations may not raise an exception based on HomeAssistantError thus the exception is raised the action does not continue.

The exception type is ConnectionError in my case:

File "/config/custom_components/nuki_ng/nuki.py", line 38, in async_json

raise ConnectionError(f"Http response: {response.status_code}")

ConnectionError: Http response: 503

It looks like it works if I comment out the latest if.

If one wants to try, log in HA docker (through Portainer or 22222 Dev Shell):

# docker exec -it homeassistant /bin/bash
bash-5.1# vi /usr/src/homeassistant/homeassistant/helpers/script.py

Line 493:

# Only Home Assistant errors can be ignored.
        #if not isinstance(exception, exceptions.HomeAssistantError):
        #    raise exception

Restart HA

1 Like

Hi,

For me also is not working with
Error: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=blablas: Device not found, reason: None

I’m not familiar with Docker so I search through Google - 22222 Dev Shell and find this add on:

May I ask if I will install that one I can connect and edit above lines?
If yes, how to ssh? Like my HA IP and 22222 port via Putty?

Thanks

You still need to know how to generate SSH key pair, use a terminal and vi.
I don’t recommend fiddling with the code if you are not completely sure about what you are doing. Any wrong change can brick your HA and any change will be lost after updating HA anyway.

It’s not my first time messing with the code.
I’m familiar with the SSH and SSH keys but I’m not sure about this part of the configuration. I don’t have any interface for entering the key.

Hey, any luck with this yet? I have exactly the same problem with the error 503 with the Nuki lock and wanted to use continue_on_error but I’m a bit hesitant if I read your post…

I also have this error. It is so frustrating.

I have an automation that does things when i leave home, one of them is to turn off the TV:

The problem is that the TV goes from available to unavailable like every minute (yeah, philipls suck and i don’t want to talk about it), so the automation is stopped when this command is performed and the TV happens to be unavailable:

As you can see from the first image, the continue on error is set to true, so i really don’t see why the automation still stops.
And really, it doesn’t matter why the TV becomes unavailable, if there is such an option in the automation it MUST work

Guys, does this “continue on error” works for you in scripts? If i put it in i get an error when reloading scripts (extra keys not allowed) and script is disabled. Where exactly do i put it?
My script:

vklop_radia_pavle:
  alias: "Vklop bujenja"
  mode: restart
   continue_on_error: true  #( if i put it here i get an error)
  sequence:
      # - continue_on_error: true  #( if i put it here i also get an error)
    - service: script.internetni_radio_turn_on
    - service: browser_mod.navigate
      data:
        path: /pavle-soba/0
        browser_id:
          - pavle-tab-s2
    - delay:
        seconds: 1
    - if:
        - condition: not
          conditions:
            - condition: state
              entity_id: media_player.pavle_internetni_radio
              state: "playing"
      then:
        - service: rest_command.kiosk_pavlesoba_oled_alarm
    # - service: rest_command.kiosk_pavlesoba_oled_alarm
    - delay:
        seconds: 50
    - service: button.press
      data:
        entity_id: button.pavle_dimmer_min
    - delay:
        seconds: 20
    - service: light.turn_on
      data:
        entity_id: light.pavle_dimmer
        brightness_pct: 100
        transition: 60
    - delay:
        seconds: 20
    - service: rest_command.kiosk_pavle_rolete_on
    - delay:
        seconds: 30
    - service: rest_command.kiosk_pavlesoba_oled_volume_100
    - service: rest_command.kiosk_pavlesoba_oled_vstajanje
    - condition: state
      entity_id: input_boolean.pavle_dvig_rolete_sluzba
      state: "on"
    - service: cover.open_cover
      entity_id: cover.pavle_roleta

You have to put it in each individual service call like in the OP’s initial example.
+1 for the idea of being able to apply it to the entire script, though.

2 Likes

Yes, +1 me too. This would be great.

2 Likes

Aha… ok, in that case i see what i did wrong - i put a dash in front of sentence (my second grayed out line)… silly mistake.
Thanks! I agree, it would be nice to set this for entire script…
but, for now i temporarily solved my problem with “if - then” command (if entitiy is not unavailable…)

The main problem is that my internet radio sometimes goes offline for no reason, and sincer i use that script for alarm clock it’s essential that script continues to run even in that case.

continue_on_error not working for me.
I have a notify.alexa_media which is sometimes unvailable because issues with HACS Alexa Media Player.

When I add continue_on_error: true, the error is always log in HA notification and my automation stops…
Is there a way to bypass this ?
IS this an issue of HA ?

1 Like

+1 me too.

As much as it would be nice to have it for an entire script or automation, you will usually find in your trace only one or maybe two device(s) causing the error, so isolating the device(s) is kind of a troubleshooting step.
Ultimately, the best way would be to work out why it throws the error and solve that issue.
Unfortunately some devices, my SOMA blind motors are one, will randomly throw errors even if they are setup perfectly ( The joys of Bluetooth in this case ). In these cases, just putting the continue on error on the service call for the troublesome device, but not on others, would be the best way to do it.
I would not really rely on using continue on error as a blanket fix on an entire automation or script just because of one or two troublesome device(s), and I think that was the thinking from the Home Assistant team when they made this a per action/service call feature. In theory, you shouldn’t get errors :slight_smile: