Hi,
i want to send the notification as soon as i clear the alarm manually from the device management through EPL,
please give code snippet or solution for this.
Thank yoo
Hi,
i want to send the notification as soon as i clear the alarm manually from the device management through EPL,
please give code snippet or solution for this.
Thank yoo
@jkpatil1010 Below find the sample Code snippet
action onload() {(){
monitor.subscribe(Alarm.SUBSCRIBE_CHANNEL));
on all Alarm(type="c8y_TemperatureThresholdExceedAlarm", status="CLEARED") as ar {
log "Received Alarm: "+ar.toString() at INFO;
sendEmail(ar);
}
}
action sendEmail(Alarm alarm) {
string subject := alarm.text;
string text := alarm.type;
string emailTo := "noreply@test.com";
sequence<string> emailReceivers := ["vachaspati.diwevedi@test.com","abc@test.com"];
sequence<string> emailCC := [];
string emailBCC := "";
send SendEmail(
subject,
text,
emailTo,
emailReceivers,
emailCC,
emailBCC,
new dictionary<string,string>
) to SendEmail.SEND_CHANNEL);
log "Email Sent" at INFO;
}
Thank you,
Hi @Vachaspati_Diwevedi2 ,
can you please also share , code snippet to send sms as well,
will be helpfull.
Thank you.
@jkpatil1010 , Below find the code snippet for send SMS, Always put a check to have at lease one received before calling this action for triggering SMS
/* The list of phone numbers to which the SMS is to be sent. */
sequence<string> smsReceivers := ["+919100000001"];
/** Called whenever a new matching alarm is received
* and an SMS has to be sent out.
* @param alarm The alarm giving rise to this SMS.
*/
action sendSMS(Alarm alarm) {
string text := Util.ensureSMSLength(
Util.replacePlaceholders(smsMessage, alarm));
send SendSMS(text, smsReceivers, alarm.source,
new dictionary<string,string>) to SendSMS.SEND_CHANNEL;
}
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.