-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (36 loc) · 1014 Bytes
/
index.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
36
37
38
39
40
module.exports = function(sails) {
const install = require('./lib/install');
const initialize = require('./lib/initialize.js');
const uninstall = require('./lib/uninstall')
const commands = require('./lib/commands/index')
const command = require('./lib/commands/command')
const checkMode = require('./lib/checkMode')
gladys.on('ready', function() {
gladys.param.getValue('NETATMO_INTERVAL_UPDATE')
.then((intervalUser) => {
return intervalUser;
})
.catch(() => {
return 30;
})
.then((interval) => {
setInterval(function () {
gladys.house.get().then((houses) => {
gladys.mode.getByHouse({id:houses[0].id}).then((mode) => {
sails.log.info('Check home mode !')
checkMode(mode.value)
})
})
sails.log.info('Update Netatmo data !')
commands.updateData()
}, interval*60000)
})
})
return {
install: install,
initialize: initialize,
uninstall: uninstall,
commands: commands,
command: command
};
};