Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95480

Script Stops on Exception

$
0
0

@elbarsal wrote:

I have a notification script that triggers several notifications - Growl, Slack, and Google TTS… the problem is that if one fails, none of the subsequent steps get executed.

The script itself is pretty simple - and it is triggered by a few different automations (doors, leak detectors, etc.).

The simplest “fix” is to put the highest priority notifications first, but that isn’t a fix, and the other notifications are there for a reason. Is there any way to handle the exceptions raised in script execution so that subsequent steps can be executed? The script is provided below - in this example, if the Growl target (my desktop PC) is asleep or off, the other notifications won’t fire.

Script below provided for detail. The message is based on templating in the automations that trigger the actions. Please don’t suggest separating this into separate scripts - this script is called from several different automations, having separate actions for each one would be a bit silly.

'send_notifications':
  alias: Send Notifications
  sequence:

    - condition: template
      value_template: "{{ is_state('input_boolean.send_notifications','on') }}"

    - service: notify.growl
      data_template:
        message: "{{ message }}"

    - service: notify.slack
      data_template:
        message: "{{ message }}"

          
    - condition: template
      value_template: "{{ is_state('input_boolean.speak_notifications','on') }}"

    - service: tts.google_translate_say
      entity_id: media_player.kitchen
      data_template:
        message: "{{ message }}"

Posts: 7

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95480

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>