@switchbot/homebridge-switchbot 1.7.1-beta.9 → 1.8.1-beta.2
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 +10 -1
- package/config.schema.json +3 -3
- package/dist/devices/bots.d.ts +15 -14
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +163 -154
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +5 -4
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +70 -61
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +8 -7
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +82 -74
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +8 -7
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +104 -101
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +5 -4
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +74 -62
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +4 -3
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +68 -56
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +6 -5
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +82 -70
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +4 -3
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +64 -52
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +2 -1
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +29 -22
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +4 -3
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +33 -26
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +2 -1
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +29 -22
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +2 -1
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +29 -22
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +2 -1
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +29 -22
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +3 -2
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +41 -34
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +2 -1
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +29 -22
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +2 -1
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +29 -22
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +2 -1
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +29 -22
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/settings.d.ts +7 -1
- 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 +170 -162
- package/src/devices/colorbulb.ts +69 -61
- package/src/devices/contact.ts +83 -75
- package/src/devices/curtains.ts +103 -100
- package/src/devices/humidifiers.ts +73 -60
- package/src/devices/meters.ts +67 -54
- package/src/devices/motion.ts +81 -68
- package/src/devices/plugs.ts +63 -50
- package/src/irdevices/airconditioners.ts +28 -20
- package/src/irdevices/airpurifiers.ts +32 -24
- package/src/irdevices/cameras.ts +28 -20
- package/src/irdevices/fans.ts +28 -20
- package/src/irdevices/lights.ts +28 -20
- package/src/irdevices/others.ts +40 -32
- package/src/irdevices/tvs.ts +28 -20
- package/src/irdevices/vacuumcleaners.ts +28 -20
- package/src/irdevices/waterheaters.ts +28 -20
- package/src/settings.ts +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
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
|
-
## [
|
|
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
|
+
|
|
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
|
|
8
15
|
* Added option to display Bot a Stateful Programmable Switch.
|
|
@@ -15,6 +22,8 @@ All notable changes to this project will be documented in this file. This projec
|
|
|
15
22
|
* Fixed Bug: Battery Service wouldn't be removed from Curtain, Contact Sensor, or Motion Sensor when switching from BLE to OpenAPI.
|
|
16
23
|
* Enhancments: Made some improvemnt on the switch from BLE to OpenAPI when BLE connection fails.
|
|
17
24
|
* Enhancments: Made Optional Switchbot Device Settings and Optional IR Device Settings more managable by using Tabs.
|
|
25
|
+
* Change: Changed Curtain `refreshRate` to `updateRate`.
|
|
26
|
+
* You will have to update your config for it to pickup the new `updateRate`.
|
|
18
27
|
* Housekeeping and updated dependencies.
|
|
19
28
|
|
|
20
29
|
**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.7.0...v1.8.0
|
package/config.schema.json
CHANGED
|
@@ -322,8 +322,8 @@
|
|
|
322
322
|
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Curtain' && model.options.devices[arrayIndices].deviceId);"
|
|
323
323
|
}
|
|
324
324
|
},
|
|
325
|
-
"
|
|
326
|
-
"title": "Curtain
|
|
325
|
+
"updateRate": {
|
|
326
|
+
"title": "Curtain Update Rate",
|
|
327
327
|
"type": "number",
|
|
328
328
|
"minimum": 1,
|
|
329
329
|
"placeholder": 5,
|
|
@@ -908,7 +908,7 @@
|
|
|
908
908
|
"options.devices[].curtain.set_minStep",
|
|
909
909
|
"options.devices[].curtain.set_min",
|
|
910
910
|
"options.devices[].curtain.set_max",
|
|
911
|
-
"options.devices[].curtain.
|
|
911
|
+
"options.devices[].curtain.updateRate",
|
|
912
912
|
"options.devices[].curtain.disable_group",
|
|
913
913
|
"options.devices[].curtain.hide_lightsensor",
|
|
914
914
|
"options.devices[].curtain.set_minlux",
|
package/dist/devices/bots.d.ts
CHANGED
|
@@ -43,20 +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
|
-
refreshRate(): void;
|
|
57
|
-
scan(): void;
|
|
58
|
-
logs(): void;
|
|
59
|
-
PressOrSwitch(): void;
|
|
60
46
|
/**
|
|
61
47
|
* Parse the device status from the SwitchBot api
|
|
62
48
|
*/
|
|
@@ -91,6 +77,21 @@ export declare class Bot {
|
|
|
91
77
|
* Handle requests to set the "On" characteristic
|
|
92
78
|
*/
|
|
93
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;
|
|
94
95
|
/**
|
|
95
96
|
* Logging for Device
|
|
96
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,OAAO,EAAa,MAAM,EAAE,aAAa,EAA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AAI,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
|
@@ -15,10 +15,11 @@ class Bot {
|
|
|
15
15
|
this.accessory = accessory;
|
|
16
16
|
this.device = device;
|
|
17
17
|
// default placeholders
|
|
18
|
-
this.logs();
|
|
19
|
-
this.scan();
|
|
20
|
-
this.refreshRate();
|
|
21
|
-
this.PressOrSwitch();
|
|
18
|
+
this.logs(device);
|
|
19
|
+
this.scan(device);
|
|
20
|
+
this.refreshRate(device);
|
|
21
|
+
this.PressOrSwitch(device);
|
|
22
|
+
this.config(device);
|
|
22
23
|
if (this.On === undefined) {
|
|
23
24
|
this.On = false;
|
|
24
25
|
this.accessory.context.On = this.On;
|
|
@@ -35,9 +36,6 @@ class Bot {
|
|
|
35
36
|
}
|
|
36
37
|
this.BatteryLevel = 100;
|
|
37
38
|
this.StatusLowBattery = 0;
|
|
38
|
-
// Bot Config
|
|
39
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Config: (ble: ${device.ble}, offline: ${device.offline}, mode: ${device.bot?.mode},`
|
|
40
|
-
+ ` deviceType: ${device.bot?.deviceType}, doublePress: ${this.doublePress})`);
|
|
41
39
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
42
40
|
this.doBotUpdate = new rxjs_1.Subject();
|
|
43
41
|
this.botUpdateInProgress = false;
|
|
@@ -306,153 +304,6 @@ class Bot {
|
|
|
306
304
|
this.botUpdateInProgress = false;
|
|
307
305
|
});
|
|
308
306
|
}
|
|
309
|
-
removeOutletService(accessory) {
|
|
310
|
-
// If outletService still pressent, then remove first
|
|
311
|
-
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
312
|
-
if (this.outletService) {
|
|
313
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
314
|
-
}
|
|
315
|
-
accessory.removeService(this.outletService);
|
|
316
|
-
}
|
|
317
|
-
removeGarageDoorService(accessory) {
|
|
318
|
-
// If garageDoorService still pressent, then remove first
|
|
319
|
-
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
320
|
-
if (this.garageDoorService) {
|
|
321
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
322
|
-
}
|
|
323
|
-
accessory.removeService(this.garageDoorService);
|
|
324
|
-
}
|
|
325
|
-
removeDoorService(accessory) {
|
|
326
|
-
// If doorService still pressent, then remove first
|
|
327
|
-
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
328
|
-
if (this.doorService) {
|
|
329
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
|
|
330
|
-
}
|
|
331
|
-
accessory.removeService(this.doorService);
|
|
332
|
-
}
|
|
333
|
-
removeLockService(accessory) {
|
|
334
|
-
// If lockService still pressent, then remove first
|
|
335
|
-
this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
|
|
336
|
-
if (this.lockService) {
|
|
337
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
338
|
-
}
|
|
339
|
-
accessory.removeService(this.lockService);
|
|
340
|
-
}
|
|
341
|
-
removeFaucetService(accessory) {
|
|
342
|
-
// If faucetService still pressent, then remove first
|
|
343
|
-
this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
|
|
344
|
-
if (this.faucetService) {
|
|
345
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
346
|
-
}
|
|
347
|
-
accessory.removeService(this.faucetService);
|
|
348
|
-
}
|
|
349
|
-
removeFanService(accessory) {
|
|
350
|
-
// If fanService still pressent, then remove first
|
|
351
|
-
this.fanService = this.accessory.getService(this.platform.Service.Fan);
|
|
352
|
-
if (this.fanService) {
|
|
353
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
354
|
-
}
|
|
355
|
-
accessory.removeService(this.fanService);
|
|
356
|
-
}
|
|
357
|
-
removeWindowService(accessory) {
|
|
358
|
-
// If windowService still pressent, then remove first
|
|
359
|
-
this.windowService = this.accessory.getService(this.platform.Service.Window);
|
|
360
|
-
if (this.windowService) {
|
|
361
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
|
|
362
|
-
}
|
|
363
|
-
accessory.removeService(this.windowService);
|
|
364
|
-
}
|
|
365
|
-
removeWindowCoveringService(accessory) {
|
|
366
|
-
// If windowCoveringService still pressent, then remove first
|
|
367
|
-
this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
|
|
368
|
-
if (this.windowCoveringService) {
|
|
369
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
370
|
-
}
|
|
371
|
-
accessory.removeService(this.windowCoveringService);
|
|
372
|
-
}
|
|
373
|
-
removeStatefulProgrammableSwitchService(accessory) {
|
|
374
|
-
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
375
|
-
this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
|
|
376
|
-
if (this.statefulProgrammableSwitchService) {
|
|
377
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
378
|
-
}
|
|
379
|
-
accessory.removeService(this.statefulProgrammableSwitchService);
|
|
380
|
-
}
|
|
381
|
-
removeSwitchService(accessory) {
|
|
382
|
-
// If switchService still pressent, then remove first
|
|
383
|
-
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
384
|
-
if (this.switchService) {
|
|
385
|
-
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
386
|
-
}
|
|
387
|
-
accessory.removeService(this.switchService);
|
|
388
|
-
}
|
|
389
|
-
refreshRate() {
|
|
390
|
-
if (this.device.refreshRate) {
|
|
391
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
392
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
393
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
else if (this.platform.config.options.refreshRate) {
|
|
397
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
|
|
398
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
399
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
scan() {
|
|
404
|
-
if (this.device.scanDuration) {
|
|
405
|
-
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
406
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
407
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
else {
|
|
411
|
-
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
412
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
413
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
logs() {
|
|
418
|
-
if (this.platform.debugMode) {
|
|
419
|
-
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
420
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
421
|
-
}
|
|
422
|
-
else if (this.device.logging) {
|
|
423
|
-
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
424
|
-
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
425
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
else if (this.platform.config.options?.logging) {
|
|
429
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
430
|
-
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
431
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
PressOrSwitch() {
|
|
439
|
-
if (!this.device.bot?.mode) {
|
|
440
|
-
this.botMode = 'switch';
|
|
441
|
-
this.warnLog(`Bot: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
|
|
442
|
-
this.warnLog(`Bot: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
|
|
443
|
-
}
|
|
444
|
-
else if (this.device.bot?.mode === 'switch') {
|
|
445
|
-
this.botMode = 'switch';
|
|
446
|
-
this.infoLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
|
|
447
|
-
}
|
|
448
|
-
else if (this.device.bot?.mode === 'press') {
|
|
449
|
-
this.botMode = 'press';
|
|
450
|
-
this.infoLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
|
|
451
|
-
}
|
|
452
|
-
else {
|
|
453
|
-
throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
307
|
/**
|
|
457
308
|
* Parse the device status from the SwitchBot api
|
|
458
309
|
*/
|
|
@@ -1121,6 +972,164 @@ class Bot {
|
|
|
1121
972
|
}
|
|
1122
973
|
this.doBotUpdate.next();
|
|
1123
974
|
}
|
|
975
|
+
config(device) {
|
|
976
|
+
const config = device.bot;
|
|
977
|
+
if (device.ble) {
|
|
978
|
+
config['ble'] = device.ble;
|
|
979
|
+
}
|
|
980
|
+
if (device.logging !== undefined) {
|
|
981
|
+
config['logging'] = device.logging;
|
|
982
|
+
}
|
|
983
|
+
if (device.refreshRate !== undefined) {
|
|
984
|
+
config['refreshRate'] = device.refreshRate;
|
|
985
|
+
}
|
|
986
|
+
if (device.scanDuration !== undefined) {
|
|
987
|
+
config['scanDuration'] = device.scanDuration;
|
|
988
|
+
}
|
|
989
|
+
if (config !== undefined) {
|
|
990
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
refreshRate(device) {
|
|
994
|
+
if (device.refreshRate) {
|
|
995
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
996
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
997
|
+
}
|
|
998
|
+
else if (this.platform.config.options.refreshRate) {
|
|
999
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
|
|
1000
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
scan(device) {
|
|
1004
|
+
if (device.scanDuration) {
|
|
1005
|
+
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
1006
|
+
if (device.ble) {
|
|
1007
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
1012
|
+
if (this.device.ble) {
|
|
1013
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
logs(device) {
|
|
1018
|
+
if (this.platform.debugMode) {
|
|
1019
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
1020
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
1021
|
+
}
|
|
1022
|
+
else if (device.logging) {
|
|
1023
|
+
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
1024
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
1025
|
+
}
|
|
1026
|
+
else if (this.platform.config.options?.logging) {
|
|
1027
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
1028
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
1029
|
+
}
|
|
1030
|
+
else {
|
|
1031
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
1032
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
PressOrSwitch(device) {
|
|
1036
|
+
if (!device.bot?.mode) {
|
|
1037
|
+
this.botMode = 'switch';
|
|
1038
|
+
this.warnLog(`Bot: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
|
|
1039
|
+
this.warnLog(`Bot: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
|
|
1040
|
+
}
|
|
1041
|
+
else if (device.bot?.mode === 'switch') {
|
|
1042
|
+
this.botMode = 'switch';
|
|
1043
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
|
|
1044
|
+
}
|
|
1045
|
+
else if (device.bot?.mode === 'press') {
|
|
1046
|
+
this.botMode = 'press';
|
|
1047
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
|
|
1048
|
+
}
|
|
1049
|
+
else {
|
|
1050
|
+
throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
removeOutletService(accessory) {
|
|
1054
|
+
// If outletService still pressent, then remove first
|
|
1055
|
+
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
1056
|
+
if (this.outletService) {
|
|
1057
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
1058
|
+
}
|
|
1059
|
+
accessory.removeService(this.outletService);
|
|
1060
|
+
}
|
|
1061
|
+
removeGarageDoorService(accessory) {
|
|
1062
|
+
// If garageDoorService still pressent, then remove first
|
|
1063
|
+
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
1064
|
+
if (this.garageDoorService) {
|
|
1065
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
1066
|
+
}
|
|
1067
|
+
accessory.removeService(this.garageDoorService);
|
|
1068
|
+
}
|
|
1069
|
+
removeDoorService(accessory) {
|
|
1070
|
+
// If doorService still pressent, then remove first
|
|
1071
|
+
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
1072
|
+
if (this.doorService) {
|
|
1073
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
|
|
1074
|
+
}
|
|
1075
|
+
accessory.removeService(this.doorService);
|
|
1076
|
+
}
|
|
1077
|
+
removeLockService(accessory) {
|
|
1078
|
+
// If lockService still pressent, then remove first
|
|
1079
|
+
this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
|
|
1080
|
+
if (this.lockService) {
|
|
1081
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
1082
|
+
}
|
|
1083
|
+
accessory.removeService(this.lockService);
|
|
1084
|
+
}
|
|
1085
|
+
removeFaucetService(accessory) {
|
|
1086
|
+
// If faucetService still pressent, then remove first
|
|
1087
|
+
this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
|
|
1088
|
+
if (this.faucetService) {
|
|
1089
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
1090
|
+
}
|
|
1091
|
+
accessory.removeService(this.faucetService);
|
|
1092
|
+
}
|
|
1093
|
+
removeFanService(accessory) {
|
|
1094
|
+
// If fanService still pressent, then remove first
|
|
1095
|
+
this.fanService = this.accessory.getService(this.platform.Service.Fan);
|
|
1096
|
+
if (this.fanService) {
|
|
1097
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
1098
|
+
}
|
|
1099
|
+
accessory.removeService(this.fanService);
|
|
1100
|
+
}
|
|
1101
|
+
removeWindowService(accessory) {
|
|
1102
|
+
// If windowService still pressent, then remove first
|
|
1103
|
+
this.windowService = this.accessory.getService(this.platform.Service.Window);
|
|
1104
|
+
if (this.windowService) {
|
|
1105
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
|
|
1106
|
+
}
|
|
1107
|
+
accessory.removeService(this.windowService);
|
|
1108
|
+
}
|
|
1109
|
+
removeWindowCoveringService(accessory) {
|
|
1110
|
+
// If windowCoveringService still pressent, then remove first
|
|
1111
|
+
this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
|
|
1112
|
+
if (this.windowCoveringService) {
|
|
1113
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
1114
|
+
}
|
|
1115
|
+
accessory.removeService(this.windowCoveringService);
|
|
1116
|
+
}
|
|
1117
|
+
removeStatefulProgrammableSwitchService(accessory) {
|
|
1118
|
+
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
1119
|
+
this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
|
|
1120
|
+
if (this.statefulProgrammableSwitchService) {
|
|
1121
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
1122
|
+
}
|
|
1123
|
+
accessory.removeService(this.statefulProgrammableSwitchService);
|
|
1124
|
+
}
|
|
1125
|
+
removeSwitchService(accessory) {
|
|
1126
|
+
// If switchService still pressent, then remove first
|
|
1127
|
+
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
1128
|
+
if (this.switchService) {
|
|
1129
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
1130
|
+
}
|
|
1131
|
+
accessory.removeService(this.switchService);
|
|
1132
|
+
}
|
|
1124
1133
|
/**
|
|
1125
1134
|
* Logging for Device
|
|
1126
1135
|
*/
|