-
Notifications
You must be signed in to change notification settings - Fork 45
/
app.js
62 lines (50 loc) · 2.03 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
57
58
59
60
61
62
"use strict";
const Homey = require("homey");
// Enable zigbee-cluster logging
const { debug } = require('zigbee-clusters');
// debug(true);
class PhilipsHueZigbeeApp extends Homey.App {
onInit() {
this.log("Philips Hue Zigbee app initiating...");
// Register listeners for Blink action
this.startBlinkAction = this.homey.flow.getActionCard('Blink');
this.startBlinkAction.registerRunListener(async (args, state) => {
if (typeof args.device.blink === 'function') {
return args.device.blink(args);
} else {
throw new Error('Device does not support blinking');
}
});
// Register listeners for Alert action
this.startAlertAction = this.homey.flow.getActionCard('Alert');
this.startAlertAction.registerRunListener(async (args, state) => {
if (typeof args.device.alert === 'function') {
return args.device.alert(args);
} else {
throw new Error('Device does not support alerts');
}
});
this.homey.flow.getActionCard('suppress_sensor')
.registerRunListener((args, state) => {
return args.device.suppressSensor(args, state);
});
this.homey.flow.getConditionCard('temperature_above')
.registerRunListener((args, state) => {
return args.device.getCapabilityValue('measure_temperature') > args.temperature;
});
this.homey.flow.getConditionCard('luminance_above')
.registerRunListener((args, state) => {
return args.device.getCapabilityValue('measure_luminance') > args.luminance;
});
// Register listeners for Dynamic Scenes
/* this.startDynamicScenesAction = this.homey.flow.getActionCard('DynamicScenes');
this.startDynamicScenesAction.registerRunListener(async (args, state) => {
if (typeof args.device.setDynamicScenes === 'function') {
return args.device.setDynamicScenes(args.dynamicScene_mode);
} else {
throw new Error('This device does not support Dynamic Scenes');
}
}); */
}
}
module.exports = PhilipsHueZigbeeApp;