@switchbot/homebridge-switchbot 1.8.0 → 1.8.1-beta.3
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 +7 -0
- package/dist/devices/bots.d.ts +15 -15
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +162 -159
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +5 -5
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +69 -66
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +8 -8
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +81 -78
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +7 -7
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +105 -113
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +5 -5
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +75 -79
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +4 -4
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +63 -60
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +6 -6
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +81 -78
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +4 -4
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +63 -60
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +2 -2
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +30 -27
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +2 -2
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +30 -27
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +2 -2
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +30 -27
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +2 -2
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +30 -27
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +2 -2
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +30 -27
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +3 -3
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +41 -38
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +2 -2
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +30 -27
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +2 -2
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +30 -27
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +2 -2
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +30 -27
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/package.json +71 -71
- package/src/devices/bots.ts +169 -166
- package/src/devices/colorbulb.ts +68 -65
- package/src/devices/contact.ts +82 -79
- package/src/devices/curtains.ts +103 -111
- package/src/devices/humidifiers.ts +74 -78
- package/src/devices/meters.ts +62 -59
- package/src/devices/motion.ts +80 -77
- package/src/devices/plugs.ts +62 -59
- package/src/irdevices/airconditioners.ts +29 -26
- package/src/irdevices/airpurifiers.ts +29 -26
- package/src/irdevices/cameras.ts +29 -26
- package/src/irdevices/fans.ts +29 -26
- package/src/irdevices/lights.ts +29 -26
- package/src/irdevices/others.ts +40 -37
- package/src/irdevices/tvs.ts +29 -26
- package/src/irdevices/vacuumcleaners.ts +29 -26
- package/src/irdevices/waterheaters.ts +29 -26
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)
|
|
4
4
|
|
|
5
|
+
## [Version 1.8.1](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.8.1) (2022-01-14)
|
|
6
|
+
|
|
7
|
+
## What's Changed
|
|
8
|
+
* Fixed Bug: Cannot set properties of undefined (setting 'logging')
|
|
9
|
+
|
|
10
|
+
**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.8.0...v1.8.1
|
|
11
|
+
|
|
5
12
|
## [Version 1.8.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.8.0) (2022-01-14)
|
|
6
13
|
|
|
7
14
|
## What's Changed
|
package/dist/devices/bots.d.ts
CHANGED
|
@@ -43,21 +43,6 @@ export declare class Bot {
|
|
|
43
43
|
botUpdateInProgress: boolean;
|
|
44
44
|
doBotUpdate: Subject<void>;
|
|
45
45
|
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: device & devicesConfig);
|
|
46
|
-
removeOutletService(accessory: PlatformAccessory): void;
|
|
47
|
-
removeGarageDoorService(accessory: PlatformAccessory): void;
|
|
48
|
-
removeDoorService(accessory: PlatformAccessory): void;
|
|
49
|
-
removeLockService(accessory: PlatformAccessory): void;
|
|
50
|
-
removeFaucetService(accessory: PlatformAccessory): void;
|
|
51
|
-
removeFanService(accessory: PlatformAccessory): void;
|
|
52
|
-
removeWindowService(accessory: PlatformAccessory): void;
|
|
53
|
-
removeWindowCoveringService(accessory: PlatformAccessory): void;
|
|
54
|
-
removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): void;
|
|
55
|
-
removeSwitchService(accessory: PlatformAccessory): void;
|
|
56
|
-
config(device: device & devicesConfig): void;
|
|
57
|
-
refreshRate(device: device & devicesConfig): void;
|
|
58
|
-
scan(device: device & devicesConfig): void;
|
|
59
|
-
logs(device: device & devicesConfig): void;
|
|
60
|
-
PressOrSwitch(): void;
|
|
61
46
|
/**
|
|
62
47
|
* Parse the device status from the SwitchBot api
|
|
63
48
|
*/
|
|
@@ -92,6 +77,21 @@ export declare class Bot {
|
|
|
92
77
|
* Handle requests to set the "On" characteristic
|
|
93
78
|
*/
|
|
94
79
|
private handleOnSet;
|
|
80
|
+
config(device: device & devicesConfig): void;
|
|
81
|
+
refreshRate(device: device & devicesConfig): void;
|
|
82
|
+
scan(device: device & devicesConfig): void;
|
|
83
|
+
logs(device: device & devicesConfig): void;
|
|
84
|
+
PressOrSwitch(device: device & devicesConfig): void;
|
|
85
|
+
removeOutletService(accessory: PlatformAccessory): void;
|
|
86
|
+
removeGarageDoorService(accessory: PlatformAccessory): void;
|
|
87
|
+
removeDoorService(accessory: PlatformAccessory): void;
|
|
88
|
+
removeLockService(accessory: PlatformAccessory): void;
|
|
89
|
+
removeFaucetService(accessory: PlatformAccessory): void;
|
|
90
|
+
removeFanService(accessory: PlatformAccessory): void;
|
|
91
|
+
removeWindowService(accessory: PlatformAccessory): void;
|
|
92
|
+
removeWindowCoveringService(accessory: PlatformAccessory): void;
|
|
93
|
+
removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): void;
|
|
94
|
+
removeSwitchService(accessory: PlatformAccessory): void;
|
|
95
95
|
/**
|
|
96
96
|
* Logging for Device
|
|
97
97
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bots.d.ts","sourceRoot":"","sources":["../../src/devices/bots.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,O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EAAE,MAAM,GAAG,aAAa;IAcnC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAgBnC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAgBrC,mBAAmB,CAAC,SAAS,EAAE,iBAAiB;IAShD,uBAAuB,CAAC,SAAS,EAAE,iBAAiB;IASpD,iBAAiB,CAAC,SAAS,EAAE,iBAAiB;IAS9C,iBAAiB,CAAC,SAAS,EAAE,iBAAiB;IAS9C,mBAAmB,CAAC,SAAS,EAAE,iBAAiB;IAShD,gBAAgB,CAAC,SAAS,EAAE,iBAAiB;IAS7C,mBAAmB,CAAC,SAAS,EAAE,iBAAiB;IAShD,2BAA2B,CAAC,SAAS,EAAE,iBAAiB;IASxD,uCAAuC,CAAC,SAAS,EAAE,iBAAiB;IASpE,mBAAmB,CAAC,SAAS,EAAE,iBAAiB;IASvD;;KAEC;IACD,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAMrB,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAMrB,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAMtB,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAUtB,qBAAqB,IAAI,OAAO;CAGjC"}
|
package/dist/devices/bots.js
CHANGED
|
@@ -18,7 +18,7 @@ class Bot {
|
|
|
18
18
|
this.logs(device);
|
|
19
19
|
this.scan(device);
|
|
20
20
|
this.refreshRate(device);
|
|
21
|
-
this.PressOrSwitch();
|
|
21
|
+
this.PressOrSwitch(device);
|
|
22
22
|
this.config(device);
|
|
23
23
|
if (this.On === undefined) {
|
|
24
24
|
this.On = false;
|
|
@@ -304,164 +304,6 @@ class Bot {
|
|
|
304
304
|
this.botUpdateInProgress = false;
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
|
-
removeOutletService(accessory) {
|
|
308
|
-
// If outletService still pressent, then remove first
|
|
309
|
-
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
310
|
-
if (this.outletService) {
|
|
311
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
312
|
-
}
|
|
313
|
-
accessory.removeService(this.outletService);
|
|
314
|
-
}
|
|
315
|
-
removeGarageDoorService(accessory) {
|
|
316
|
-
// If garageDoorService still pressent, then remove first
|
|
317
|
-
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
318
|
-
if (this.garageDoorService) {
|
|
319
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
320
|
-
}
|
|
321
|
-
accessory.removeService(this.garageDoorService);
|
|
322
|
-
}
|
|
323
|
-
removeDoorService(accessory) {
|
|
324
|
-
// If doorService still pressent, then remove first
|
|
325
|
-
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
326
|
-
if (this.doorService) {
|
|
327
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
|
|
328
|
-
}
|
|
329
|
-
accessory.removeService(this.doorService);
|
|
330
|
-
}
|
|
331
|
-
removeLockService(accessory) {
|
|
332
|
-
// If lockService still pressent, then remove first
|
|
333
|
-
this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
|
|
334
|
-
if (this.lockService) {
|
|
335
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
336
|
-
}
|
|
337
|
-
accessory.removeService(this.lockService);
|
|
338
|
-
}
|
|
339
|
-
removeFaucetService(accessory) {
|
|
340
|
-
// If faucetService still pressent, then remove first
|
|
341
|
-
this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
|
|
342
|
-
if (this.faucetService) {
|
|
343
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
344
|
-
}
|
|
345
|
-
accessory.removeService(this.faucetService);
|
|
346
|
-
}
|
|
347
|
-
removeFanService(accessory) {
|
|
348
|
-
// If fanService still pressent, then remove first
|
|
349
|
-
this.fanService = this.accessory.getService(this.platform.Service.Fan);
|
|
350
|
-
if (this.fanService) {
|
|
351
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
352
|
-
}
|
|
353
|
-
accessory.removeService(this.fanService);
|
|
354
|
-
}
|
|
355
|
-
removeWindowService(accessory) {
|
|
356
|
-
// If windowService still pressent, then remove first
|
|
357
|
-
this.windowService = this.accessory.getService(this.platform.Service.Window);
|
|
358
|
-
if (this.windowService) {
|
|
359
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
|
|
360
|
-
}
|
|
361
|
-
accessory.removeService(this.windowService);
|
|
362
|
-
}
|
|
363
|
-
removeWindowCoveringService(accessory) {
|
|
364
|
-
// If windowCoveringService still pressent, then remove first
|
|
365
|
-
this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
|
|
366
|
-
if (this.windowCoveringService) {
|
|
367
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
368
|
-
}
|
|
369
|
-
accessory.removeService(this.windowCoveringService);
|
|
370
|
-
}
|
|
371
|
-
removeStatefulProgrammableSwitchService(accessory) {
|
|
372
|
-
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
373
|
-
this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
|
|
374
|
-
if (this.statefulProgrammableSwitchService) {
|
|
375
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
376
|
-
}
|
|
377
|
-
accessory.removeService(this.statefulProgrammableSwitchService);
|
|
378
|
-
}
|
|
379
|
-
removeSwitchService(accessory) {
|
|
380
|
-
// If switchService still pressent, then remove first
|
|
381
|
-
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
382
|
-
if (this.switchService) {
|
|
383
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
384
|
-
}
|
|
385
|
-
accessory.removeService(this.switchService);
|
|
386
|
-
}
|
|
387
|
-
config(device) {
|
|
388
|
-
const config = device.bot;
|
|
389
|
-
if (device.ble !== undefined) {
|
|
390
|
-
config['ble'] = device.ble;
|
|
391
|
-
}
|
|
392
|
-
if (device.logging !== undefined) {
|
|
393
|
-
config['logging'] = device.logging;
|
|
394
|
-
}
|
|
395
|
-
if (device.refreshRate !== undefined) {
|
|
396
|
-
config['refreshRate'] = device.refreshRate;
|
|
397
|
-
}
|
|
398
|
-
if (device.scanDuration !== undefined) {
|
|
399
|
-
config['scanDuration'] = device.scanDuration;
|
|
400
|
-
}
|
|
401
|
-
if (config !== undefined) {
|
|
402
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
refreshRate(device) {
|
|
406
|
-
if (device.refreshRate) {
|
|
407
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
408
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
409
|
-
}
|
|
410
|
-
else if (this.platform.config.options.refreshRate) {
|
|
411
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
|
|
412
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
scan(device) {
|
|
416
|
-
if (device.scanDuration) {
|
|
417
|
-
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
418
|
-
if (device.ble) {
|
|
419
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
else {
|
|
423
|
-
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
424
|
-
if (this.device.ble) {
|
|
425
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
logs(device) {
|
|
430
|
-
if (this.platform.debugMode) {
|
|
431
|
-
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
432
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
433
|
-
}
|
|
434
|
-
else if (device.logging) {
|
|
435
|
-
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
436
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
437
|
-
}
|
|
438
|
-
else if (this.platform.config.options?.logging) {
|
|
439
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
440
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
441
|
-
}
|
|
442
|
-
else {
|
|
443
|
-
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
444
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
PressOrSwitch() {
|
|
448
|
-
if (!this.device.bot?.mode) {
|
|
449
|
-
this.botMode = 'switch';
|
|
450
|
-
this.warnLog(`Bot: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
|
|
451
|
-
this.warnLog(`Bot: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
|
|
452
|
-
}
|
|
453
|
-
else if (this.device.bot?.mode === 'switch') {
|
|
454
|
-
this.botMode = 'switch';
|
|
455
|
-
this.infoLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
|
|
456
|
-
}
|
|
457
|
-
else if (this.device.bot?.mode === 'press') {
|
|
458
|
-
this.botMode = 'press';
|
|
459
|
-
this.infoLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
|
|
460
|
-
}
|
|
461
|
-
else {
|
|
462
|
-
throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
307
|
/**
|
|
466
308
|
* Parse the device status from the SwitchBot api
|
|
467
309
|
*/
|
|
@@ -1130,6 +972,167 @@ class Bot {
|
|
|
1130
972
|
}
|
|
1131
973
|
this.doBotUpdate.next();
|
|
1132
974
|
}
|
|
975
|
+
config(device) {
|
|
976
|
+
let config = {};
|
|
977
|
+
if (device.bot) {
|
|
978
|
+
config = device.bot;
|
|
979
|
+
}
|
|
980
|
+
if (device.ble) {
|
|
981
|
+
config['ble'] = device.ble;
|
|
982
|
+
}
|
|
983
|
+
if (device.logging !== undefined) {
|
|
984
|
+
config['logging'] = device.logging;
|
|
985
|
+
}
|
|
986
|
+
if (device.refreshRate !== undefined) {
|
|
987
|
+
config['refreshRate'] = device.refreshRate;
|
|
988
|
+
}
|
|
989
|
+
if (device.scanDuration !== undefined) {
|
|
990
|
+
config['scanDuration'] = device.scanDuration;
|
|
991
|
+
}
|
|
992
|
+
if (config !== undefined) {
|
|
993
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
refreshRate(device) {
|
|
997
|
+
if (device.refreshRate) {
|
|
998
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
999
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
1000
|
+
}
|
|
1001
|
+
else if (this.platform.config.options.refreshRate) {
|
|
1002
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
|
|
1003
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
scan(device) {
|
|
1007
|
+
if (device.scanDuration) {
|
|
1008
|
+
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
1009
|
+
if (device.ble) {
|
|
1010
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
else {
|
|
1014
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
1015
|
+
if (this.device.ble) {
|
|
1016
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
logs(device) {
|
|
1021
|
+
if (this.platform.debugMode) {
|
|
1022
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
1023
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
1024
|
+
}
|
|
1025
|
+
else if (device.logging) {
|
|
1026
|
+
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
1027
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
1028
|
+
}
|
|
1029
|
+
else if (this.platform.config.options?.logging) {
|
|
1030
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
1031
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
1032
|
+
}
|
|
1033
|
+
else {
|
|
1034
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
1035
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
PressOrSwitch(device) {
|
|
1039
|
+
if (!device.bot?.mode) {
|
|
1040
|
+
this.botMode = 'switch';
|
|
1041
|
+
this.warnLog(`Bot: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
|
|
1042
|
+
this.warnLog(`Bot: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
|
|
1043
|
+
}
|
|
1044
|
+
else if (device.bot?.mode === 'switch') {
|
|
1045
|
+
this.botMode = 'switch';
|
|
1046
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
|
|
1047
|
+
}
|
|
1048
|
+
else if (device.bot?.mode === 'press') {
|
|
1049
|
+
this.botMode = 'press';
|
|
1050
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
|
|
1051
|
+
}
|
|
1052
|
+
else {
|
|
1053
|
+
throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
removeOutletService(accessory) {
|
|
1057
|
+
// If outletService still pressent, then remove first
|
|
1058
|
+
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
1059
|
+
if (this.outletService) {
|
|
1060
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
1061
|
+
}
|
|
1062
|
+
accessory.removeService(this.outletService);
|
|
1063
|
+
}
|
|
1064
|
+
removeGarageDoorService(accessory) {
|
|
1065
|
+
// If garageDoorService still pressent, then remove first
|
|
1066
|
+
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
1067
|
+
if (this.garageDoorService) {
|
|
1068
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
1069
|
+
}
|
|
1070
|
+
accessory.removeService(this.garageDoorService);
|
|
1071
|
+
}
|
|
1072
|
+
removeDoorService(accessory) {
|
|
1073
|
+
// If doorService still pressent, then remove first
|
|
1074
|
+
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
1075
|
+
if (this.doorService) {
|
|
1076
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
|
|
1077
|
+
}
|
|
1078
|
+
accessory.removeService(this.doorService);
|
|
1079
|
+
}
|
|
1080
|
+
removeLockService(accessory) {
|
|
1081
|
+
// If lockService still pressent, then remove first
|
|
1082
|
+
this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
|
|
1083
|
+
if (this.lockService) {
|
|
1084
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
1085
|
+
}
|
|
1086
|
+
accessory.removeService(this.lockService);
|
|
1087
|
+
}
|
|
1088
|
+
removeFaucetService(accessory) {
|
|
1089
|
+
// If faucetService still pressent, then remove first
|
|
1090
|
+
this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
|
|
1091
|
+
if (this.faucetService) {
|
|
1092
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
1093
|
+
}
|
|
1094
|
+
accessory.removeService(this.faucetService);
|
|
1095
|
+
}
|
|
1096
|
+
removeFanService(accessory) {
|
|
1097
|
+
// If fanService still pressent, then remove first
|
|
1098
|
+
this.fanService = this.accessory.getService(this.platform.Service.Fan);
|
|
1099
|
+
if (this.fanService) {
|
|
1100
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
1101
|
+
}
|
|
1102
|
+
accessory.removeService(this.fanService);
|
|
1103
|
+
}
|
|
1104
|
+
removeWindowService(accessory) {
|
|
1105
|
+
// If windowService still pressent, then remove first
|
|
1106
|
+
this.windowService = this.accessory.getService(this.platform.Service.Window);
|
|
1107
|
+
if (this.windowService) {
|
|
1108
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
|
|
1109
|
+
}
|
|
1110
|
+
accessory.removeService(this.windowService);
|
|
1111
|
+
}
|
|
1112
|
+
removeWindowCoveringService(accessory) {
|
|
1113
|
+
// If windowCoveringService still pressent, then remove first
|
|
1114
|
+
this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
|
|
1115
|
+
if (this.windowCoveringService) {
|
|
1116
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
1117
|
+
}
|
|
1118
|
+
accessory.removeService(this.windowCoveringService);
|
|
1119
|
+
}
|
|
1120
|
+
removeStatefulProgrammableSwitchService(accessory) {
|
|
1121
|
+
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
1122
|
+
this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
|
|
1123
|
+
if (this.statefulProgrammableSwitchService) {
|
|
1124
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
1125
|
+
}
|
|
1126
|
+
accessory.removeService(this.statefulProgrammableSwitchService);
|
|
1127
|
+
}
|
|
1128
|
+
removeSwitchService(accessory) {
|
|
1129
|
+
// If switchService still pressent, then remove first
|
|
1130
|
+
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
1131
|
+
if (this.switchService) {
|
|
1132
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
1133
|
+
}
|
|
1134
|
+
accessory.removeService(this.switchService);
|
|
1135
|
+
}
|
|
1133
1136
|
/**
|
|
1134
1137
|
* Logging for Device
|
|
1135
1138
|
*/
|