@switchbot/homebridge-switchbot 1.5.1-beta.4 → 1.5.1-beta.5
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 +6 -2
- package/config.schema.json +9 -0
- package/dist/devices/bots.d.ts +2 -0
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +51 -9
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.js +3 -3
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +2 -0
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +21 -6
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +2 -0
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +21 -6
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +2 -0
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +21 -6
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +2 -0
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +20 -5
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +2 -0
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +20 -5
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +2 -0
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +19 -4
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.js +3 -3
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.js +3 -3
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.js +3 -3
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.js +3 -3
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.js +3 -3
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.js +3 -3
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.js +3 -3
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +3 -3
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.js +2 -2
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/devices/bots.ts +51 -9
- package/src/devices/colorbulb.ts +3 -3
- package/src/devices/contact.ts +22 -6
- package/src/devices/curtains.ts +22 -6
- package/src/devices/humidifiers.ts +22 -6
- package/src/devices/meters.ts +21 -5
- package/src/devices/motion.ts +21 -5
- package/src/devices/plugs.ts +20 -4
- package/src/irdevices/airconditioners.ts +3 -3
- package/src/irdevices/airpurifiers.ts +3 -3
- package/src/irdevices/cameras.ts +3 -3
- package/src/irdevices/fans.ts +3 -3
- package/src/irdevices/lights.ts +3 -3
- package/src/irdevices/others.ts +3 -3
- package/src/irdevices/tvs.ts +3 -3
- package/src/irdevices/vacuumcleaners.ts +3 -3
- package/src/irdevices/waterheaters.ts +2 -2
- package/src/settings.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Homebridge SwitchBot",
|
|
3
3
|
"name": "@switchbot/homebridge-switchbot",
|
|
4
|
-
"version": "1.5.1-beta.
|
|
4
|
+
"version": "1.5.1-beta.5",
|
|
5
5
|
"description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
|
|
6
6
|
"author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
|
|
7
7
|
"license": "ISC",
|
package/src/devices/bots.ts
CHANGED
|
@@ -36,6 +36,7 @@ export class Bot {
|
|
|
36
36
|
battery!: serviceData['battery'];
|
|
37
37
|
|
|
38
38
|
// Config
|
|
39
|
+
scanDuration!: number;
|
|
39
40
|
deviceLogging!: string;
|
|
40
41
|
deviceRefreshRate!: number;
|
|
41
42
|
|
|
@@ -52,8 +53,9 @@ export class Bot {
|
|
|
52
53
|
public device: device & devicesConfig,
|
|
53
54
|
) {
|
|
54
55
|
// default placeholders
|
|
55
|
-
this.refreshRate();
|
|
56
56
|
this.logs();
|
|
57
|
+
this.scan();
|
|
58
|
+
this.refreshRate();
|
|
57
59
|
if (this.On === undefined) {
|
|
58
60
|
this.On = false;
|
|
59
61
|
this.accessory.context.On = this.On;
|
|
@@ -67,7 +69,7 @@ export class Bot {
|
|
|
67
69
|
this.doublePress = 1;
|
|
68
70
|
}
|
|
69
71
|
this.BatteryLevel = 100;
|
|
70
|
-
this.StatusLowBattery =
|
|
72
|
+
this.StatusLowBattery = 0;
|
|
71
73
|
|
|
72
74
|
// Bot Config
|
|
73
75
|
this.debugLog(`Bot: ${this.accessory.displayName} Config: (ble: ${device.ble}, offline: ${device.offline}, mode: ${device.bot?.mode},`
|
|
@@ -195,10 +197,24 @@ export class Bot {
|
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
199
|
|
|
200
|
+
scan() {
|
|
201
|
+
if (this.device.scanDuration) {
|
|
202
|
+
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
203
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
204
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
205
|
+
}
|
|
206
|
+
} else {
|
|
207
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
208
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
209
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
198
214
|
logs() {
|
|
199
215
|
if (this.platform.debugMode) {
|
|
200
216
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
201
|
-
this.warnLog(`
|
|
217
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
202
218
|
} else if (this.device.logging) {
|
|
203
219
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
204
220
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
@@ -229,10 +245,17 @@ export class Bot {
|
|
|
229
245
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE parseStatus`);
|
|
230
246
|
// BLEmode (true if Switch Mode) | (false if Press Mode)
|
|
231
247
|
if (this.mode) {
|
|
232
|
-
this.
|
|
233
|
-
this.
|
|
248
|
+
this.OnCached = this.On;
|
|
249
|
+
this.accessory.context.On = this.OnCached;
|
|
250
|
+
if (this.On === undefined) {
|
|
251
|
+
this.On = Boolean(this.state);
|
|
252
|
+
}
|
|
253
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Switch Mode, mode: ${this.mode}, On: ${this.On}`);
|
|
234
254
|
} else {
|
|
235
|
-
this.
|
|
255
|
+
this.On = false;
|
|
256
|
+
this.OnCached = this.On;
|
|
257
|
+
this.accessory.context.On = this.OnCached;
|
|
258
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Press Mode, mode: ${this.mode}, On: ${this.On}`);
|
|
236
259
|
}
|
|
237
260
|
|
|
238
261
|
this.BatteryLevel = Number(this.battery);
|
|
@@ -252,11 +275,17 @@ export class Bot {
|
|
|
252
275
|
this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI parseStatus`);
|
|
253
276
|
if (this.device.bot?.mode === 'press') {
|
|
254
277
|
this.On = false;
|
|
278
|
+
this.OnCached = this.On;
|
|
279
|
+
this.accessory.context.On = this.OnCached;
|
|
255
280
|
} else {
|
|
256
281
|
if (this.deviceStatus.body.power === 'on') {
|
|
257
282
|
this.On = true;
|
|
283
|
+
this.OnCached = this.On;
|
|
284
|
+
this.accessory.context.On = this.OnCached;
|
|
258
285
|
} else {
|
|
259
286
|
this.On = false;
|
|
287
|
+
this.OnCached = this.On;
|
|
288
|
+
this.accessory.context.On = this.OnCached;
|
|
260
289
|
}
|
|
261
290
|
}
|
|
262
291
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
@@ -308,8 +337,8 @@ export class Bot {
|
|
|
308
337
|
this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
309
338
|
}
|
|
310
339
|
};
|
|
311
|
-
// Wait
|
|
312
|
-
return switchbot.wait(
|
|
340
|
+
// Wait 2 seconds
|
|
341
|
+
return switchbot.wait(this.scanDuration * 1000);
|
|
313
342
|
}).then(async () => {
|
|
314
343
|
// Stop to monitor
|
|
315
344
|
switchbot.stopScan();
|
|
@@ -393,10 +422,21 @@ export class Bot {
|
|
|
393
422
|
this.debugLog(`Bot: ${this.accessory.displayName} Press Mode: ${this.device.bot?.mode}`);
|
|
394
423
|
switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac })
|
|
395
424
|
.then((device_list: { press: (arg0: { id: string | undefined; }) => any; }[]) => {
|
|
396
|
-
this.infoLog(`Bot: ${this.accessory.displayName}
|
|
425
|
+
this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
397
426
|
return device_list[0].press({ id: this.device.bleMac });
|
|
398
427
|
}).then(() => {
|
|
399
428
|
this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
|
|
429
|
+
this.On = false;
|
|
430
|
+
this.OnCached = this.On;
|
|
431
|
+
this.accessory.context.On = this.OnCached;
|
|
432
|
+
setTimeout(() => {
|
|
433
|
+
if (this.device.bot?.deviceType === 'switch') {
|
|
434
|
+
this.switchService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
435
|
+
} else {
|
|
436
|
+
this.outletService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
437
|
+
}
|
|
438
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}, Switch Timeout`);
|
|
439
|
+
}, 500);
|
|
400
440
|
}).catch(async (e: any) => {
|
|
401
441
|
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
402
442
|
if (this.deviceLogging === 'debug') {
|
|
@@ -420,6 +460,8 @@ export class Bot {
|
|
|
420
460
|
return this.turnOnOff(device_list);
|
|
421
461
|
}).then(() => {
|
|
422
462
|
this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
|
|
463
|
+
this.OnCached = this.On;
|
|
464
|
+
this.accessory.context.On = this.OnCached;
|
|
423
465
|
}).catch(async (e: any) => {
|
|
424
466
|
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
425
467
|
if (this.deviceLogging === 'debug') {
|
package/src/devices/colorbulb.ts
CHANGED
|
@@ -214,16 +214,16 @@ export class ColorBulb {
|
|
|
214
214
|
logs() {
|
|
215
215
|
if (this.platform.debugMode) {
|
|
216
216
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
217
|
-
this.warnLog(`
|
|
217
|
+
this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
218
218
|
} else if (this.device.logging) {
|
|
219
219
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
220
220
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
221
|
-
this.warnLog(`
|
|
221
|
+
this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
222
222
|
}
|
|
223
223
|
} else if (this.platform.config.options?.logging) {
|
|
224
224
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
225
225
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
226
|
-
this.warnLog(`
|
|
226
|
+
this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
227
227
|
}
|
|
228
228
|
} else {
|
|
229
229
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
package/src/devices/contact.ts
CHANGED
|
@@ -37,6 +37,7 @@ export class Contact {
|
|
|
37
37
|
lightLevel!: serviceData['lightLevel'];
|
|
38
38
|
|
|
39
39
|
// Config
|
|
40
|
+
scanDuration!: number;
|
|
40
41
|
deviceLogging!: string;
|
|
41
42
|
deviceRefreshRate!: number;
|
|
42
43
|
|
|
@@ -50,8 +51,9 @@ export class Contact {
|
|
|
50
51
|
public device: device & devicesConfig,
|
|
51
52
|
) {
|
|
52
53
|
// default placeholders
|
|
53
|
-
this.refreshRate();
|
|
54
54
|
this.logs();
|
|
55
|
+
this.scan();
|
|
56
|
+
this.refreshRate();
|
|
55
57
|
this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
|
|
56
58
|
|
|
57
59
|
// Contact Config
|
|
@@ -157,19 +159,33 @@ export class Contact {
|
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
161
|
|
|
162
|
+
scan() {
|
|
163
|
+
if (this.device.scanDuration) {
|
|
164
|
+
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
165
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
166
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
170
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
171
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
160
176
|
logs() {
|
|
161
177
|
if (this.platform.debugMode) {
|
|
162
178
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
163
|
-
this.warnLog(`
|
|
179
|
+
this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
164
180
|
} else if (this.device.logging) {
|
|
165
181
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
166
182
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
167
|
-
this.warnLog(`
|
|
183
|
+
this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
168
184
|
}
|
|
169
185
|
} else if (this.platform.config.options?.logging) {
|
|
170
186
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
171
187
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
172
|
-
this.warnLog(`
|
|
188
|
+
this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
173
189
|
}
|
|
174
190
|
} else {
|
|
175
191
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
@@ -293,8 +309,8 @@ export class Contact {
|
|
|
293
309
|
this.debugLog(`Contact Sensor: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
294
310
|
}
|
|
295
311
|
};
|
|
296
|
-
// Wait
|
|
297
|
-
return switchbot.wait(
|
|
312
|
+
// Wait 2 seconds
|
|
313
|
+
return switchbot.wait(this.scanDuration * 1000);
|
|
298
314
|
}).then(async () => {
|
|
299
315
|
// Stop to monitor
|
|
300
316
|
switchbot.stopScan();
|
package/src/devices/curtains.ts
CHANGED
|
@@ -42,6 +42,7 @@ export class Curtain {
|
|
|
42
42
|
curtainRefreshRate!: number;
|
|
43
43
|
set_minLux!: number;
|
|
44
44
|
set_maxLux!: number;
|
|
45
|
+
scanDuration!: number;
|
|
45
46
|
deviceLogging!: string;
|
|
46
47
|
deviceRefreshRate!: number;
|
|
47
48
|
spaceBetweenLevels!: number;
|
|
@@ -56,9 +57,10 @@ export class Curtain {
|
|
|
56
57
|
public device: device & devicesConfig,
|
|
57
58
|
) {
|
|
58
59
|
// default placeholders
|
|
59
|
-
this.refreshRate();
|
|
60
60
|
this.logs();
|
|
61
|
+
this.scan();
|
|
61
62
|
this.setMinMax();
|
|
63
|
+
this.refreshRate();
|
|
62
64
|
this.CurrentPosition = 0;
|
|
63
65
|
this.TargetPosition = 0;
|
|
64
66
|
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
@@ -219,19 +221,33 @@ export class Curtain {
|
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
223
|
|
|
224
|
+
scan() {
|
|
225
|
+
if (this.device.scanDuration) {
|
|
226
|
+
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
227
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
228
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
232
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
233
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
222
238
|
logs() {
|
|
223
239
|
if (this.platform.debugMode) {
|
|
224
240
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
225
|
-
this.warnLog(`
|
|
241
|
+
this.warnLog(`Curtain: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
226
242
|
} else if (this.device.logging) {
|
|
227
243
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
228
244
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
229
|
-
this.warnLog(`
|
|
245
|
+
this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
230
246
|
}
|
|
231
247
|
} else if (this.platform.config.options?.logging) {
|
|
232
248
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
233
249
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
234
|
-
this.warnLog(`
|
|
250
|
+
this.warnLog(`Curtain: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
235
251
|
}
|
|
236
252
|
} else {
|
|
237
253
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
@@ -461,8 +477,8 @@ export class Curtain {
|
|
|
461
477
|
this.debugLog(`Curtain: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
462
478
|
}
|
|
463
479
|
};
|
|
464
|
-
// Wait
|
|
465
|
-
return switchbot.wait(
|
|
480
|
+
// Wait 2 seconds
|
|
481
|
+
return switchbot.wait(this.scanDuration * 1000);
|
|
466
482
|
}).then(async () => {
|
|
467
483
|
// Stop to monitor
|
|
468
484
|
switchbot.stopScan();
|
|
@@ -37,6 +37,7 @@ export class Humidifier {
|
|
|
37
37
|
|
|
38
38
|
// Config
|
|
39
39
|
set_minStep?: number;
|
|
40
|
+
scanDuration!: number;
|
|
40
41
|
deviceLogging!: string;
|
|
41
42
|
deviceRefreshRate!: number;
|
|
42
43
|
|
|
@@ -50,8 +51,9 @@ export class Humidifier {
|
|
|
50
51
|
public device: device & devicesConfig,
|
|
51
52
|
) {
|
|
52
53
|
// default placeholders
|
|
53
|
-
this.refreshRate();
|
|
54
54
|
this.logs();
|
|
55
|
+
this.scan();
|
|
56
|
+
this.refreshRate();
|
|
55
57
|
this.CurrentRelativeHumidity = 0;
|
|
56
58
|
this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
57
59
|
this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
@@ -204,19 +206,33 @@ export class Humidifier {
|
|
|
204
206
|
}
|
|
205
207
|
}
|
|
206
208
|
|
|
209
|
+
scan() {
|
|
210
|
+
if (this.device.scanDuration) {
|
|
211
|
+
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
212
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
213
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
217
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
218
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
207
223
|
logs() {
|
|
208
224
|
if (this.platform.debugMode) {
|
|
209
225
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
210
|
-
this.warnLog(`
|
|
226
|
+
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
211
227
|
} else if (this.device.logging) {
|
|
212
228
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
213
229
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
214
|
-
this.warnLog(`
|
|
230
|
+
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
215
231
|
}
|
|
216
232
|
} else if (this.platform.config.options?.logging) {
|
|
217
233
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
218
234
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
219
|
-
this.warnLog(`
|
|
235
|
+
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
220
236
|
}
|
|
221
237
|
} else {
|
|
222
238
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
@@ -358,8 +374,8 @@ export class Humidifier {
|
|
|
358
374
|
this.debugLog(`Humidifier: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
359
375
|
}
|
|
360
376
|
};
|
|
361
|
-
// Wait
|
|
362
|
-
return switchbot.wait(
|
|
377
|
+
// Wait 2 seconds
|
|
378
|
+
return switchbot.wait(this.scanDuration * 1000);
|
|
363
379
|
}).then(async () => {
|
|
364
380
|
// Stop to monitor
|
|
365
381
|
switchbot.stopScan();
|
package/src/devices/meters.ts
CHANGED
|
@@ -40,6 +40,7 @@ export class Meter {
|
|
|
40
40
|
humidity!: serviceData['humidity'];
|
|
41
41
|
|
|
42
42
|
// Config
|
|
43
|
+
scanDuration!: number;
|
|
43
44
|
deviceLogging!: string;
|
|
44
45
|
deviceRefreshRate!: number;
|
|
45
46
|
|
|
@@ -53,8 +54,9 @@ export class Meter {
|
|
|
53
54
|
public device: device & devicesConfig,
|
|
54
55
|
) {
|
|
55
56
|
// default placeholders
|
|
56
|
-
this.refreshRate();
|
|
57
57
|
this.logs();
|
|
58
|
+
this.scan();
|
|
59
|
+
this.refreshRate();
|
|
58
60
|
if (this.BatteryLevel === undefined) {
|
|
59
61
|
this.BatteryLevel = 100;
|
|
60
62
|
} else {
|
|
@@ -194,19 +196,33 @@ export class Meter {
|
|
|
194
196
|
}
|
|
195
197
|
}
|
|
196
198
|
|
|
199
|
+
scan() {
|
|
200
|
+
if (this.device.scanDuration) {
|
|
201
|
+
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
202
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
203
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
207
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
208
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
197
213
|
logs() {
|
|
198
214
|
if (this.platform.debugMode) {
|
|
199
215
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
200
|
-
this.warnLog(`
|
|
216
|
+
this.warnLog(`Meter: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
201
217
|
} else if (this.device.logging) {
|
|
202
218
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
203
219
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
204
|
-
this.warnLog(`
|
|
220
|
+
this.warnLog(`Meter: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
205
221
|
}
|
|
206
222
|
} else if (this.platform.config.options?.logging) {
|
|
207
223
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
208
224
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
209
|
-
this.warnLog(`
|
|
225
|
+
this.warnLog(`Meter: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
210
226
|
}
|
|
211
227
|
} else {
|
|
212
228
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
@@ -324,7 +340,7 @@ export class Meter {
|
|
|
324
340
|
}
|
|
325
341
|
};
|
|
326
342
|
// Wait 10 seconds
|
|
327
|
-
return switchbot.wait(
|
|
343
|
+
return switchbot.wait(this.scanDuration * 1000);
|
|
328
344
|
}).then(async () => {
|
|
329
345
|
// Stop to monitor
|
|
330
346
|
switchbot.stopScan();
|
package/src/devices/motion.ts
CHANGED
|
@@ -34,6 +34,7 @@ export class Motion {
|
|
|
34
34
|
lightLevel!: serviceData['lightLevel'];
|
|
35
35
|
|
|
36
36
|
// Config
|
|
37
|
+
scanDuration!: number;
|
|
37
38
|
deviceLogging!: string;
|
|
38
39
|
deviceRefreshRate!: number;
|
|
39
40
|
|
|
@@ -47,8 +48,9 @@ export class Motion {
|
|
|
47
48
|
public device: device & devicesConfig,
|
|
48
49
|
) {
|
|
49
50
|
// default placeholders
|
|
50
|
-
this.refreshRate();
|
|
51
51
|
this.logs();
|
|
52
|
+
this.scan();
|
|
53
|
+
this.refreshRate();
|
|
52
54
|
this.MotionDetected = false;
|
|
53
55
|
|
|
54
56
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
@@ -125,19 +127,33 @@ export class Motion {
|
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
|
|
130
|
+
scan() {
|
|
131
|
+
if (this.device.scanDuration) {
|
|
132
|
+
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
133
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
134
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
138
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
139
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
128
144
|
logs() {
|
|
129
145
|
if (this.platform.debugMode) {
|
|
130
146
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
131
|
-
this.warnLog(`
|
|
147
|
+
this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
132
148
|
} else if (this.device.logging) {
|
|
133
149
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
134
150
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
135
|
-
this.warnLog(`
|
|
151
|
+
this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
136
152
|
}
|
|
137
153
|
} else if (this.platform.config.options?.logging) {
|
|
138
154
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
139
155
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
140
|
-
this.warnLog(`
|
|
156
|
+
this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
141
157
|
}
|
|
142
158
|
} else {
|
|
143
159
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
@@ -231,7 +247,7 @@ export class Motion {
|
|
|
231
247
|
}
|
|
232
248
|
};
|
|
233
249
|
// Wait 10 seconds
|
|
234
|
-
return switchbot.wait(
|
|
250
|
+
return switchbot.wait(this.scanDuration * 1000);
|
|
235
251
|
}).then(async () => {
|
|
236
252
|
// Stop to monitor
|
|
237
253
|
switchbot.stopScan();
|
package/src/devices/plugs.ts
CHANGED
|
@@ -18,6 +18,7 @@ export class Plug {
|
|
|
18
18
|
deviceStatus!: deviceStatusResponse;
|
|
19
19
|
|
|
20
20
|
// Config
|
|
21
|
+
scanDuration!: number;
|
|
21
22
|
deviceLogging!: string;
|
|
22
23
|
deviceRefreshRate!: number;
|
|
23
24
|
|
|
@@ -31,8 +32,9 @@ export class Plug {
|
|
|
31
32
|
public device: device & devicesConfig,
|
|
32
33
|
) {
|
|
33
34
|
// default placeholders
|
|
34
|
-
this.refreshRate();
|
|
35
35
|
this.logs();
|
|
36
|
+
this.scan();
|
|
37
|
+
this.refreshRate();
|
|
36
38
|
if (this.On === undefined) {
|
|
37
39
|
this.On = false;
|
|
38
40
|
} else {
|
|
@@ -128,19 +130,33 @@ export class Plug {
|
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
|
|
133
|
+
scan() {
|
|
134
|
+
if (this.device.scanDuration) {
|
|
135
|
+
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
136
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
137
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
141
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
142
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
131
147
|
logs() {
|
|
132
148
|
if (this.platform.debugMode) {
|
|
133
149
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
134
|
-
this.warnLog(`
|
|
150
|
+
this.warnLog(`Plug: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
135
151
|
} else if (this.device.logging) {
|
|
136
152
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
137
153
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
138
|
-
this.warnLog(`
|
|
154
|
+
this.warnLog(`Plug: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
139
155
|
}
|
|
140
156
|
} else if (this.platform.config.options?.logging) {
|
|
141
157
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
142
158
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
143
|
-
this.warnLog(`
|
|
159
|
+
this.warnLog(`Plug: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
144
160
|
}
|
|
145
161
|
} else {
|
|
146
162
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
@@ -169,16 +169,16 @@ export class AirConditioner {
|
|
|
169
169
|
logs() {
|
|
170
170
|
if (this.platform.debugMode) {
|
|
171
171
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
172
|
-
this.warnLog(`
|
|
172
|
+
this.warnLog(`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
173
173
|
} else if (this.device.logging) {
|
|
174
174
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
175
175
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
176
|
-
this.warnLog(`
|
|
176
|
+
this.warnLog(`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
177
177
|
}
|
|
178
178
|
} else if (this.platform.config.options?.logging) {
|
|
179
179
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
180
180
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
181
|
-
this.warnLog(`
|
|
181
|
+
this.warnLog(`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
182
182
|
}
|
|
183
183
|
} else {
|
|
184
184
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
@@ -90,16 +90,16 @@ export class AirPurifier {
|
|
|
90
90
|
logs() {
|
|
91
91
|
if (this.platform.debugMode) {
|
|
92
92
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
93
|
-
this.warnLog(`
|
|
93
|
+
this.warnLog(`Air Purifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
94
94
|
} else if (this.device.logging) {
|
|
95
95
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
96
96
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
97
|
-
this.warnLog(`
|
|
97
|
+
this.warnLog(`Air Purifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
98
98
|
}
|
|
99
99
|
} else if (this.platform.config.options?.logging) {
|
|
100
100
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
101
101
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
102
|
-
this.warnLog(`
|
|
102
|
+
this.warnLog(`Air Purifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
103
103
|
}
|
|
104
104
|
} else {
|
|
105
105
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
package/src/irdevices/cameras.ts
CHANGED
|
@@ -60,16 +60,16 @@ export class Camera {
|
|
|
60
60
|
logs() {
|
|
61
61
|
if (this.platform.debugMode) {
|
|
62
62
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
63
|
-
this.warnLog(`
|
|
63
|
+
this.warnLog(`Camera: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
64
64
|
} else if (this.device.logging) {
|
|
65
65
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
66
66
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
67
|
-
this.warnLog(`
|
|
67
|
+
this.warnLog(`Camera: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
68
68
|
}
|
|
69
69
|
} else if (this.platform.config.options?.logging) {
|
|
70
70
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
71
71
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
72
|
-
this.warnLog(`
|
|
72
|
+
this.warnLog(`Camera: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
73
73
|
}
|
|
74
74
|
} else {
|
|
75
75
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
package/src/irdevices/fans.ts
CHANGED
|
@@ -119,16 +119,16 @@ export class Fan {
|
|
|
119
119
|
logs() {
|
|
120
120
|
if (this.platform.debugMode) {
|
|
121
121
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
122
|
-
this.warnLog(`
|
|
122
|
+
this.warnLog(`Fan: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
123
123
|
} else if (this.device.logging) {
|
|
124
124
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
125
125
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
126
|
-
this.warnLog(`
|
|
126
|
+
this.warnLog(`Fan: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
127
127
|
}
|
|
128
128
|
} else if (this.platform.config.options?.logging) {
|
|
129
129
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
130
130
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
131
|
-
this.warnLog(`
|
|
131
|
+
this.warnLog(`Fan: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
132
132
|
}
|
|
133
133
|
} else {
|
|
134
134
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
package/src/irdevices/lights.ts
CHANGED
|
@@ -75,16 +75,16 @@ export class Light {
|
|
|
75
75
|
logs() {
|
|
76
76
|
if (this.platform.debugMode) {
|
|
77
77
|
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
78
|
-
this.warnLog(`
|
|
78
|
+
this.warnLog(`Light: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
79
79
|
} else if (this.device.logging) {
|
|
80
80
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
81
81
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
82
|
-
this.warnLog(`
|
|
82
|
+
this.warnLog(`Light: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
83
83
|
}
|
|
84
84
|
} else if (this.platform.config.options?.logging) {
|
|
85
85
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
86
86
|
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
87
|
-
this.warnLog(`
|
|
87
|
+
this.warnLog(`Light: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
88
88
|
}
|
|
89
89
|
} else {
|
|
90
90
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|