forked from CFenner/MMM-Sonos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_helper.js
More file actions
28 lines (27 loc) · 794 Bytes
/
node_helper.js
File metadata and controls
28 lines (27 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* Magic Mirror
* Module: MagicMirror-Sonos-Module
*
* By Christopher Fenner https://github.com/CFenner
* MIT Licensed.
*/
var NodeHelper = require('node_helper');
var request = require('request');
module.exports = NodeHelper.create({
start: function () {
console.log('Sonos helper started ...');
},
//Subclass socketNotificationReceived received.
socketNotificationReceived: function(notification, url) {
if (notification === 'SONOS_UPDATE') {
console.log(notification);
var self = this;
request(url, function(error, response, body) {
if (!error && response.statusCode == 200) {
self.sendSocketNotification('SONOS_DATA', JSON.parse(body));
} else {
console.error('Failure: ' + error);
}
});
}
}
});