From 8e4dc790d96e7a52e42adeb4423b8b8395cad562 Mon Sep 17 00:00:00 2001 From: Mason10198 <31994327+Mason10198@users.noreply.github.com> Date: Wed, 5 Jul 2023 18:20:39 -0500 Subject: [PATCH] Ability to use {alert_title} variable in mappings --- SkywarnPlus.py | 1 + config.yaml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/SkywarnPlus.py b/SkywarnPlus.py index e1b307e..37f2dab 100644 --- a/SkywarnPlus.py +++ b/SkywarnPlus.py @@ -905,6 +905,7 @@ def alertScript(alerts): if mapping.get("Type") == "BASH": logger.debug('Mapping type is "BASH"') for cmd in commands: + cmd = cmd.format(alert_title=alert) # Replace placeholder with alert title logger.info("AlertScript: Executing BASH command: %s", cmd) subprocess.run(cmd, shell=True) elif mapping.get("Type") == "DTMF": diff --git a/config.yaml b/config.yaml index fd0d8d1..fc55e1f 100644 --- a/config.yaml +++ b/config.yaml @@ -327,10 +327,12 @@ AlertScript: # This is an example entry that will automatically execute SkyDescribe and # announce the full details of a Tornado Warning when it is detected. + # The placeholder '{alert_title}' will be replaced with the title of the alert + # when AlertScript executes the command. - Type: BASH Commands: - - '/usr/local/bin/SkywarnPlus/SkyDescribe.py "Tornado Warning"' + - '/usr/local/bin/SkywarnPlus/SkyDescribe.py "{alert_title}"' Triggers: - Tornado Warning