meross-cli 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +28 -2
- package/cli/commands/control/execute.js +36 -6
- package/cli/commands/control/params/index.js +16 -12
- package/cli/commands/control/params/light.js +55 -25
- package/cli/commands/control/params/thermostat.js +24 -22
- package/cli/commands/control/params/timer.js +18 -15
- package/cli/commands/control/params/trigger.js +24 -13
- package/cli/commands/info.js +38 -14
- package/cli/commands/sniffer/sniffer-menu.js +2 -2
- package/cli/commands/status/device-status.js +418 -1292
- package/cli/commands/status/hub-status.js +14 -6
- package/cli/control-registry.js +211 -406
- package/cli/meross-cli.js +1 -1
- package/cli/tests/README.md +2 -0
- package/cli/tests/test-alarm.js +22 -2
- package/cli/tests/test-child-lock.js +40 -10
- package/cli/tests/test-config.js +22 -2
- package/cli/tests/test-control.js +8 -8
- package/cli/tests/test-diffuser.js +7 -7
- package/cli/tests/test-dnd.js +87 -66
- package/cli/tests/test-electricity.js +37 -33
- package/cli/tests/test-encryption.js +13 -13
- package/cli/tests/test-garage.js +12 -14
- package/cli/tests/test-helper.js +1 -1
- package/cli/tests/test-hub-sensors.js +3 -3
- package/cli/tests/test-light.js +497 -105
- package/cli/tests/test-presence.js +10 -55
- package/cli/tests/test-registry.js +7 -1
- package/cli/tests/test-roller-shutter.js +78 -90
- package/cli/tests/test-screen.js +1 -1
- package/cli/tests/test-sensor-history.js +6 -2
- package/cli/tests/test-smoke-config.js +24 -4
- package/cli/tests/test-spray.js +11 -11
- package/cli/tests/test-system.js +375 -0
- package/cli/tests/test-temp-unit.js +22 -2
- package/cli/tests/test-template.js +61 -73
- package/cli/tests/test-thermostat.js +126 -89
- package/cli/tests/test-timer.js +8 -51
- package/cli/tests/test-toggle.js +49 -173
- package/cli/tests/test-trigger.js +7 -50
- package/package.json +2 -2
package/cli/meross-cli.js
CHANGED
|
@@ -300,7 +300,7 @@ Examples:
|
|
|
300
300
|
console.log();
|
|
301
301
|
}
|
|
302
302
|
console.log('Usage: meross-cli control <uuid> <method> [options]');
|
|
303
|
-
console.log('Example: meross-cli control <uuid>
|
|
303
|
+
console.log('Example: meross-cli control <uuid> toggle.set --channel 0 --on true');
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
function _findMethodInfo(availableMethods, methodName) {
|
package/cli/tests/README.md
CHANGED
|
@@ -41,6 +41,7 @@ The test system is designed for simplicity, maintainability, and excellent error
|
|
|
41
41
|
- `test-config.js` - Tests for config features (over temp)
|
|
42
42
|
- `test-control.js` - Tests for control features (multiple commands, upgrade, over temp)
|
|
43
43
|
- `test-presence.js` - Tests for presence sensor devices
|
|
44
|
+
- `test-system.js` - Tests for system information, hardware, firmware, abilities, and configuration
|
|
44
45
|
|
|
45
46
|
## Running Tests
|
|
46
47
|
|
|
@@ -107,6 +108,7 @@ meross-cli test electricity --email your@email.com --password yourpass
|
|
|
107
108
|
- `config` - Config features (over temp)
|
|
108
109
|
- `control` - Control features (multiple commands, upgrade, over temp)
|
|
109
110
|
- `presence` - Presence sensor devices
|
|
111
|
+
- `system` - System information, hardware, firmware, abilities, and configuration
|
|
110
112
|
|
|
111
113
|
## Writing New Tests
|
|
112
114
|
|
package/cli/tests/test-alarm.js
CHANGED
|
@@ -47,7 +47,17 @@ async function runTests(context) {
|
|
|
47
47
|
|
|
48
48
|
// Test 1: Get alarm status
|
|
49
49
|
try {
|
|
50
|
-
|
|
50
|
+
if (!testDevice.alarm) {
|
|
51
|
+
results.push({
|
|
52
|
+
name: 'should get alarm status',
|
|
53
|
+
passed: false,
|
|
54
|
+
skipped: true,
|
|
55
|
+
error: 'Device does not support alarm feature',
|
|
56
|
+
device: deviceName
|
|
57
|
+
});
|
|
58
|
+
return results;
|
|
59
|
+
}
|
|
60
|
+
const response = await testDevice.alarm.get({ channel: 0 });
|
|
51
61
|
|
|
52
62
|
if (!response) {
|
|
53
63
|
results.push({
|
|
@@ -87,8 +97,18 @@ async function runTests(context) {
|
|
|
87
97
|
|
|
88
98
|
// Test 2: Store alarm events from push notifications
|
|
89
99
|
try {
|
|
100
|
+
if (!testDevice.alarm) {
|
|
101
|
+
results.push({
|
|
102
|
+
name: 'should store alarm events from push notifications',
|
|
103
|
+
passed: false,
|
|
104
|
+
skipped: true,
|
|
105
|
+
error: 'Device does not support alarm feature',
|
|
106
|
+
device: deviceName
|
|
107
|
+
});
|
|
108
|
+
return results;
|
|
109
|
+
}
|
|
90
110
|
// Get initial alarm events (should be empty or existing events)
|
|
91
|
-
const initialEvents = testDevice.
|
|
111
|
+
const initialEvents = testDevice.alarm.getLastEvents();
|
|
92
112
|
|
|
93
113
|
if (!Array.isArray(initialEvents)) {
|
|
94
114
|
results.push({
|
|
@@ -49,14 +49,24 @@ async function runTests(context) {
|
|
|
49
49
|
|
|
50
50
|
// Test 1: Get child lock status
|
|
51
51
|
try {
|
|
52
|
-
|
|
52
|
+
if (!testDevice.childLock) {
|
|
53
|
+
results.push({
|
|
54
|
+
name: 'should get child lock status',
|
|
55
|
+
passed: false,
|
|
56
|
+
skipped: true,
|
|
57
|
+
error: 'Device does not support child lock feature',
|
|
58
|
+
device: deviceName
|
|
59
|
+
});
|
|
60
|
+
return results;
|
|
61
|
+
}
|
|
62
|
+
const lockStatus = await testDevice.childLock.get({ channel: 0 });
|
|
53
63
|
|
|
54
64
|
if (!lockStatus) {
|
|
55
65
|
results.push({
|
|
56
66
|
name: 'should get child lock status',
|
|
57
67
|
passed: false,
|
|
58
68
|
skipped: false,
|
|
59
|
-
error: '
|
|
69
|
+
error: 'childLock.get() returned null or undefined',
|
|
60
70
|
device: deviceName
|
|
61
71
|
});
|
|
62
72
|
} else if (!lockStatus.lock) {
|
|
@@ -89,8 +99,18 @@ async function runTests(context) {
|
|
|
89
99
|
|
|
90
100
|
// Test 2: Control child lock status
|
|
91
101
|
try {
|
|
102
|
+
if (!testDevice.childLock) {
|
|
103
|
+
results.push({
|
|
104
|
+
name: 'should control child lock status',
|
|
105
|
+
passed: false,
|
|
106
|
+
skipped: true,
|
|
107
|
+
error: 'Device does not support child lock feature',
|
|
108
|
+
device: deviceName
|
|
109
|
+
});
|
|
110
|
+
return results;
|
|
111
|
+
}
|
|
92
112
|
// Get initial lock status
|
|
93
|
-
const initialStatus = await testDevice.
|
|
113
|
+
const initialStatus = await testDevice.childLock.get({ channel: 0 });
|
|
94
114
|
|
|
95
115
|
if (!initialStatus || !initialStatus.lock || !Array.isArray(initialStatus.lock) || initialStatus.lock.length === 0) {
|
|
96
116
|
results.push({
|
|
@@ -110,11 +130,11 @@ async function runTests(context) {
|
|
|
110
130
|
onoff: newLockState
|
|
111
131
|
};
|
|
112
132
|
|
|
113
|
-
await testDevice.
|
|
133
|
+
await testDevice.childLock.set({ channel: 0, onoff: newLockState });
|
|
114
134
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
115
135
|
|
|
116
136
|
// Verify the change
|
|
117
|
-
const updatedStatus = await testDevice.
|
|
137
|
+
const updatedStatus = await testDevice.childLock.get({ channel: 0 });
|
|
118
138
|
|
|
119
139
|
if (!updatedStatus || !updatedStatus.lock || !updatedStatus.lock[0]) {
|
|
120
140
|
results.push({
|
|
@@ -138,10 +158,10 @@ async function runTests(context) {
|
|
|
138
158
|
channel: 0,
|
|
139
159
|
onoff: initialLockState
|
|
140
160
|
};
|
|
141
|
-
await testDevice.
|
|
161
|
+
await testDevice.childLock.set({ channel: 0, onoff: initialLockState });
|
|
142
162
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
143
163
|
|
|
144
|
-
const restoredStatus = await testDevice.
|
|
164
|
+
const restoredStatus = await testDevice.childLock.get({ channel: 0 });
|
|
145
165
|
|
|
146
166
|
if (!restoredStatus || !restoredStatus.lock || !restoredStatus.lock[0] ||
|
|
147
167
|
restoredStatus.lock[0].onoff !== initialLockState) {
|
|
@@ -175,8 +195,18 @@ async function runTests(context) {
|
|
|
175
195
|
|
|
176
196
|
// Test 3: Handle multiple channel lock control
|
|
177
197
|
try {
|
|
198
|
+
if (!testDevice.childLock) {
|
|
199
|
+
results.push({
|
|
200
|
+
name: 'should handle multiple channel lock control',
|
|
201
|
+
passed: false,
|
|
202
|
+
skipped: true,
|
|
203
|
+
error: 'Device does not support child lock feature',
|
|
204
|
+
device: deviceName
|
|
205
|
+
});
|
|
206
|
+
return results;
|
|
207
|
+
}
|
|
178
208
|
// Get initial status for all channels
|
|
179
|
-
const initialStatus = await testDevice.
|
|
209
|
+
const initialStatus = await testDevice.childLock.get({ channel: 0 });
|
|
180
210
|
|
|
181
211
|
if (!initialStatus || !initialStatus.lock) {
|
|
182
212
|
results.push({
|
|
@@ -205,11 +235,11 @@ async function runTests(context) {
|
|
|
205
235
|
}
|
|
206
236
|
}
|
|
207
237
|
|
|
208
|
-
await testDevice.
|
|
238
|
+
await testDevice.childLock.set({ lockData: lockDataArray });
|
|
209
239
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
210
240
|
|
|
211
241
|
// Verify all channels were set
|
|
212
|
-
const updatedStatus = await testDevice.
|
|
242
|
+
const updatedStatus = await testDevice.childLock.get({ channel: 0 });
|
|
213
243
|
|
|
214
244
|
if (!updatedStatus) {
|
|
215
245
|
results.push({
|
package/cli/tests/test-config.js
CHANGED
|
@@ -47,7 +47,17 @@ async function runTests(context) {
|
|
|
47
47
|
|
|
48
48
|
// Test 1: Get config over temp
|
|
49
49
|
try {
|
|
50
|
-
|
|
50
|
+
if (!testDevice.config) {
|
|
51
|
+
results.push({
|
|
52
|
+
name: 'should get config over temp',
|
|
53
|
+
passed: false,
|
|
54
|
+
skipped: true,
|
|
55
|
+
error: 'Device does not support config feature',
|
|
56
|
+
device: deviceName
|
|
57
|
+
});
|
|
58
|
+
return results;
|
|
59
|
+
}
|
|
60
|
+
const response = await testDevice.config.get();
|
|
51
61
|
|
|
52
62
|
if (!response) {
|
|
53
63
|
results.push({
|
|
@@ -87,8 +97,18 @@ async function runTests(context) {
|
|
|
87
97
|
|
|
88
98
|
// Test 2: Control config over temp
|
|
89
99
|
try {
|
|
100
|
+
if (!testDevice.config) {
|
|
101
|
+
results.push({
|
|
102
|
+
name: 'should control config over temp',
|
|
103
|
+
passed: false,
|
|
104
|
+
skipped: true,
|
|
105
|
+
error: 'Device does not support config feature',
|
|
106
|
+
device: deviceName
|
|
107
|
+
});
|
|
108
|
+
return results;
|
|
109
|
+
}
|
|
90
110
|
// Get current config first
|
|
91
|
-
const currentResponse = await testDevice.
|
|
111
|
+
const currentResponse = await testDevice.config.get();
|
|
92
112
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
93
113
|
|
|
94
114
|
if (!currentResponse || !currentResponse.overTemp) {
|
|
@@ -63,12 +63,12 @@ async function runTests(context) {
|
|
|
63
63
|
|
|
64
64
|
// Test 1: Control Multiple
|
|
65
65
|
try {
|
|
66
|
-
if (typeof device.setMultiple !== 'function') {
|
|
66
|
+
if (!device.control || typeof device.control.setMultiple !== 'function') {
|
|
67
67
|
results.push({
|
|
68
68
|
name: 'should execute multiple commands',
|
|
69
69
|
passed: false,
|
|
70
70
|
skipped: true,
|
|
71
|
-
error: 'Device does not support setMultiple',
|
|
71
|
+
error: 'Device does not support control.setMultiple',
|
|
72
72
|
device: deviceName
|
|
73
73
|
});
|
|
74
74
|
} else {
|
|
@@ -85,14 +85,14 @@ async function runTests(context) {
|
|
|
85
85
|
}
|
|
86
86
|
];
|
|
87
87
|
|
|
88
|
-
const response = await device.setMultiple(commands);
|
|
88
|
+
const response = await device.control.setMultiple({ commands });
|
|
89
89
|
|
|
90
90
|
if (!response) {
|
|
91
91
|
results.push({
|
|
92
92
|
name: 'should execute multiple commands',
|
|
93
93
|
passed: false,
|
|
94
94
|
skipped: false,
|
|
95
|
-
error: 'setMultiple returned null or undefined',
|
|
95
|
+
error: 'control.setMultiple returned null or undefined',
|
|
96
96
|
device: deviceName
|
|
97
97
|
});
|
|
98
98
|
} else {
|
|
@@ -117,12 +117,12 @@ async function runTests(context) {
|
|
|
117
117
|
|
|
118
118
|
// Test 2: Control Over Temp
|
|
119
119
|
try {
|
|
120
|
-
if (typeof device.
|
|
120
|
+
if (!device.control || typeof device.control.acknowledgeOverTemp !== 'function') {
|
|
121
121
|
results.push({
|
|
122
122
|
name: 'should acknowledge over temp event',
|
|
123
123
|
passed: false,
|
|
124
124
|
skipped: true,
|
|
125
|
-
error: 'Device does not support
|
|
125
|
+
error: 'Device does not support control.acknowledgeOverTemp',
|
|
126
126
|
device: deviceName
|
|
127
127
|
});
|
|
128
128
|
} else {
|
|
@@ -149,12 +149,12 @@ async function runTests(context) {
|
|
|
149
149
|
|
|
150
150
|
// Test 3: Control Upgrade
|
|
151
151
|
try {
|
|
152
|
-
if (typeof device.setUpgrade !== 'function') {
|
|
152
|
+
if (!device.control || typeof device.control.setUpgrade !== 'function') {
|
|
153
153
|
results.push({
|
|
154
154
|
name: 'should have upgrade method available',
|
|
155
155
|
passed: false,
|
|
156
156
|
skipped: true,
|
|
157
|
-
error: 'Device does not support setUpgrade',
|
|
157
|
+
error: 'Device does not support control.setUpgrade',
|
|
158
158
|
device: deviceName
|
|
159
159
|
});
|
|
160
160
|
} else {
|
|
@@ -43,13 +43,13 @@ async function runTests(context) {
|
|
|
43
43
|
// Wait for devices to be connected
|
|
44
44
|
for (const device of lightDevices) {
|
|
45
45
|
await waitForDeviceConnection(device, timeout);
|
|
46
|
-
await device.
|
|
46
|
+
await device.diffuser.get({ type: 'light', channel: 0 });
|
|
47
47
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
for (const device of sprayDevices) {
|
|
51
51
|
await waitForDeviceConnection(device, timeout);
|
|
52
|
-
await device.
|
|
52
|
+
await device.diffuser.get({ type: 'spray', channel: 0 });
|
|
53
53
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -67,7 +67,7 @@ async function runTests(context) {
|
|
|
67
67
|
const deviceName = getDeviceName(light);
|
|
68
68
|
|
|
69
69
|
try {
|
|
70
|
-
await light.
|
|
70
|
+
await light.diffuser.get({ type: 'light', channel: 0 });
|
|
71
71
|
|
|
72
72
|
// Set mode to FIXED_RGB
|
|
73
73
|
await light.setDiffuserLight({
|
|
@@ -142,7 +142,7 @@ async function runTests(context) {
|
|
|
142
142
|
const deviceName = getDeviceName(light);
|
|
143
143
|
|
|
144
144
|
try {
|
|
145
|
-
await light.
|
|
145
|
+
await light.diffuser.get({ type: 'light', channel: 0 });
|
|
146
146
|
|
|
147
147
|
// Set mode to FIXED RGB
|
|
148
148
|
await light.setDiffuserLight({
|
|
@@ -275,7 +275,7 @@ async function runTests(context) {
|
|
|
275
275
|
const deviceName = getDeviceName(light);
|
|
276
276
|
|
|
277
277
|
try {
|
|
278
|
-
await light.
|
|
278
|
+
await light.diffuser.get({ type: 'light', channel: 0 });
|
|
279
279
|
|
|
280
280
|
await light.setDiffuserLight({
|
|
281
281
|
channel: 0,
|
|
@@ -365,7 +365,7 @@ async function runTests(context) {
|
|
|
365
365
|
const deviceName = getDeviceName(light);
|
|
366
366
|
|
|
367
367
|
try {
|
|
368
|
-
await light.
|
|
368
|
+
await light.diffuser.get({ type: 'light', channel: 0 });
|
|
369
369
|
|
|
370
370
|
await light.setDiffuserLight({
|
|
371
371
|
channel: 0,
|
|
@@ -430,7 +430,7 @@ async function runTests(context) {
|
|
|
430
430
|
const deviceName = getDeviceName(spray);
|
|
431
431
|
|
|
432
432
|
try {
|
|
433
|
-
await spray.
|
|
433
|
+
await spray.diffuser.getSpray({ channel: 0 });
|
|
434
434
|
|
|
435
435
|
await spray.setDiffuserSpray(0, DiffuserSprayMode.LIGHT);
|
|
436
436
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
package/cli/tests/test-dnd.js
CHANGED
|
@@ -27,8 +27,9 @@ async function runTests(context) {
|
|
|
27
27
|
const allDevices = manager.devices.list();
|
|
28
28
|
testDevices = allDevices.filter(d => {
|
|
29
29
|
return d.onlineStatus === OnlineStatus.ONLINE &&
|
|
30
|
-
|
|
31
|
-
typeof d.
|
|
30
|
+
d.dnd &&
|
|
31
|
+
typeof d.dnd.get === 'function' &&
|
|
32
|
+
typeof d.dnd.set === 'function';
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -56,67 +57,77 @@ async function runTests(context) {
|
|
|
56
57
|
|
|
57
58
|
// Test 1: Get and set DND mode
|
|
58
59
|
try {
|
|
59
|
-
|
|
60
|
-
const initialMode = await testDevice.getDNDMode();
|
|
61
|
-
|
|
62
|
-
if (initialMode === null || initialMode === undefined) {
|
|
60
|
+
if (!testDevice.dnd) {
|
|
63
61
|
results.push({
|
|
64
62
|
name: 'should get and set DND mode',
|
|
65
63
|
passed: false,
|
|
66
|
-
skipped:
|
|
67
|
-
error: '
|
|
68
|
-
device: deviceName
|
|
69
|
-
});
|
|
70
|
-
} else if (initialMode !== DNDMode.DND_DISABLED && initialMode !== DNDMode.DND_ENABLED) {
|
|
71
|
-
results.push({
|
|
72
|
-
name: 'should get and set DND mode',
|
|
73
|
-
passed: false,
|
|
74
|
-
skipped: false,
|
|
75
|
-
error: `Invalid DND mode value: ${initialMode}`,
|
|
64
|
+
skipped: true,
|
|
65
|
+
error: 'Device does not support DND feature',
|
|
76
66
|
device: deviceName
|
|
77
67
|
});
|
|
78
68
|
} else {
|
|
79
|
-
//
|
|
80
|
-
const
|
|
81
|
-
await testDevice.setDNDMode({ mode: newMode });
|
|
69
|
+
// Get current DND mode
|
|
70
|
+
const initialMode = await testDevice.dnd.get();
|
|
82
71
|
|
|
83
|
-
|
|
84
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
85
|
-
|
|
86
|
-
// Verify the change
|
|
87
|
-
const updatedMode = await testDevice.getDNDMode();
|
|
88
|
-
|
|
89
|
-
if (updatedMode !== newMode) {
|
|
72
|
+
if (initialMode === null || initialMode === undefined) {
|
|
90
73
|
results.push({
|
|
91
74
|
name: 'should get and set DND mode',
|
|
92
75
|
passed: false,
|
|
93
76
|
skipped: false,
|
|
94
|
-
error:
|
|
77
|
+
error: 'dnd.get() returned null or undefined',
|
|
78
|
+
device: deviceName
|
|
79
|
+
});
|
|
80
|
+
} else if (initialMode !== DNDMode.DND_DISABLED && initialMode !== DNDMode.DND_ENABLED) {
|
|
81
|
+
results.push({
|
|
82
|
+
name: 'should get and set DND mode',
|
|
83
|
+
passed: false,
|
|
84
|
+
skipped: false,
|
|
85
|
+
error: `Invalid DND mode value: ${initialMode}`,
|
|
95
86
|
device: deviceName
|
|
96
87
|
});
|
|
97
88
|
} else {
|
|
98
|
-
//
|
|
99
|
-
|
|
89
|
+
// Toggle DND mode
|
|
90
|
+
const newMode = initialMode === DNDMode.DND_ENABLED ? DNDMode.DND_DISABLED : DNDMode.DND_ENABLED;
|
|
91
|
+
await testDevice.dnd.set({ mode: newMode });
|
|
92
|
+
|
|
93
|
+
// Wait for the change to take effect
|
|
100
94
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
101
95
|
|
|
102
|
-
|
|
96
|
+
// Verify the change
|
|
97
|
+
const updatedMode = await testDevice.dnd.get();
|
|
103
98
|
|
|
104
|
-
if (
|
|
99
|
+
if (updatedMode !== newMode) {
|
|
105
100
|
results.push({
|
|
106
101
|
name: 'should get and set DND mode',
|
|
107
102
|
passed: false,
|
|
108
103
|
skipped: false,
|
|
109
|
-
error: `
|
|
104
|
+
error: `DND mode did not change. Expected ${newMode}, got ${updatedMode}`,
|
|
110
105
|
device: deviceName
|
|
111
106
|
});
|
|
112
107
|
} else {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
// Restore original mode
|
|
109
|
+
await testDevice.dnd.set({ mode: initialMode });
|
|
110
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
111
|
+
|
|
112
|
+
const restoredMode = await testDevice.dnd.get();
|
|
113
|
+
|
|
114
|
+
if (restoredMode !== initialMode) {
|
|
115
|
+
results.push({
|
|
116
|
+
name: 'should get and set DND mode',
|
|
117
|
+
passed: false,
|
|
118
|
+
skipped: false,
|
|
119
|
+
error: `Failed to restore DND mode. Expected ${initialMode}, got ${restoredMode}`,
|
|
120
|
+
device: deviceName
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
results.push({
|
|
124
|
+
name: 'should get and set DND mode',
|
|
125
|
+
passed: true,
|
|
126
|
+
skipped: false,
|
|
127
|
+
error: null,
|
|
128
|
+
device: deviceName
|
|
129
|
+
});
|
|
130
|
+
}
|
|
120
131
|
}
|
|
121
132
|
}
|
|
122
133
|
}
|
|
@@ -132,37 +143,47 @@ async function runTests(context) {
|
|
|
132
143
|
|
|
133
144
|
// Test 2: Accept boolean values for DND mode
|
|
134
145
|
try {
|
|
135
|
-
|
|
136
|
-
const initialMode = await testDevice.getDNDMode();
|
|
137
|
-
const initialBoolean = initialMode === DNDMode.DND_ENABLED;
|
|
138
|
-
|
|
139
|
-
// Set using boolean (true = enabled)
|
|
140
|
-
await testDevice.setDNDMode({ mode: !initialBoolean });
|
|
141
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
142
|
-
|
|
143
|
-
const updatedMode = await testDevice.getDNDMode();
|
|
144
|
-
const expectedMode = !initialBoolean ? DNDMode.DND_ENABLED : DNDMode.DND_DISABLED;
|
|
145
|
-
|
|
146
|
-
if (updatedMode !== expectedMode) {
|
|
146
|
+
if (!testDevice.dnd) {
|
|
147
147
|
results.push({
|
|
148
148
|
name: 'should accept boolean values for DND mode',
|
|
149
149
|
passed: false,
|
|
150
|
-
skipped:
|
|
151
|
-
error:
|
|
150
|
+
skipped: true,
|
|
151
|
+
error: 'Device does not support DND feature',
|
|
152
152
|
device: deviceName
|
|
153
153
|
});
|
|
154
154
|
} else {
|
|
155
|
-
//
|
|
156
|
-
await testDevice.
|
|
155
|
+
// Get current mode
|
|
156
|
+
const initialMode = await testDevice.dnd.get();
|
|
157
|
+
const initialBoolean = initialMode === DNDMode.DND_ENABLED;
|
|
158
|
+
|
|
159
|
+
// Set using boolean (true = enabled)
|
|
160
|
+
await testDevice.dnd.set({ mode: !initialBoolean });
|
|
157
161
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
158
162
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
const updatedMode = await testDevice.dnd.get();
|
|
164
|
+
const expectedMode = !initialBoolean ? DNDMode.DND_ENABLED : DNDMode.DND_DISABLED;
|
|
165
|
+
|
|
166
|
+
if (updatedMode !== expectedMode) {
|
|
167
|
+
results.push({
|
|
168
|
+
name: 'should accept boolean values for DND mode',
|
|
169
|
+
passed: false,
|
|
170
|
+
skipped: false,
|
|
171
|
+
error: `Boolean set failed. Expected ${expectedMode}, got ${updatedMode}`,
|
|
172
|
+
device: deviceName
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
// Restore original mode
|
|
176
|
+
await testDevice.dnd.set({ mode: initialBoolean });
|
|
177
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
178
|
+
|
|
179
|
+
results.push({
|
|
180
|
+
name: 'should accept boolean values for DND mode',
|
|
181
|
+
passed: true,
|
|
182
|
+
skipped: false,
|
|
183
|
+
error: null,
|
|
184
|
+
device: deviceName
|
|
185
|
+
});
|
|
186
|
+
}
|
|
166
187
|
}
|
|
167
188
|
} catch (error) {
|
|
168
189
|
results.push({
|
|
@@ -176,16 +197,16 @@ async function runTests(context) {
|
|
|
176
197
|
|
|
177
198
|
// Test 3: Get raw DND mode value
|
|
178
199
|
try {
|
|
179
|
-
if (typeof testDevice.
|
|
200
|
+
if (!testDevice.dnd || typeof testDevice.dnd.getRaw !== 'function') {
|
|
180
201
|
results.push({
|
|
181
202
|
name: 'should get raw DND mode value',
|
|
182
203
|
passed: false,
|
|
183
204
|
skipped: true,
|
|
184
|
-
error: 'Device does not support
|
|
205
|
+
error: 'Device does not support dnd.getRaw',
|
|
185
206
|
device: deviceName
|
|
186
207
|
});
|
|
187
208
|
} else {
|
|
188
|
-
const rawMode = await testDevice.
|
|
209
|
+
const rawMode = await testDevice.dnd.getRaw();
|
|
189
210
|
|
|
190
211
|
if (typeof rawMode !== 'number') {
|
|
191
212
|
results.push({
|
|
@@ -205,7 +226,7 @@ async function runTests(context) {
|
|
|
205
226
|
});
|
|
206
227
|
} else {
|
|
207
228
|
// Verify it matches enum value
|
|
208
|
-
const enumMode = await testDevice.
|
|
229
|
+
const enumMode = await testDevice.dnd.get();
|
|
209
230
|
|
|
210
231
|
if (rawMode !== enumMode) {
|
|
211
232
|
results.push({
|