forked from magtimmermans/com.cyclone-software.sunevents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (25 loc) · 830 Bytes
/
app.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
const SunEvent = require('./sunevent');
const api = new SunEvent();
function init() {
Homey.log("Sun Events start");
setLocation(function(err) {
console.log(err);
if (!err) {
api.init();
};
});
}
/* Get the current location of homey and put this into the SunEvent object. Based on this the calculations are made */
function setLocation(callback) {
// Homey.log('Call GeoLocation');
Homey.manager('geolocation').getLocation((err, location) => {
if (!err) {
// Homey.log(location);
api.setLatLon(location.latitude, location.longitude);
}
if (callback) {
callback(err || (!location || location.latitude === false || location.longitude === false), location);
}
});
}
module.exports.init = init;