From e05a3f3d4d1e81e9d99a940114420118038b2227 Mon Sep 17 00:00:00 2001 From: JsBergbau <37013344+JsBergbau@users.noreply.github.com> Date: Thu, 25 Mar 2021 10:42:50 +0100 Subject: [PATCH] Added retry and expire setting for Prio 2 messages (#780) --- social/pushover/57-pushover.html | 2 ++ social/pushover/57-pushover.js | 22 ++++++++++++++++++++-- social/pushover/README.md | 2 ++ social/pushover/package.json | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/social/pushover/57-pushover.html b/social/pushover/57-pushover.html index 7f871e22..942f2285 100644 --- a/social/pushover/57-pushover.html +++ b/social/pushover/57-pushover.html @@ -84,6 +84,8 @@

msg.url_title: to add a url title if not already set in the properties

msg.html: set to true or 1 if message is HTML formatted, see the supported tags

msg.sound: set the notification sound, see the available options

+

msg.retry: set retry interval for Emergency priority (2) messages, see details

+

msg.expire: set retry duration for Emergency priority (2) messages, see details

Uses Pushover. See this link for more details.

diff --git a/social/pushover/57-pushover.js b/social/pushover/57-pushover.js index 571e91c2..2a197712 100644 --- a/social/pushover/57-pushover.js +++ b/social/pushover/57-pushover.js @@ -39,9 +39,27 @@ module.exports = function(RED) { var url_title = node.url_title || msg.url_title || null; var html = node.html || msg.html || false; var attachment = msg.attachment || null; + var retry = msg.retry || 30; + var expire = msg.expire || 600; if (isNaN(pri)) {pri=0;} if (pri > 2) {pri = 2;} if (pri < -2) {pri = -2;} + if (isNaN(retry)) { + retry = 30; + node.warn("No valid number for retry found, using default 30s retry interval"); + } + if (isNaN(expire)) { + expire = 600; + node.warn("No valid number for expire time found, using default 600s retry duration"); + } + if (retry < 30) { + retry = 30; + node.warn("Retry interval too low, using minimal 30s retry interval"); + } + if (expire > 10800) { + expire = 10800; + node.warn("Expire time too high, using maximum setting of 10800s (3 hours) retry duration"); + } if (typeof msg.payload === 'undefined') { msg.payload = "(undefined msg.payload)"; } if (typeof(msg.payload) === 'object') { msg.payload = JSON.stringify(msg.payload); @@ -52,8 +70,8 @@ module.exports = function(RED) { message: msg.payload, title: title, priority: pri, - retry: 30, - expire: 600, + retry: retry, + expire: expire, html: html }; if (dev) { pushmsg.device = dev; } diff --git a/social/pushover/README.md b/social/pushover/README.md index 2de64955..55acef20 100644 --- a/social/pushover/README.md +++ b/social/pushover/README.md @@ -26,6 +26,8 @@ Optionally uses `msg.topic` to set the configuration, if not already set in the - `msg.url_title`: to add a url title - `msg.html`: set to true or 1 if message is HTML formatted, see the [supported tags](https://pushover.net/api#html) - `msg.sound`: to set the alert sound, see the [available options](https://pushover.net/api#sounds) + - `msg.retry`: to set retry interval for Emergency priority (2) messages, see [priority](https://pushover.net/api#priority) + - `msg.expire`: to set retry duration for Emergency priority (2) messages, see [priority](https://pushover.net/api#priority) The User-key and API-token are stored in a separate credentials file. diff --git a/social/pushover/package.json b/social/pushover/package.json index 7253739f..d0aa3a3b 100644 --- a/social/pushover/package.json +++ b/social/pushover/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pushover", - "version" : "0.0.23", + "version" : "0.0.24", "description" : "A Node-RED node to send alerts via Pushover", "dependencies" : { "pushover-notifications" : "^1.2.2"