How can I update the email message depending on my tag value?

I have a Flexy that I am currently doing some alarming on. The big thing that we want however is the ability to
change the message in the alarm depending on the value. We don’t want to use the built in alarming as it seems
somewhat limited in terms of altering the messages.

What can I do here or is this even possible?

Hello there!
As I always like to say, with programming anything is possible!

What you are trying to do will in fact require a BASIC script however the script itself is not
a very complex or difficult one.

We will need a two part script to accomplish this.

  1. To monitor the alarm status of the tag and drop into our subroutine.
  2. To get the tag value and update the alarm message and send the email.

For the sake of this example, the tag we are monitoring will be called: Tag

INIT Section: 
ONALARM "Tag", "GOTO MyRoutine"

We then need to add a new script section with the subroutine of MyRoutine/

MyRoutine:
e$ = "Email To"
c$ = "CC"
s$ = "Subject message"
b$ = "This is a body placeholder";

IF(Tag@ < 100) THEN
    b$ = "Tag is currently at: " + STR$ Tag@ + " It is not an immediate alert."
ENDIF

IF(Tag@ > 100) THEN
    b$ = "Tag is currently at: " + STR$ Tag@ + " It is getting borderline critical."
ENDIF 

IF(Tag@ > 150) THEN
    b$ = "Tag is currently at: " + STR$ Tag@ + " It is seriously critical at this point."
ENDIF

SENDMAIL e$, c$, s$, b$ REM - Actually sending the email

I hope this helps!

1 Like

A post was split to a new topic: Email send on different alarms