@switchbot/homebridge-switchbot 1.12.8 → 1.12.9-beta.10
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/.github/ISSUE_TEMPLATE/bug-report.yml +6 -1
- package/.github/ISSUE_TEMPLATE/feature-request.yml +6 -1
- package/.github/ISSUE_TEMPLATE/support-request.yml +6 -1
- package/CHANGELOG.md +12 -0
- package/config.schema.json +62 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +3 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +3 -1
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +3 -1
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +4 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +47 -3
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +3 -2
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +1 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +44 -6
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +3 -1
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +3 -1
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +3 -1
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +3 -1
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +3 -1
- package/dist/device/striplight.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +40 -41
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +3 -0
- 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 +3 -1
- package/src/device/colorbulb.ts +3 -1
- package/src/device/contact.ts +3 -1
- package/src/device/curtain.ts +45 -3
- package/src/device/humidifier.ts +3 -2
- package/src/device/lock.ts +45 -6
- package/src/device/meter.ts +3 -1
- package/src/device/meterplus.ts +3 -1
- package/src/device/motion.ts +3 -1
- package/src/device/plug.ts +3 -1
- package/src/device/striplight.ts +3 -1
- package/src/platform.ts +40 -41
- package/src/settings.ts +3 -0
package/package.json
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
|
|
14
|
-
},
|
|
15
|
-
"engines": {
|
|
16
|
-
"homebridge": "^1.4.0",
|
|
17
|
-
"node": "^14.19.0 || ^16.14.0"
|
|
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"
|
|
2
|
+
"displayName": "Homebridge SwitchBot",
|
|
3
|
+
"name": "@switchbot/homebridge-switchbot",
|
|
4
|
+
"version": "1.12.9-beta.10",
|
|
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"
|
|
35
11
|
},
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"homebridge": "^1.4.0",
|
|
17
|
+
"node": "^14.19.0 || ^16.14.0"
|
|
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.26.1",
|
|
59
|
+
"rxjs": "^7.5.5"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/node": "^17.0.23",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
64
|
+
"@typescript-eslint/parser": "^5.17.0",
|
|
65
|
+
"eslint": "^8.12.0",
|
|
66
|
+
"eslint-config-prettier": "8.5.0",
|
|
67
|
+
"eslint-plugin-prettier": "4.0.0",
|
|
68
|
+
"homebridge": "^1.4.0",
|
|
69
|
+
"nodemon": "^2.0.15",
|
|
70
|
+
"npm-check-updates": "^12.5.7",
|
|
71
|
+
"prettier": "2.6.2",
|
|
72
|
+
"rimraf": "^3.0.2",
|
|
73
|
+
"ts-node": "^10.7.0",
|
|
74
|
+
"typescript": "^4.6.3",
|
|
75
|
+
"typescript-axios-wb": "^1.0.3"
|
|
76
|
+
},
|
|
77
|
+
"optionalDependencies": {
|
|
78
|
+
"node-switchbot": "^1.2.0"
|
|
39
79
|
}
|
|
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.26.1",
|
|
59
|
-
"rxjs": "^7.5.5"
|
|
60
|
-
},
|
|
61
|
-
"devDependencies": {
|
|
62
|
-
"@types/node": "^17.0.21",
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
|
64
|
-
"@typescript-eslint/parser": "^5.15.0",
|
|
65
|
-
"eslint": "^8.11.0",
|
|
66
|
-
"eslint-config-prettier": "8.5.0",
|
|
67
|
-
"eslint-plugin-prettier": "4.0.0",
|
|
68
|
-
"homebridge": "^1.4.0",
|
|
69
|
-
"nodemon": "^2.0.15",
|
|
70
|
-
"npm-check-updates": "^12.5.4",
|
|
71
|
-
"prettier": "2.6.0",
|
|
72
|
-
"rimraf": "^3.0.2",
|
|
73
|
-
"ts-node": "^10.7.0",
|
|
74
|
-
"typescript": "^4.6.2",
|
|
75
|
-
"typescript-axios-wb": "^1.0.3"
|
|
76
|
-
},
|
|
77
|
-
"optionalDependencies": {
|
|
78
|
-
"node-switchbot": "^1.2.0"
|
|
79
|
-
}
|
|
80
80
|
}
|
package/src/device/bot.ts
CHANGED
|
@@ -93,7 +93,9 @@ export class Bot {
|
|
|
93
93
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
94
94
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
95
95
|
.setCharacteristic(this.platform.Characteristic.Model, 'SWITCHBOT-BOT-S1')
|
|
96
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
96
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
97
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
98
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
97
99
|
|
|
98
100
|
// get the service if it exists, otherwise create a new service
|
|
99
101
|
// you can create multiple services for each accessory
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -83,7 +83,9 @@ export class ColorBulb {
|
|
|
83
83
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
84
84
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
85
85
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1401400')
|
|
86
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
86
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
87
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
88
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
87
89
|
|
|
88
90
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
89
91
|
// you can create multiple services for each accessory
|
package/src/device/contact.ts
CHANGED
|
@@ -71,7 +71,9 @@ export class Contact {
|
|
|
71
71
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
72
72
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
73
73
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1201500')
|
|
74
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
74
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
75
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
76
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
75
77
|
|
|
76
78
|
// get the Contact service if it exists, otherwise create a new Contact service
|
|
77
79
|
// you can create multiple services for each accessory
|
package/src/device/curtain.ts
CHANGED
|
@@ -24,6 +24,8 @@ export class Curtain {
|
|
|
24
24
|
slidePosition: deviceStatus['slidePosition'];
|
|
25
25
|
moving: deviceStatus['moving'];
|
|
26
26
|
brightness: deviceStatus['brightness'];
|
|
27
|
+
setPositionMode?: string | number;
|
|
28
|
+
Mode!: string;
|
|
27
29
|
|
|
28
30
|
// BLE Others
|
|
29
31
|
connected?: boolean;
|
|
@@ -49,6 +51,8 @@ export class Curtain {
|
|
|
49
51
|
scanDuration!: number;
|
|
50
52
|
deviceLogging!: string;
|
|
51
53
|
deviceRefreshRate!: number;
|
|
54
|
+
setCloseMode!: string;
|
|
55
|
+
setOpenMode!: string;
|
|
52
56
|
|
|
53
57
|
// Updates
|
|
54
58
|
curtainUpdateInProgress!: boolean;
|
|
@@ -77,7 +81,9 @@ export class Curtain {
|
|
|
77
81
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
78
82
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
79
83
|
.setCharacteristic(this.platform.Characteristic.Model, 'W0701600')
|
|
80
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
84
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
85
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
86
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
81
87
|
|
|
82
88
|
// get the WindowCovering service if it exists, otherwise create a new WindowCovering service
|
|
83
89
|
// you can create multiple services for each accessory
|
|
@@ -528,12 +534,34 @@ export class Curtain {
|
|
|
528
534
|
.join(':')
|
|
529
535
|
.toLowerCase();
|
|
530
536
|
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
537
|
+
if (this.TargetPosition > 50) {
|
|
538
|
+
if (this.device.curtain?.setOpenMode === '1') {
|
|
539
|
+
this.setPositionMode = 1;
|
|
540
|
+
this.Mode = 'Silent Mode';
|
|
541
|
+
} else {
|
|
542
|
+
this.setPositionMode = 0;
|
|
543
|
+
this.Mode = 'Performance Mode';
|
|
544
|
+
}
|
|
545
|
+
} else {
|
|
546
|
+
if (this.device.curtain?.setCloseMode === '1') {
|
|
547
|
+
this.setPositionMode = 1;
|
|
548
|
+
this.Mode = 'Silent Mode';
|
|
549
|
+
} else {
|
|
550
|
+
this.setPositionMode = 0;
|
|
551
|
+
this.Mode = 'Performance Mode';
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
const adjustedMode = this.setPositionMode || null;
|
|
555
|
+
if (adjustedMode === null) {
|
|
556
|
+
this.Mode = 'Default Mode';
|
|
557
|
+
}
|
|
558
|
+
this.debugLog(`${this.accessory.displayName} Mode: ${this.Mode}`);
|
|
531
559
|
if (switchbot !== false) {
|
|
532
560
|
switchbot
|
|
533
561
|
.discover({ model: 'c', quick: true, id: this.device.bleMac })
|
|
534
562
|
.then((device_list) => {
|
|
535
563
|
this.infoLog(`${this.accessory.displayName} Target Position: ${this.TargetPosition}`);
|
|
536
|
-
return device_list[0].runToPos(100 - Number(this.TargetPosition));
|
|
564
|
+
return device_list[0].runToPos(100 - Number(this.TargetPosition), adjustedMode);
|
|
537
565
|
})
|
|
538
566
|
.then(() => {
|
|
539
567
|
this.debugLog(`Curtain: ${this.accessory.displayName} Done.`);
|
|
@@ -573,10 +601,24 @@ export class Curtain {
|
|
|
573
601
|
if (this.TargetPosition !== this.CurrentPosition) {
|
|
574
602
|
this.debugLog(`Pushing ${this.TargetPosition}`);
|
|
575
603
|
const adjustedTargetPosition = 100 - Number(this.TargetPosition);
|
|
604
|
+
if (this.TargetPosition > 50) {
|
|
605
|
+
this.setPositionMode = this.device.curtain?.setOpenMode;
|
|
606
|
+
} else {
|
|
607
|
+
this.setPositionMode = this.device.curtain?.setCloseMode;
|
|
608
|
+
}
|
|
609
|
+
if (this.setPositionMode === '1') {
|
|
610
|
+
this.Mode = 'Silent Mode';
|
|
611
|
+
} else if (this.setPositionMode === '0') {
|
|
612
|
+
this.Mode = 'Performance Mode';
|
|
613
|
+
} else {
|
|
614
|
+
this.Mode = 'Default Mode';
|
|
615
|
+
}
|
|
616
|
+
this.debugLog(`${this.accessory.displayName} Mode: ${this.Mode}`);
|
|
617
|
+
const adjustedMode = this.setPositionMode || 'ff';
|
|
576
618
|
const payload = {
|
|
577
619
|
commandType: 'command',
|
|
578
620
|
command: 'setPosition',
|
|
579
|
-
parameter: `0
|
|
621
|
+
parameter: `0,${adjustedMode},${adjustedTargetPosition}`,
|
|
580
622
|
} as payload;
|
|
581
623
|
|
|
582
624
|
this.infoLog(
|
package/src/device/humidifier.ts
CHANGED
|
@@ -77,7 +77,9 @@ export class Humidifier {
|
|
|
77
77
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
78
78
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
79
79
|
.setCharacteristic(this.platform.Characteristic.Model, 'W0801800')
|
|
80
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
80
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
81
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
82
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
81
83
|
|
|
82
84
|
// get the service if it exists, otherwise create a new service
|
|
83
85
|
// you can create multiple services for each accessory
|
|
@@ -124,7 +126,6 @@ export class Humidifier {
|
|
|
124
126
|
})
|
|
125
127
|
.onSet(this.handleRelativeHumidityHumidifierThresholdSet.bind(this));
|
|
126
128
|
|
|
127
|
-
// create a new Temperature Sensor service
|
|
128
129
|
// Temperature Sensor Service
|
|
129
130
|
if (device.humidifier?.hide_temperature || device.ble) {
|
|
130
131
|
this.debugLog(`Humidifier: ${accessory.displayName} Removing Temperature Sensor Service`);
|
package/src/device/lock.ts
CHANGED
|
@@ -11,6 +11,7 @@ export class Lock {
|
|
|
11
11
|
contactSensorService?: Service;
|
|
12
12
|
|
|
13
13
|
// Characteristic Values
|
|
14
|
+
ContactSensorState!: CharacteristicValue;
|
|
14
15
|
LockCurrentState!: CharacteristicValue;
|
|
15
16
|
LockTargetState!: CharacteristicValue;
|
|
16
17
|
LockTargetStateCached!: CharacteristicValue;
|
|
@@ -53,7 +54,9 @@ export class Lock {
|
|
|
53
54
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
54
55
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
55
56
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1601700')
|
|
56
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
57
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
58
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
59
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
57
60
|
|
|
58
61
|
// get the LockMechanism service if it exists, otherwise create a new LockMechanism service
|
|
59
62
|
// you can create multiple services for each accessory
|
|
@@ -74,6 +77,22 @@ export class Lock {
|
|
|
74
77
|
// create handlers for required characteristics
|
|
75
78
|
this.lockService.getCharacteristic(this.platform.Characteristic.LockCurrentState).onSet(this.LockTargetStateSet.bind(this));
|
|
76
79
|
|
|
80
|
+
// Contact Sensor Service
|
|
81
|
+
if (device.lock?.hide_contactsensor) {
|
|
82
|
+
this.debugLog(`Lock: ${accessory.displayName} Removing Contact Sensor Service`);
|
|
83
|
+
this.contactSensorService = this.accessory.getService(this.platform.Service.ContactSensor);
|
|
84
|
+
accessory.removeService(this.contactSensorService!);
|
|
85
|
+
} else if (!this.contactSensorService) {
|
|
86
|
+
this.debugLog(`Lock: ${accessory.displayName} Add Contact Sensor Service`);
|
|
87
|
+
(this.contactSensorService =
|
|
88
|
+
this.accessory.getService(this.platform.Service.ContactSensor) || this.accessory.addService(this.platform.Service.ContactSensor)),
|
|
89
|
+
`${accessory.displayName} Contact Sensor`;
|
|
90
|
+
|
|
91
|
+
this.contactSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Contact Sensor`);
|
|
92
|
+
} else {
|
|
93
|
+
this.debugLog(`Lock: ${accessory.displayName} Contact Sensor Service Not Added`);
|
|
94
|
+
}
|
|
95
|
+
|
|
77
96
|
// Update Homekit
|
|
78
97
|
this.updateHomeKitCharacteristics();
|
|
79
98
|
|
|
@@ -107,13 +126,24 @@ export class Lock {
|
|
|
107
126
|
});
|
|
108
127
|
}
|
|
109
128
|
|
|
129
|
+
//{"deviceId":"DBDC23B53139","deviceType":"Smart Lock","hubDeviceId":"E68B14109DA2","lockState":"locked","doorState":"opened","calibrate":true}
|
|
130
|
+
|
|
110
131
|
async parseStatus(): Promise<void> {
|
|
111
132
|
switch (this.lockState) {
|
|
112
|
-
case '
|
|
133
|
+
case 'locked':
|
|
134
|
+
this.LockCurrentState = this.platform.Characteristic.LockCurrentState.SECURED;
|
|
135
|
+
this.LockTargetState = this.platform.Characteristic.LockTargetState.SECURED;
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
113
138
|
this.LockCurrentState = this.platform.Characteristic.LockCurrentState.UNSECURED;
|
|
139
|
+
this.LockTargetState = this.platform.Characteristic.LockTargetState.UNSECURED;
|
|
140
|
+
}
|
|
141
|
+
switch (this.doorState) {
|
|
142
|
+
case 'opened':
|
|
143
|
+
this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
|
|
114
144
|
break;
|
|
115
145
|
default:
|
|
116
|
-
this.
|
|
146
|
+
this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
|
|
117
147
|
}
|
|
118
148
|
this.debugLog(`Lock: ${this.accessory.displayName} On: ${this.LockTargetState}`);
|
|
119
149
|
}
|
|
@@ -123,9 +153,7 @@ export class Lock {
|
|
|
123
153
|
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
|
|
124
154
|
this.debugLog(`Lock: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
|
|
125
155
|
this.lockState = this.deviceStatus.body.lockState;
|
|
126
|
-
this.warnLog(`Lock: ${this.accessory.displayName} lockState: ${JSON.stringify(this.lockState)} (COPY THIS LOG)`);
|
|
127
156
|
this.doorState = this.deviceStatus.body.doorState;
|
|
128
|
-
this.debugLog(`Lock: ${this.accessory.displayName} doorState: ${JSON.stringify(this.doorState)} (COPY THIS LOG)`);
|
|
129
157
|
this.parseStatus();
|
|
130
158
|
this.updateHomeKitCharacteristics();
|
|
131
159
|
} catch (e: any) {
|
|
@@ -178,6 +206,14 @@ export class Lock {
|
|
|
178
206
|
}
|
|
179
207
|
|
|
180
208
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
209
|
+
if (!this.device.lock?.hide_contactsensor) {
|
|
210
|
+
if (this.ContactSensorState === undefined) {
|
|
211
|
+
this.debugLog(`Lock: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensorState}`);
|
|
212
|
+
} else {
|
|
213
|
+
this.contactSensorService?.updateCharacteristic(this.platform.Characteristic.ContactSensorState, this.ContactSensorState);
|
|
214
|
+
this.debugLog(`Lock: ${this.accessory.displayName} updateCharacteristic ContactSensorState: ${this.ContactSensorState}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
181
217
|
if (this.LockTargetState === undefined) {
|
|
182
218
|
this.debugLog(`Lock: ${this.accessory.displayName} LockTargetState: ${this.LockTargetState}`);
|
|
183
219
|
} else {
|
|
@@ -188,11 +224,14 @@ export class Lock {
|
|
|
188
224
|
this.debugLog(`Lock: ${this.accessory.displayName} LockCurrentState: ${this.LockCurrentState}`);
|
|
189
225
|
} else {
|
|
190
226
|
this.lockService.updateCharacteristic(this.platform.Characteristic.LockCurrentState, this.LockCurrentState);
|
|
191
|
-
this.debugLog(`Lock: ${this.accessory.displayName} updateCharacteristic
|
|
227
|
+
this.debugLog(`Lock: ${this.accessory.displayName} updateCharacteristic LockCurrentState: ${this.LockCurrentState}`);
|
|
192
228
|
}
|
|
193
229
|
}
|
|
194
230
|
|
|
195
231
|
async apiError(e: any): Promise<void> {
|
|
232
|
+
if (!this.device.lock?.hide_contactsensor) {
|
|
233
|
+
this.contactSensorService?.updateCharacteristic(this.platform.Characteristic.ContactSensorState, e);
|
|
234
|
+
}
|
|
196
235
|
this.lockService.updateCharacteristic(this.platform.Characteristic.LockTargetState, e);
|
|
197
236
|
this.lockService.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
|
|
198
237
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
package/src/device/meter.ts
CHANGED
|
@@ -79,7 +79,9 @@ export class Meter {
|
|
|
79
79
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
80
80
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
81
81
|
.setCharacteristic(this.platform.Characteristic.Model, 'METERTH-S1')
|
|
82
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
82
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
83
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
84
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
83
85
|
|
|
84
86
|
// Temperature Sensor Service
|
|
85
87
|
if (device.meter?.hide_temperature) {
|
package/src/device/meterplus.ts
CHANGED
|
@@ -79,7 +79,9 @@ export class MeterPlus {
|
|
|
79
79
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
80
80
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
81
81
|
.setCharacteristic(this.platform.Characteristic.Model, this.model(device))
|
|
82
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
82
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
83
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
84
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
83
85
|
|
|
84
86
|
// Temperature Sensor Service
|
|
85
87
|
if (device.meter?.hide_temperature) {
|
package/src/device/motion.ts
CHANGED
|
@@ -67,7 +67,9 @@ export class Motion {
|
|
|
67
67
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
68
68
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
69
69
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1101500')
|
|
70
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
70
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
71
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
72
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
71
73
|
|
|
72
74
|
// get the Battery service if it exists, otherwise create a new Motion service
|
|
73
75
|
// you can create multiple services for each accessory
|
package/src/device/plug.ts
CHANGED
|
@@ -50,7 +50,9 @@ export class Plug {
|
|
|
50
50
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
51
51
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
52
52
|
.setCharacteristic(this.platform.Characteristic.Model, this.model(device))
|
|
53
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
53
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
54
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
55
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
54
56
|
|
|
55
57
|
// get the Outlet service if it exists, otherwise create a new Outlet service
|
|
56
58
|
// you can create multiple services for each accessory
|
package/src/device/striplight.ts
CHANGED
|
@@ -78,7 +78,9 @@ export class StripLight {
|
|
|
78
78
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
79
79
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
80
80
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1701100')
|
|
81
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
81
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
82
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
83
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision).updateValue(accessory.context.firmwareRevision);
|
|
82
84
|
|
|
83
85
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
84
86
|
// you can create multiple services for each accessory
|