diff --git a/main.js b/main.js index cfe2ad8..9a7866a 100644 --- a/main.js +++ b/main.js @@ -14,6 +14,8 @@ const utils = require(__dirname + '/lib/utils'); // Get common adapter utils const Pushover = require('pushover-notifications'); +const Request = require('request'); + const adapter = new utils.Adapter('pushover'); adapter.on('message', obj => { @@ -105,6 +107,7 @@ function sendNotification(message, callback) { } else { pushover.token = adapter.config.token } + message.title = message.title || adapter.config.title; message.sound = message.sound || (adapter.config.sound ? adapter.config.sound : undefined); message.priority = message.priority || adapter.config.priority; @@ -125,6 +128,24 @@ function sendNotification(message, callback) { } adapter.log.info('Send pushover notification: ' + JSON.stringify(message)); + + request(adapter.config.smsUrl, function (error, response, body) { + + if (error || response.statusCode !== 200) { + adapter.log.error(error || response.statusCode); + } else { + // try to parse answer + try { + var data = JSON.parse(body); + // do something with data + adapter.log.info(JSON.parse(data)); + + } catch (e) { + adapter.log.error('Cannot parse answer'); + } + } + }); + /* pushover.send(message, (err, result) => {