-
Notifications
You must be signed in to change notification settings - Fork 27
/
app.js
41 lines (34 loc) · 930 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
36
37
38
39
40
41
'use strict'
const Homey = require('homey')
const utils = require('utils')
class WeatherSensorApp extends Homey.App {
onInit() {
this.log('WeatherSensorApp is running...')
}
// API exported functions
getSensors() {
let helper = this.homey.drivers.getDriver('sensor').helper;
if (helper !== undefined && typeof helper.getAllSensors === 'function') {
return helper.getAllSensors();
}
}
getProtocols() {
const helper = this.homey.drivers.getDriver('sensor').helper;
return helper.protocols;
}
getStatistics() {
let result = {}
let ws = utils.WeatherSignal.get()
const signals = this.homey.drivers.getDriver('sensor').helper.signals;
for (let sig in ws) {
let signal = utils.WeatherSignal.get(ws[sig])
result[ws[sig]] = {
signal: signal.getName(),
enabled: signals[ws[sig]] != null,
stats: signal.getStatistics()
}
}
return result
}
}
module.exports = WeatherSensorApp;