add sms_changed to pushbullet handler

This commit is contained in:
Dave Conway-Jones 2020-08-24 12:12:32 +01:00
parent 34262e2fb0
commit ea729546d4
No known key found for this signature in database
GPG Key ID: 302A6725C594817F
2 changed files with 10 additions and 9 deletions

View File

@ -3,9 +3,7 @@ module.exports = function(RED) {
"use strict"; "use strict";
var PushBullet = require('pushbullet'); var PushBullet = require('pushbullet');
var fs = require('fs'); var fs = require('fs');
var util = require('util');
var when = require('when'); var when = require('when');
var nodefn = require('when/node');
var EventEmitter = require('events').EventEmitter; var EventEmitter = require('events').EventEmitter;
function onError(err, node) { function onError(err, node) {
@ -129,7 +127,7 @@ module.exports = function(RED) {
if (!closing) { if (!closing) {
tout = setTimeout(function() { tout = setTimeout(function() {
stream.connect(); stream.connect();
},15000); }, 15000);
} }
}); });
stream.on('error', function(err) { stream.on('error', function(err) {
@ -137,7 +135,7 @@ module.exports = function(RED) {
if (!closing) { if (!closing) {
tout = setTimeout(function() { tout = setTimeout(function() {
stream.connect(); stream.connect();
},15000); }, 15000);
} }
}); });
stream.connect(); stream.connect();
@ -229,10 +227,14 @@ module.exports = function(RED) {
msg.payload = incoming.body; msg.payload = incoming.body;
} }
else if (incoming.type === 'dismissal') { else if (incoming.type === 'dismissal') {
msg.topic = "dismissal";
msg.topic = "Push dismissed"; msg.topic = "Push dismissed";
msg.payload = incoming.iden; msg.payload = incoming.iden;
} }
else if (incoming.type === 'sms_changed') {
msg.topic = "SMS: "+ incoming.notifications[0].title;
msg.payload = incoming.notifications[0].body;
msg.message = incoming;
}
else { else {
this.error("unknown push type: " + incoming.type + " content: " + JSON.stringify(incoming)); this.error("unknown push type: " + incoming.type + " content: " + JSON.stringify(incoming));
return; return;
@ -257,8 +259,7 @@ module.exports = function(RED) {
try { try {
pushkeys = RED.settings.pushbullet || require(process.env.NODE_RED_HOME+"/../pushkey.js"); pushkeys = RED.settings.pushbullet || require(process.env.NODE_RED_HOME+"/../pushkey.js");
} }
catch(err) { catch(err) { }
}
var cred = RED.nodes.getCredentials(n.id); var cred = RED.nodes.getCredentials(n.id);
// get old apikey // get old apikey
@ -327,7 +328,7 @@ module.exports = function(RED) {
try { try {
this.deviceid = this.credentials.deviceid; this.deviceid = this.credentials.deviceid;
} }
catch(err) {} catch(err) { }
} }
if (configNode) { if (configNode) {

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-pushbullet", "name" : "node-red-node-pushbullet",
"version" : "0.0.14", "version" : "0.0.15",
"description" : "A Node-RED node to send alerts via Pushbullet", "description" : "A Node-RED node to send alerts via Pushbullet",
"dependencies" : { "dependencies" : {
"pushbullet": "^2.4.0", "pushbullet": "^2.4.0",