Add device target bailty to pushover node

This commit is contained in:
Dave Conway-Jones
2015-08-25 21:04:54 +01:00
parent 834115907c
commit 4e6f76cc1d
4 changed files with 19 additions and 8 deletions

View File

@@ -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);