@switchbot/homebridge-switchbot 1.10.2-beta.7 → 1.11.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 +20 -3
- package/config.schema.json +49 -0
- package/dist/device/bot.d.ts +43 -40
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +26 -26
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts +25 -21
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +176 -140
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +15 -15
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +14 -13
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +25 -22
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +50 -37
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts +23 -20
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +38 -38
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +16 -13
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +17 -17
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +15 -15
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +11 -11
- package/dist/device/meter.js.map +1 -1
- package/dist/device/motion.d.ts +14 -14
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +13 -13
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +10 -7
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +19 -19
- package/dist/device/plug.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +22 -22
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +44 -44
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +12 -9
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +20 -20
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +10 -7
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +11 -11
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +12 -9
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +29 -29
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +10 -7
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +13 -13
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +12 -9
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +17 -17
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +13 -10
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +25 -25
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +10 -7
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +13 -13
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +10 -7
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +16 -16
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/settings.d.ts +4 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +76 -76
- package/src/device/bot.ts +50 -50
- package/src/device/colorbulb.ts +206 -157
- package/src/device/contact.ts +31 -30
- package/src/device/curtain.ts +68 -57
- package/src/device/humidifier.ts +65 -53
- package/src/device/lock.ts +25 -25
- package/src/device/meter.ts +25 -25
- package/src/device/motion.ts +27 -27
- package/src/device/plug.ts +22 -22
- package/src/irdevice/airconditioner.ts +54 -54
- package/src/irdevice/airpurifier.ts +30 -30
- package/src/irdevice/camera.ts +19 -19
- package/src/irdevice/fan.ts +40 -40
- package/src/irdevice/light.ts +23 -23
- package/src/irdevice/other.ts +25 -25
- package/src/irdevice/tv.ts +42 -42
- package/src/irdevice/vacuumcleaner.ts +21 -21
- package/src/irdevice/waterheater.ts +24 -24
- package/src/platform.ts +4 -4
- package/src/settings.ts +5 -1
package/package.json
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
"displayName": "Homebridge SwitchBot",
|
|
3
|
+
"name": "@switchbot/homebridge-switchbot",
|
|
4
|
+
"version": "1.11.2",
|
|
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
|
+
"author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"homebridge": "^1.4.0",
|
|
17
|
+
"node": "^14.18.3 || ^16.13.2"
|
|
18
|
+
},
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"check": "npm install && npm outdated",
|
|
22
|
+
"update": "ncu -u && npm update && npm install",
|
|
23
|
+
"lint": "eslint src/**.ts",
|
|
24
|
+
"watch": "npm run build && npm link && nodemon",
|
|
25
|
+
"build": "rimraf ./dist && tsc",
|
|
26
|
+
"prepublishOnly": "npm run lint && npm run build",
|
|
27
|
+
"postpublish": "npm run clean",
|
|
28
|
+
"clean": "rimraf ./dist",
|
|
29
|
+
"test": "eslint src/**.ts"
|
|
30
|
+
},
|
|
31
|
+
"funding": [
|
|
32
|
+
{
|
|
33
|
+
"type": "Paypal",
|
|
34
|
+
"url": "https://paypal.me/donavanbecker"
|
|
11
35
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"engines": {
|
|
16
|
-
"homebridge": "^1.4.0",
|
|
17
|
-
"node": "^14.18.3 || ^16.13.2"
|
|
18
|
-
},
|
|
19
|
-
"main": "dist/index.js",
|
|
20
|
-
"scripts": {
|
|
21
|
-
"check": "npm install && npm outdated",
|
|
22
|
-
"update": "ncu -u && npm update && npm install",
|
|
23
|
-
"lint": "eslint src/**.ts",
|
|
24
|
-
"watch": "npm run build && npm link && nodemon",
|
|
25
|
-
"build": "rimraf ./dist && tsc",
|
|
26
|
-
"prepublishOnly": "npm run lint && npm run build",
|
|
27
|
-
"postpublish": "npm run clean",
|
|
28
|
-
"clean": "rimraf ./dist",
|
|
29
|
-
"test": "eslint src/**.ts"
|
|
30
|
-
},
|
|
31
|
-
"funding": [
|
|
32
|
-
{
|
|
33
|
-
"type": "Paypal",
|
|
34
|
-
"url": "https://paypal.me/donavanbecker"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"type": "GitHub",
|
|
38
|
-
"url": "https://github.com/sponsors/donavanbecker"
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
"publishConfig": {
|
|
42
|
-
"access": "public"
|
|
43
|
-
},
|
|
44
|
-
"keywords": [
|
|
45
|
-
"homebridge-plugin",
|
|
46
|
-
"switchbot",
|
|
47
|
-
"humidifier",
|
|
48
|
-
"humidity",
|
|
49
|
-
"temperature",
|
|
50
|
-
"bot",
|
|
51
|
-
"curtains",
|
|
52
|
-
"windows",
|
|
53
|
-
"ble",
|
|
54
|
-
"ir"
|
|
55
|
-
],
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"@homebridge/plugin-ui-utils": "^0.0.19",
|
|
58
|
-
"axios": "^0.25.0",
|
|
59
|
-
"rxjs": "^7.5.2"
|
|
60
|
-
},
|
|
61
|
-
"devDependencies": {
|
|
62
|
-
"@types/node": "^17.0.12",
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
|
64
|
-
"@typescript-eslint/parser": "^5.10.1",
|
|
65
|
-
"eslint": "^8.7.0",
|
|
66
|
-
"eslint-config-prettier": "8.3.0",
|
|
67
|
-
"eslint-plugin-prettier": "4.0.0",
|
|
68
|
-
"homebridge": "^1.4.0",
|
|
69
|
-
"nodemon": "^2.0.15",
|
|
70
|
-
"npm-check-updates": "^12.2.1",
|
|
71
|
-
"prettier": "2.5.1",
|
|
72
|
-
"rimraf": "^3.0.2",
|
|
73
|
-
"ts-node": "^10.4.0",
|
|
74
|
-
"typescript": "^4.5.5",
|
|
75
|
-
"typescript-axios-wb": "^1.0.3"
|
|
76
|
-
},
|
|
77
|
-
"optionalDependencies": {
|
|
78
|
-
"node-switchbot": "^1.1.2"
|
|
36
|
+
{
|
|
37
|
+
"type": "GitHub",
|
|
38
|
+
"url": "https://github.com/sponsors/donavanbecker"
|
|
79
39
|
}
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"homebridge-plugin",
|
|
46
|
+
"switchbot",
|
|
47
|
+
"humidifier",
|
|
48
|
+
"humidity",
|
|
49
|
+
"temperature",
|
|
50
|
+
"bot",
|
|
51
|
+
"curtains",
|
|
52
|
+
"windows",
|
|
53
|
+
"ble",
|
|
54
|
+
"ir"
|
|
55
|
+
],
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@homebridge/plugin-ui-utils": "^0.0.19",
|
|
58
|
+
"axios": "^0.25.0",
|
|
59
|
+
"rxjs": "^7.5.2"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/node": "^17.0.13",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
|
64
|
+
"@typescript-eslint/parser": "^5.10.1",
|
|
65
|
+
"eslint": "^8.8.0",
|
|
66
|
+
"eslint-config-prettier": "8.3.0",
|
|
67
|
+
"eslint-plugin-prettier": "4.0.0",
|
|
68
|
+
"homebridge": "^1.4.0",
|
|
69
|
+
"nodemon": "^2.0.15",
|
|
70
|
+
"npm-check-updates": "^12.2.1",
|
|
71
|
+
"prettier": "2.5.1",
|
|
72
|
+
"rimraf": "^3.0.2",
|
|
73
|
+
"ts-node": "^10.4.0",
|
|
74
|
+
"typescript": "^4.5.5",
|
|
75
|
+
"typescript-axios-wb": "^1.0.3"
|
|
76
|
+
},
|
|
77
|
+
"optionalDependencies": {
|
|
78
|
+
"node-switchbot": "^1.1.2"
|
|
79
|
+
}
|
|
80
80
|
}
|
package/src/device/bot.ts
CHANGED
|
@@ -12,17 +12,17 @@ import { DeviceURL, device, devicesConfig, serviceData, ad, switchbot, deviceSta
|
|
|
12
12
|
*/
|
|
13
13
|
export class Bot {
|
|
14
14
|
// Services
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
fanService?: Service;
|
|
16
|
+
doorService?: Service;
|
|
17
|
+
lockService?: Service;
|
|
18
|
+
faucetService?: Service;
|
|
19
|
+
windowService?: Service;
|
|
20
|
+
switchService?: Service;
|
|
21
|
+
outletService?: Service;
|
|
22
|
+
batteryService?: Service;
|
|
23
|
+
garageDoorService?: Service;
|
|
24
|
+
windowCoveringService?: Service;
|
|
25
|
+
statefulProgrammableSwitchService?: Service;
|
|
26
26
|
|
|
27
27
|
// Characteristic Values
|
|
28
28
|
On!: CharacteristicValue;
|
|
@@ -333,8 +333,8 @@ export class Bot {
|
|
|
333
333
|
// Start an update interval
|
|
334
334
|
interval(this.deviceRefreshRate * 1000)
|
|
335
335
|
.pipe(skipWhile(() => this.botUpdateInProgress))
|
|
336
|
-
.subscribe(() => {
|
|
337
|
-
this.refreshStatus();
|
|
336
|
+
.subscribe(async () => {
|
|
337
|
+
await this.refreshStatus();
|
|
338
338
|
});
|
|
339
339
|
|
|
340
340
|
// Watch for Bot change events
|
|
@@ -369,7 +369,7 @@ export class Bot {
|
|
|
369
369
|
/**
|
|
370
370
|
* Parse the device status from the SwitchBot api
|
|
371
371
|
*/
|
|
372
|
-
async parseStatus() {
|
|
372
|
+
async parseStatus(): Promise<void> {
|
|
373
373
|
if (this.SwitchToOpenAPI || !this.device.ble) {
|
|
374
374
|
await this.openAPIparseStatus();
|
|
375
375
|
} else {
|
|
@@ -377,7 +377,7 @@ export class Bot {
|
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
|
|
380
|
+
async BLEparseStatus(): Promise<void> {
|
|
381
381
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE parseStatus`);
|
|
382
382
|
// BLEmode (true if Switch Mode) | (false if Press Mode)
|
|
383
383
|
if (this.mode) {
|
|
@@ -406,7 +406,7 @@ export class Bot {
|
|
|
406
406
|
this.debugLog(`Bot: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
-
|
|
409
|
+
async openAPIparseStatus(): Promise<void> {
|
|
410
410
|
if (this.device.ble) {
|
|
411
411
|
this.SwitchToOpenAPI = false;
|
|
412
412
|
}
|
|
@@ -439,7 +439,7 @@ export class Bot {
|
|
|
439
439
|
/**
|
|
440
440
|
* Asks the SwitchBot API for the latest device information
|
|
441
441
|
*/
|
|
442
|
-
async refreshStatus() {
|
|
442
|
+
async refreshStatus(): Promise<void> {
|
|
443
443
|
if (this.device.ble) {
|
|
444
444
|
await this.BLERefreshStatus();
|
|
445
445
|
} else {
|
|
@@ -447,7 +447,7 @@ export class Bot {
|
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
|
|
450
|
+
async BLERefreshStatus(): Promise<void> {
|
|
451
451
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE refreshStatus`);
|
|
452
452
|
const switchbot = await this.platform.connectBLE();
|
|
453
453
|
// Convert to BLE Address
|
|
@@ -523,7 +523,7 @@ export class Bot {
|
|
|
523
523
|
});
|
|
524
524
|
}
|
|
525
525
|
|
|
526
|
-
|
|
526
|
+
async openAPIRefreshStatus(): Promise<void> {
|
|
527
527
|
if (this.platform.config.credentials?.openToken) {
|
|
528
528
|
this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI refreshStatus`);
|
|
529
529
|
try {
|
|
@@ -554,7 +554,7 @@ export class Bot {
|
|
|
554
554
|
* Bot - "command" "turnOn" "default" = set to ON state
|
|
555
555
|
* Bot - "command" "press" "default" = trigger press
|
|
556
556
|
*/
|
|
557
|
-
async pushChanges() {
|
|
557
|
+
async pushChanges(): Promise<void> {
|
|
558
558
|
if (this.device.ble) {
|
|
559
559
|
await this.BLEpushChanges();
|
|
560
560
|
} else {
|
|
@@ -563,12 +563,12 @@ export class Bot {
|
|
|
563
563
|
interval(5000)
|
|
564
564
|
.pipe(skipWhile(() => this.botUpdateInProgress))
|
|
565
565
|
.pipe(take(1))
|
|
566
|
-
.subscribe(() => {
|
|
567
|
-
this.refreshStatus();
|
|
566
|
+
.subscribe(async () => {
|
|
567
|
+
await this.refreshStatus();
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
570
|
|
|
571
|
-
|
|
571
|
+
async BLEpushChanges(): Promise<void> {
|
|
572
572
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.OnCached}`);
|
|
573
573
|
if (this.On !== this.OnCached || this.allowPush) {
|
|
574
574
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges`);
|
|
@@ -662,7 +662,7 @@ export class Bot {
|
|
|
662
662
|
this.accessory.context.On = this.OnCached;
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
-
|
|
665
|
+
async turnOnOff(device_list: any): Promise<any> {
|
|
666
666
|
if (this.On) {
|
|
667
667
|
return device_list[0].turnOn({ id: this.device.bleMac });
|
|
668
668
|
} else {
|
|
@@ -670,7 +670,7 @@ export class Bot {
|
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
672
|
|
|
673
|
-
|
|
673
|
+
async openAPIpushChanges(): Promise<void> {
|
|
674
674
|
if (this.platform.config.credentials?.openToken) {
|
|
675
675
|
try {
|
|
676
676
|
if (this.On !== this.OnCached || this.allowPush) {
|
|
@@ -726,7 +726,7 @@ export class Bot {
|
|
|
726
726
|
/**
|
|
727
727
|
* Updates the status for each of the HomeKit Characteristics
|
|
728
728
|
*/
|
|
729
|
-
updateHomeKitCharacteristics() {
|
|
729
|
+
async updateHomeKitCharacteristics(): Promise<void> {
|
|
730
730
|
if (this.device.bot?.deviceType === 'garagedoor') {
|
|
731
731
|
if (this.On === undefined) {
|
|
732
732
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
@@ -913,7 +913,7 @@ export class Bot {
|
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
|
|
916
|
-
|
|
916
|
+
async apiError(e: any): Promise<void> {
|
|
917
917
|
if (this.device.bot?.deviceType === 'garagedoor') {
|
|
918
918
|
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.TargetDoorState, e);
|
|
919
919
|
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.CurrentDoorState, e);
|
|
@@ -952,7 +952,7 @@ export class Bot {
|
|
|
952
952
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
953
953
|
}
|
|
954
954
|
|
|
955
|
-
|
|
955
|
+
async statusCode(push: AxiosResponse<{ statusCode: number }>): Promise<void> {
|
|
956
956
|
switch (push.data.statusCode) {
|
|
957
957
|
case 151:
|
|
958
958
|
this.errorLog(`Bot: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
@@ -985,7 +985,7 @@ export class Bot {
|
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
987
|
|
|
988
|
-
offlineOff() {
|
|
988
|
+
async offlineOff(): Promise<void> {
|
|
989
989
|
if (this.device.offline) {
|
|
990
990
|
this.On = false;
|
|
991
991
|
if (this.device.bot?.deviceType === 'switch') {
|
|
@@ -999,7 +999,7 @@ export class Bot {
|
|
|
999
999
|
/**
|
|
1000
1000
|
* Handle requests to set the "On" characteristic
|
|
1001
1001
|
*/
|
|
1002
|
-
handleOnSet(value: CharacteristicValue) {
|
|
1002
|
+
async handleOnSet(value: CharacteristicValue): Promise<void> {
|
|
1003
1003
|
if (this.device.bot?.deviceType === 'garagedoor') {
|
|
1004
1004
|
this.debugLog(`Bot: ${this.accessory.displayName} TargetDoorState: ${value}`);
|
|
1005
1005
|
if (value === this.platform.Characteristic.TargetDoorState.CLOSED) {
|
|
@@ -1046,7 +1046,7 @@ export class Bot {
|
|
|
1046
1046
|
this.doBotUpdate.next();
|
|
1047
1047
|
}
|
|
1048
1048
|
|
|
1049
|
-
config(device: device & devicesConfig) {
|
|
1049
|
+
async config(device: device & devicesConfig): Promise<void> {
|
|
1050
1050
|
let config = {};
|
|
1051
1051
|
if (device.bot) {
|
|
1052
1052
|
config = device.bot;
|
|
@@ -1071,7 +1071,7 @@ export class Bot {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
}
|
|
1073
1073
|
|
|
1074
|
-
refreshRate(device: device & devicesConfig) {
|
|
1074
|
+
async refreshRate(device: device & devicesConfig): Promise<void> {
|
|
1075
1075
|
if (device.refreshRate) {
|
|
1076
1076
|
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
1077
1077
|
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
@@ -1081,7 +1081,7 @@ export class Bot {
|
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
1083
1083
|
|
|
1084
|
-
scan(device: device & devicesConfig) {
|
|
1084
|
+
async scan(device: device & devicesConfig): Promise<void> {
|
|
1085
1085
|
if (device.scanDuration) {
|
|
1086
1086
|
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
1087
1087
|
if (device.ble) {
|
|
@@ -1095,7 +1095,7 @@ export class Bot {
|
|
|
1095
1095
|
}
|
|
1096
1096
|
}
|
|
1097
1097
|
|
|
1098
|
-
logs(device: device & devicesConfig) {
|
|
1098
|
+
async logs(device: device & devicesConfig): Promise<void> {
|
|
1099
1099
|
if (this.platform.debugMode) {
|
|
1100
1100
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
1101
1101
|
this.debugLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
@@ -1111,7 +1111,7 @@ export class Bot {
|
|
|
1111
1111
|
}
|
|
1112
1112
|
}
|
|
1113
1113
|
|
|
1114
|
-
PressOrSwitch(device: device & devicesConfig) {
|
|
1114
|
+
async PressOrSwitch(device: device & devicesConfig): Promise<void> {
|
|
1115
1115
|
if (!device.bot?.mode) {
|
|
1116
1116
|
this.botMode = 'switch';
|
|
1117
1117
|
this.warnLog(`Bot: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
|
|
@@ -1127,7 +1127,7 @@ export class Bot {
|
|
|
1127
1127
|
}
|
|
1128
1128
|
}
|
|
1129
1129
|
|
|
1130
|
-
allowPushChanges(device: device & devicesConfig) {
|
|
1130
|
+
async allowPushChanges(device: device & devicesConfig): Promise<void> {
|
|
1131
1131
|
if (device.bot?.allowPush) {
|
|
1132
1132
|
this.allowPush = true;
|
|
1133
1133
|
} else {
|
|
@@ -1136,7 +1136,7 @@ export class Bot {
|
|
|
1136
1136
|
this.debugLog(`Bot: ${this.accessory.displayName} Allowing Push Changes: ${this.allowPush}`);
|
|
1137
1137
|
}
|
|
1138
1138
|
|
|
1139
|
-
|
|
1139
|
+
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
1140
1140
|
// If outletService still pressent, then remove first
|
|
1141
1141
|
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
1142
1142
|
if (this.outletService) {
|
|
@@ -1145,7 +1145,7 @@ export class Bot {
|
|
|
1145
1145
|
accessory.removeService(this.outletService!);
|
|
1146
1146
|
}
|
|
1147
1147
|
|
|
1148
|
-
|
|
1148
|
+
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
1149
1149
|
// If garageDoorService still pressent, then remove first
|
|
1150
1150
|
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
1151
1151
|
if (this.garageDoorService) {
|
|
@@ -1154,7 +1154,7 @@ export class Bot {
|
|
|
1154
1154
|
accessory.removeService(this.garageDoorService!);
|
|
1155
1155
|
}
|
|
1156
1156
|
|
|
1157
|
-
|
|
1157
|
+
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
1158
1158
|
// If doorService still pressent, then remove first
|
|
1159
1159
|
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
1160
1160
|
if (this.doorService) {
|
|
@@ -1163,7 +1163,7 @@ export class Bot {
|
|
|
1163
1163
|
accessory.removeService(this.doorService!);
|
|
1164
1164
|
}
|
|
1165
1165
|
|
|
1166
|
-
|
|
1166
|
+
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
1167
1167
|
// If lockService still pressent, then remove first
|
|
1168
1168
|
this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
|
|
1169
1169
|
if (this.lockService) {
|
|
@@ -1172,7 +1172,7 @@ export class Bot {
|
|
|
1172
1172
|
accessory.removeService(this.lockService!);
|
|
1173
1173
|
}
|
|
1174
1174
|
|
|
1175
|
-
|
|
1175
|
+
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
1176
1176
|
// If faucetService still pressent, then remove first
|
|
1177
1177
|
this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
|
|
1178
1178
|
if (this.faucetService) {
|
|
@@ -1181,7 +1181,7 @@ export class Bot {
|
|
|
1181
1181
|
accessory.removeService(this.faucetService!);
|
|
1182
1182
|
}
|
|
1183
1183
|
|
|
1184
|
-
|
|
1184
|
+
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
1185
1185
|
// If fanService still pressent, then remove first
|
|
1186
1186
|
this.fanService = this.accessory.getService(this.platform.Service.Fan);
|
|
1187
1187
|
if (this.fanService) {
|
|
@@ -1190,7 +1190,7 @@ export class Bot {
|
|
|
1190
1190
|
accessory.removeService(this.fanService!);
|
|
1191
1191
|
}
|
|
1192
1192
|
|
|
1193
|
-
|
|
1193
|
+
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
1194
1194
|
// If windowService still pressent, then remove first
|
|
1195
1195
|
this.windowService = this.accessory.getService(this.platform.Service.Window);
|
|
1196
1196
|
if (this.windowService) {
|
|
@@ -1199,7 +1199,7 @@ export class Bot {
|
|
|
1199
1199
|
accessory.removeService(this.windowService!);
|
|
1200
1200
|
}
|
|
1201
1201
|
|
|
1202
|
-
|
|
1202
|
+
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
1203
1203
|
// If windowCoveringService still pressent, then remove first
|
|
1204
1204
|
this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
|
|
1205
1205
|
if (this.windowCoveringService) {
|
|
@@ -1208,7 +1208,7 @@ export class Bot {
|
|
|
1208
1208
|
accessory.removeService(this.windowCoveringService!);
|
|
1209
1209
|
}
|
|
1210
1210
|
|
|
1211
|
-
|
|
1211
|
+
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
1212
1212
|
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
1213
1213
|
this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
|
|
1214
1214
|
if (this.statefulProgrammableSwitchService) {
|
|
@@ -1217,7 +1217,7 @@ export class Bot {
|
|
|
1217
1217
|
accessory.removeService(this.statefulProgrammableSwitchService!);
|
|
1218
1218
|
}
|
|
1219
1219
|
|
|
1220
|
-
|
|
1220
|
+
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
1221
1221
|
// If switchService still pressent, then remove first
|
|
1222
1222
|
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
1223
1223
|
if (this.switchService) {
|
|
@@ -1229,25 +1229,25 @@ export class Bot {
|
|
|
1229
1229
|
/**
|
|
1230
1230
|
* Logging for Device
|
|
1231
1231
|
*/
|
|
1232
|
-
infoLog(...log: any[]) {
|
|
1232
|
+
infoLog(...log: any[]): void {
|
|
1233
1233
|
if (this.enablingDeviceLogging()) {
|
|
1234
1234
|
this.platform.log.info(String(...log));
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
1237
|
|
|
1238
|
-
warnLog(...log: any[]) {
|
|
1238
|
+
warnLog(...log: any[]): void {
|
|
1239
1239
|
if (this.enablingDeviceLogging()) {
|
|
1240
1240
|
this.platform.log.warn(String(...log));
|
|
1241
1241
|
}
|
|
1242
1242
|
}
|
|
1243
1243
|
|
|
1244
|
-
errorLog(...log: any[]) {
|
|
1244
|
+
errorLog(...log: any[]): void {
|
|
1245
1245
|
if (this.enablingDeviceLogging()) {
|
|
1246
1246
|
this.platform.log.error(String(...log));
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
1249
1249
|
|
|
1250
|
-
debugLog(...log: any[]) {
|
|
1250
|
+
debugLog(...log: any[]): void {
|
|
1251
1251
|
if (this.enablingDeviceLogging()) {
|
|
1252
1252
|
if (this.deviceLogging === 'debug') {
|
|
1253
1253
|
this.platform.log.info('[DEBUG]', String(...log));
|