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

View File

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