"Continue on error" not working

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:

@loic69
I found in my Script it had to be done as a list item, but in automations it was not.
I think it depends how your script or automation is nested sometimes, but it definitely is still working fine.
Make sure you have it in your Action / Service call line
This format should work in an automation, obviously replacing the lines with correct HA commands.

- alias: xxxxx
  action: xxxxxx
  continue_on_error: true

I have the same issue. In my “leaving apartment script” I shutdown my Magic Mirror Pi using a function of the Magic Mirror custom integration.

  - device_id: xxxxxxx
    domain: button
    entity_id: button.bathroom_magicmirror_shutdown_host
    type: press
    continue_on_error: true

Whenever that is executed it throws an error Error: Cannot connect to host 192.xxx.xxx.xxx:8080 ssl:default [Connect call failed (‘192.xxx.xxx.xxx’, 8080)] despite actually shutting down the host just fine. I guess somehow it shuts down and looses connection right afterwards and somehow the script gets a hiccup.

Due to that error my script gets stuck and according to the trace none of the fillowing steps get executed “This step was not executed and so no further trace information is available.”

image

I tried adding the continue_on_error: true as you can see in the code above. However it does not do anything and the script stops nonetheless.

Or when it gets a connection disconnected.: Even if its in a parallell block.

  - action: notify.notify
    metadata: {}
    data:
      title: '{{ title if title != "" else " "}}'
      message: '{{ message if message != "" else " "}}'
    alias: Global
  - alias: Pushbullet
    choose:
      - conditions:
          - condition: template
            value_template: '{{ pushbullet }}'
        sequence:
          - data:
              title: '{{ title if title != "" else " "}}'
              message: '{{ message if message != "" else " "}}'
            action: notify.pushbullet
            continue_on_error: true
2024-10-27 14:25:16.524 ERROR (MainThread) [homeassistant.components.script.notifying_multiple_devices] Notifying multiple devices: Parallel action at step 1: parallel 7: Pushbullet: choice 1: Error executing script. Unexpected error for call_service at pos 1: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 716, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 468, in _make_request
    six.raise_from(e, None)
  File "", line 3, in raise_from
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 463, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 1428, in getresponse
    response.begin()
  File "/usr/local/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 802, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 552, in increment
    raise six.reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 716, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 468, in _make_request
    six.raise_from(e, None)
  File "", line 3, in raise_from
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 463, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 1428, in getresponse
    response.begin()
  File "/usr/local/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 273, in _async_notify_message_service
    await self.async_send_message(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 251, in async_send_message
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/pushbullet/notify.py", line 77, in send_message
    self._push_data(message, title, data, self.pushbullet)
  File "/usr/src/homeassistant/homeassistant/components/pushbullet/notify.py", line 157, in _push_data
    pusher.push_note(**kwargs)
  File "/usr/local/lib/python3.12/site-packages/pushbullet/pushbullet.py", line 286, in push_note
    return self._push(data)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pushbullet/pushbullet.py", line 304, in _push
    r = self._session.post(self.PUSH_URL, data=json.dumps(data))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 682, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2024-10-27 14:25:16.682 DEBUG (SyncWorker_13) [homeassistant.components.pushbullet.notify] Sent notification to self
2024-10-27 14:25:16.691 ERROR (MainThread) [homeassistant.components.script.notifying_multiple_devices] Notifying multiple devices: Parallel action at step 1: parallel 7: Error executing script. Unexpected error for choose at pos 1: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 716, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 468, in _make_request
    six.raise_from(e, None)
  File "", line 3, in raise_from
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 463, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 1428, in getresponse
    response.begin()
  File "/usr/local/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 802, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 552, in increment
    raise six.reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 716, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 468, in _make_request
    six.raise_from(e, None)
  File "", line 3, in raise_from
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 463, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 1428, in getresponse
    response.begin()
  File "/usr/local/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1048, in _async_choose_step
    await self._async_run_script(script)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1268, in _async_run_script
    result = await self._async_run_long_action(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1795, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 580, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 273, in _async_notify_message_service
    await self.async_send_message(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 251, in async_send_message
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/pushbullet/notify.py", line 77, in send_message
    self._push_data(message, title, data, self.pushbullet)
  File "/usr/src/homeassistant/homeassistant/components/pushbullet/notify.py", line 157, in _push_data
    pusher.push_note(**kwargs)
  File "/usr/local/lib/python3.12/site-packages/pushbullet/pushbullet.py", line 286, in push_note
    return self._push(data)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pushbullet/pushbullet.py", line 304, in _push
    r = self._session.post(self.PUSH_URL, data=json.dumps(data))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 682, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))