-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBinary Switch.js
44 lines (40 loc) · 1.17 KB
/
Binary Switch.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
/*
* Homey CommandClass
* Binary Switch
* Version 1 - 2
*
* JUST FOR REFERENCE!
* Basic knowledge still needed.
*/
/*
* =========== GENERAL CODE: VERSION 1 ===========
* [#CAPABILITY#] = the used capability
*/
'[#CAPABILITY#]': {
'command_class': 'COMMAND_CLASS_SWITCH_BINARY',
'command_get': 'SWITCH_BINARY_GET',
'command_set': 'SWITCH_BINARY_SET',
'command_set_parser': value => ({
'Switch Value': (value) ? 'on/enable' : 'off/disable'
}),
'command_report': 'SWITCH_BINARY_REPORT',
'command_report_parser': report => report.Value === 'on/enable'
}
/*
* =========== GENERAL CODE: VERSION 2 ===========
* [#CAPABILITY#] = the used capability
*/
'[#CAPABILITY#]': {
command_class: 'COMMAND_CLASS_SWITCH_BINARY',
command_get: 'SWITCH_BINARY_GET',
command_set: 'SWITCH_BINARY_SET',
command_set_parser: value => ({
'Target Value': (value) ? 'on/enable' : 'off/disable',
'Duration': 'Default'
}),
command_report: 'SWITCH_BINARY_REPORT',
command_report_parser: report => {
if (report && typeof report['Current Value'] !== 'undefined') return report['Current Value'] === 'on/enable';
return null;
},
}