-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
56 lines (50 loc) · 1.66 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
const Homey = require('homey');
class MeteoalarmApp extends Homey.App {
onInit() {
this.log('Meteoalarm is running...');
let cond;
['at', 'ba', 'be', 'bg', 'ch', 'cy', 'cz', 'de', 'dk', 'ee',
'es', 'fi', 'fr', 'gr', 'hr', 'hu', 'ie', 'il', 'is', 'it',
'lt', 'lu', 'lv', 'md', 'me', 'mk', 'mt', 'nl', 'no', 'pl',
'pt', 'ro', 'rs', 'se', 'si', 'sk', 'uk'].forEach(country => {
cond = new Homey.FlowCardCondition('overall_today_'+country);
cond.register().registerRunListener(( args, state ) => {
if (args.device.state) {
if (args.device.state.today.overall == args.state) {
return Promise.resolve( true );
}
}
return Promise.resolve( false );
})
cond = new Homey.FlowCardCondition('overall_tomorrow_'+country);
cond.register().registerRunListener(( args, state ) => {
if (args.device.state) {
if (args.device.state.tomorrow.overall == args.state) {
return Promise.resolve( true );
}
}
return Promise.resolve( false );
})
cond = new Homey.FlowCardCondition('specific_today_'+country);
cond.register().registerRunListener(( args, state ) => {
if (args.device.state) {
if (args.device.state.today[args.type] == args.state) {
return Promise.resolve( true );
}
}
return Promise.resolve( false );
})
cond = new Homey.FlowCardCondition('specific_tomorrow_'+country);
cond.register().registerRunListener(( args, state ) => {
if (args.device.state) {
if (args.device.state.tomorrow[args.type] == args.state) {
return Promise.resolve( true );
}
}
return Promise.resolve( false );
})
})
}
}
module.exports = MeteoalarmApp;