mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Add device target bailty to pushover node
This commit is contained in:
@@ -22,6 +22,7 @@ module.exports = function(RED) {
|
||||
function PushoverNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
this.title = n.title;
|
||||
this.device = n.device;
|
||||
this.priority = n.priority;
|
||||
var credentials = this.credentials;
|
||||
if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; }
|
||||
@@ -43,6 +44,7 @@ module.exports = function(RED) {
|
||||
this.on("input",function(msg) {
|
||||
var titl = this.title || msg.topic || "Node-RED";
|
||||
var pri = this.priority || msg.priority || 0;
|
||||
var dev = this.device || msg.device;
|
||||
if (isNaN(pri)) {pri=0;}
|
||||
if (pri > 2) {pri = 2;}
|
||||
if (pri < -2) {pri = -2;}
|
||||
@@ -58,7 +60,8 @@ module.exports = function(RED) {
|
||||
retry: 30,
|
||||
expire: 600
|
||||
};
|
||||
//console.log("Sending",pushmsg);
|
||||
if (dev) { pushmsg.device = dev; }
|
||||
//node.log("Sending "+JSON.stringify(pushmsg));
|
||||
pusher.send( pushmsg, function(err, response) {
|
||||
if (err) { node.error("Pushover Error: "+err); }
|
||||
//console.log(response);
|
||||
|
||||
Reference in New Issue
Block a user