Skip to content

Commit

Permalink
add sms_changed to pushbullet handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Conway-Jones committed Aug 24, 2020
1 parent 34262e2 commit ea72954
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions social/pushbullet/57-pushbullet.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -129,15 +127,15 @@ module.exports = function(RED) {
if (!closing) {
tout = setTimeout(function() {
stream.connect();
},15000);
}, 15000);
}
});
stream.on('error', function(err) {
self.emitter.emit('stream_error', err);
if (!closing) {
tout = setTimeout(function() {
stream.connect();
},15000);
}, 15000);
}
});
stream.connect();
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -327,7 +328,7 @@ module.exports = function(RED) {
try {
this.deviceid = this.credentials.deviceid;
}
catch(err) {}
catch(err) { }
}

if (configNode) {
Expand Down
2 changes: 1 addition & 1 deletion social/pushbullet/package.json
@@ -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",
Expand Down

0 comments on commit ea72954

Please sign in to comment.