pushbullet.js (929B)
1 /** 2 * Pushbullet Module 3 * 4 * @module Main 5 * @submodule pushbullet 6 * @author Marcel Radzio 7 */ 8 9 //Load needed Features 10 var curl = require('curlrequest'); 11 12 module.exports = { 13 /** 14 * Send Status on change to Pushbullet Channel 15 * @class pushbullet 16 * @constructor 17 */ 18 pushbulletSend: function (door_status){ 19 var token = process.env.pushbullet_api 20 if (typeof token === 'undefined' && !token) { 21 console.log("No pushbullet token defined") 22 } 23 curl.request({ url: 'https://api.pushbullet.com/v2/pushes', method: 'POST', headers: { "Access-Token": token, "Content-Type": 'application/json' }, data: '{"channel_tag": "space-door", "body":"'+ door_status + '","title":"Door Status","type":"note"}'}, function (err, stdout, meta) { 24 if (err){ 25 /** 26 * Fired when an error occurs... 27 * 28 * @property err 29 * @type String 30 */ 31 throw new Error(err) 32 } 33 }); 34 } 35 };