-
Notifications
You must be signed in to change notification settings - Fork 5
/
node_helper.js
35 lines (31 loc) · 912 Bytes
/
node_helper.js
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
29
30
31
32
33
34
35
/* Magic Mirror
* Module: DWD-Pollen
*
*/
var NodeHelper = require("node_helper");
var request = require("request");
module.exports = NodeHelper.create({
start: function () {
console.log("MMM-DWD-Pollen helper started ...");
},
getData: function (url) {
var self = this;
console.log("requesting:" + url);
request(
{ url: url, headers: { Referer: url }, method: "GET" },
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log("MMM-DWD-Pollen: Success loading");
var result = JSON.parse(body);
self.sendSocketNotification("DWD_POLLEN_RESULT", result);
} else {
console.log("MMM-DWD-Pollen : Could not load data.");
}
}
);
},
//Subclass socketNotificationReceived received.
socketNotificationReceived: function (payload) {
this.getData(payload);
}
});