-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (25 loc) · 876 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
'use strict'
const Homey = require('homey')
const app = require('./app.json')
class Yr extends Homey.App {
onInit () {
this.log(`${app.name.en} version ${app.version} is running!`)
// Instantiate handlers
this.log('App - Instantiate handlers...')
this.Nowcast = require('./handlers/nowcast-handler')(this)
this.Forecast = require('./handlers/forecast-handler')(this)
this.TextForecast = require('./handlers/text-forecast-handler')(this)
// @ts-ignore
Homey.on('unload', async () => {
await this.unregisterTasks()
})
}
async unregisterTasks () {
const currentTasks = await Homey.ManagerCron.getTasks()
if (currentTasks && currentTasks.length > 0) {
this.log(`App - Unregistering ${currentTasks.length} existing cron jobs...`)
await Homey.ManagerCron.unregisterAllTasks()
}
}
}
module.exports = Yr