@switchbot/homebridge-switchbot 1.7.1-beta.1 → 1.7.1-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/CHANGELOG.md +7 -2
- package/config.schema.json +46 -33
- package/dist/devices/bots.d.ts +4 -2
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +40 -40
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +6 -1
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +18 -11
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +6 -7
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +69 -107
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +10 -3
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +52 -34
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +8 -2
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +28 -35
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +14 -12
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +63 -103
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +5 -6
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +61 -90
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +3 -1
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +8 -1
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +1 -0
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +6 -0
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +1 -0
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +6 -0
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +1 -0
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +6 -0
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +1 -0
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +6 -0
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +1 -0
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +6 -0
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +1 -0
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +6 -0
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +1 -0
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +6 -0
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +1 -0
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +6 -0
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +1 -0
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +6 -0
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +2 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +14 -1
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +6 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +5 -5
- package/src/devices/bots.ts +43 -44
- package/src/devices/colorbulb.ts +24 -14
- package/src/devices/contact.ts +72 -108
- package/src/devices/curtains.ts +60 -36
- package/src/devices/humidifiers.ts +36 -36
- package/src/devices/meters.ts +79 -113
- package/src/devices/motion.ts +66 -91
- package/src/devices/plugs.ts +11 -2
- package/src/irdevices/airconditioners.ts +7 -0
- package/src/irdevices/airpurifiers.ts +7 -0
- package/src/irdevices/cameras.ts +7 -0
- package/src/irdevices/fans.ts +7 -0
- package/src/irdevices/lights.ts +7 -0
- package/src/irdevices/others.ts +7 -0
- package/src/irdevices/tvs.ts +7 -0
- package/src/irdevices/vacuumcleaners.ts +7 -0
- package/src/irdevices/waterheaters.ts +7 -0
- package/src/platform.ts +14 -1
- package/src/settings.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,17 +2,22 @@
|
|
|
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
|
-
## [Beta - Version 1.
|
|
5
|
+
## [Beta - Version 1.8.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.8.0) (2022-01-XX)
|
|
6
6
|
|
|
7
7
|
## What's Changed
|
|
8
8
|
* Added option to display Bot a Stateful Programmable Switch.
|
|
9
9
|
* This will only Works in 3rd Party Home App, Like [Eve](https://apps.apple.com/us/app/eve-for-homekit/id917695792) or [Home+ 5](https://apps.apple.com/us/app/home-5/id995994352)
|
|
10
10
|
* Add option to Hide Motion Sensor's Light Sensor.
|
|
11
11
|
* Add option to Set Motion Sensor's Light Sensor `set_minLux` and `set_maxLux`.
|
|
12
|
+
* Fixed Bug: Where BLE config would show for devices that don't support BLE.
|
|
12
13
|
* Fixed Bug: Contact Sensors's Motion Sensor and Light Sensor showing undefined values.
|
|
13
14
|
* Fixed Bug: Motion Sensors's Light Sensor showing undefined values.
|
|
15
|
+
* Fixed Bug: Battery Service wouldn't be removed from Curtain, Contact Sensor, or Motion Sensor when switching from BLE to OpenAPI.
|
|
16
|
+
* Enhancments: Made some improvemnt on the switch from BLE to OpenAPI when BLE connection fails.
|
|
17
|
+
* Enhancments: Made Optional Switchbot Device Settings and Optional IR Device Settings more managable by using Tabs.
|
|
18
|
+
* Housekeeping and updated dependencies.
|
|
14
19
|
|
|
15
|
-
**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.7.0...v1.
|
|
20
|
+
**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.7.0...v1.8.0
|
|
16
21
|
|
|
17
22
|
## [Version 1.7.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.7.0) (2022-01-05)
|
|
18
23
|
|
package/config.schema.json
CHANGED
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"name": {
|
|
12
12
|
"type": "string",
|
|
13
13
|
"title": "Name",
|
|
14
|
-
"default": "SwitchBot"
|
|
15
|
-
"required": true
|
|
14
|
+
"default": "SwitchBot"
|
|
16
15
|
},
|
|
17
16
|
"credentials": {
|
|
18
17
|
"type": "object",
|
|
@@ -20,7 +19,6 @@
|
|
|
20
19
|
"openToken": {
|
|
21
20
|
"title": "Token",
|
|
22
21
|
"type": "string",
|
|
23
|
-
"required": true,
|
|
24
22
|
"x-schema-form": {
|
|
25
23
|
"type": "password"
|
|
26
24
|
}
|
|
@@ -28,10 +26,13 @@
|
|
|
28
26
|
"notice": {
|
|
29
27
|
"title": "Notice",
|
|
30
28
|
"type": "string",
|
|
31
|
-
"required": true,
|
|
32
29
|
"default": "Keep your token a secret!"
|
|
33
30
|
}
|
|
34
|
-
}
|
|
31
|
+
},
|
|
32
|
+
"required": [
|
|
33
|
+
"openToken",
|
|
34
|
+
"notice"
|
|
35
|
+
]
|
|
35
36
|
},
|
|
36
37
|
"options": {
|
|
37
38
|
"type": "object",
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
"type": "string",
|
|
53
54
|
"placeholder": "SwitchBot",
|
|
54
55
|
"condition": {
|
|
55
|
-
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId
|
|
56
|
+
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId);"
|
|
56
57
|
}
|
|
57
58
|
},
|
|
58
59
|
"hide_device": {
|
|
@@ -137,11 +138,11 @@
|
|
|
137
138
|
"title": "Enable Bluetooth Low Energy (BLE) Connection",
|
|
138
139
|
"type": "boolean",
|
|
139
140
|
"condition": {
|
|
140
|
-
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device);"
|
|
141
|
+
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device && (model.options.devices[arrayIndices].configDeviceType === 'Humidifier' || model.options.devices[arrayIndices].configDeviceType === 'Meter' || model.options.devices[arrayIndices].configDeviceType === 'Curtain' || model.options.devices[arrayIndices].configDeviceType === 'Bot'));"
|
|
141
142
|
}
|
|
142
143
|
},
|
|
143
144
|
"scanDuration": {
|
|
144
|
-
"title": "Scan Duration (Default is 1 Second)",
|
|
145
|
+
"title": "BLE Scan Duration (Default is 1 Second)",
|
|
145
146
|
"type": "number",
|
|
146
147
|
"placeholder": 1,
|
|
147
148
|
"condition": {
|
|
@@ -455,7 +456,7 @@
|
|
|
455
456
|
"placeholder": 360,
|
|
456
457
|
"description": "Indicates the number of seconds between polls of SwitchBot API.",
|
|
457
458
|
"condition": {
|
|
458
|
-
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device);"
|
|
459
|
+
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType);"
|
|
459
460
|
}
|
|
460
461
|
},
|
|
461
462
|
"logging": {
|
|
@@ -482,11 +483,17 @@
|
|
|
482
483
|
}
|
|
483
484
|
],
|
|
484
485
|
"condition": {
|
|
485
|
-
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device);"
|
|
486
|
+
"functionBody": "return (model.options && model.options.devices && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType);"
|
|
486
487
|
}
|
|
487
488
|
}
|
|
488
|
-
}
|
|
489
|
-
|
|
489
|
+
},
|
|
490
|
+
"required": [
|
|
491
|
+
"deviceId",
|
|
492
|
+
"configDeviceType",
|
|
493
|
+
"configDeviceName"
|
|
494
|
+
]
|
|
495
|
+
},
|
|
496
|
+
"uniqueItems": true
|
|
490
497
|
},
|
|
491
498
|
"irdevices": {
|
|
492
499
|
"type": "array",
|
|
@@ -804,11 +811,16 @@
|
|
|
804
811
|
}
|
|
805
812
|
],
|
|
806
813
|
"condition": {
|
|
807
|
-
"functionBody": "return (model.options && model.options.irdevices && model.options.irdevices[arrayIndices].deviceId && !model.options.irdevices[arrayIndices].hide_device);"
|
|
814
|
+
"functionBody": "return (model.options && model.options.irdevices && model.options.irdevices[arrayIndices].deviceId && !model.options.irdevices[arrayIndices].hide_device && model.options.irdevices[arrayIndices].configRemoteType);"
|
|
808
815
|
}
|
|
809
816
|
}
|
|
810
|
-
}
|
|
811
|
-
|
|
817
|
+
},
|
|
818
|
+
"required": [
|
|
819
|
+
"deviceId",
|
|
820
|
+
"configRemoteType"
|
|
821
|
+
]
|
|
822
|
+
},
|
|
823
|
+
"uniqueItems": true
|
|
812
824
|
},
|
|
813
825
|
"refreshRate": {
|
|
814
826
|
"title": "Refresh Rate",
|
|
@@ -849,7 +861,10 @@
|
|
|
849
861
|
}
|
|
850
862
|
}
|
|
851
863
|
}
|
|
852
|
-
}
|
|
864
|
+
},
|
|
865
|
+
"required": [
|
|
866
|
+
"name"
|
|
867
|
+
]
|
|
853
868
|
},
|
|
854
869
|
"layout": [
|
|
855
870
|
{
|
|
@@ -862,28 +877,27 @@
|
|
|
862
877
|
]
|
|
863
878
|
},
|
|
864
879
|
{
|
|
865
|
-
"key": "options.devices",
|
|
866
|
-
"notitle": false,
|
|
867
|
-
"add": "Add Another Device",
|
|
868
880
|
"type": "fieldset",
|
|
869
881
|
"title": "Optional SwitchBot Device Settings",
|
|
870
882
|
"expandable": true,
|
|
871
883
|
"expanded": false,
|
|
872
|
-
"orderable": false,
|
|
873
|
-
"buttonText": "Add Device",
|
|
874
884
|
"items": [
|
|
875
885
|
{
|
|
876
|
-
"
|
|
877
|
-
"
|
|
878
|
-
"
|
|
886
|
+
"key": "options.devices",
|
|
887
|
+
"notitle": false,
|
|
888
|
+
"type": "tabarray",
|
|
889
|
+
"title": "{{ value.configDeviceName || value.deviceId || 'New SwitchBot Device' }}",
|
|
890
|
+
"expandable": true,
|
|
891
|
+
"expanded": false,
|
|
892
|
+
"orderable": false,
|
|
879
893
|
"items": [
|
|
880
894
|
"options.devices[].configDeviceName",
|
|
881
895
|
"options.devices[].deviceId",
|
|
882
896
|
"options.devices[].hide_device",
|
|
897
|
+
"options.devices[].configDeviceType",
|
|
883
898
|
"options.devices[].offline",
|
|
884
899
|
"options.devices[].ble",
|
|
885
900
|
"options.devices[].scanDuration",
|
|
886
|
-
"options.devices[].configDeviceType",
|
|
887
901
|
"options.devices[].bot.mode",
|
|
888
902
|
"options.devices[].bot.deviceType",
|
|
889
903
|
"options.devices[].bot.doublePress",
|
|
@@ -915,20 +929,19 @@
|
|
|
915
929
|
]
|
|
916
930
|
},
|
|
917
931
|
{
|
|
918
|
-
"key": "options.irdevices",
|
|
919
|
-
"notitle": false,
|
|
920
|
-
"add": "Add Another IR Device",
|
|
921
932
|
"type": "fieldset",
|
|
922
933
|
"title": "Optional IR Device Settings",
|
|
923
934
|
"expandable": true,
|
|
924
935
|
"expanded": false,
|
|
925
|
-
"orderable": false,
|
|
926
|
-
"buttonText": "Add IR Device",
|
|
927
936
|
"items": [
|
|
928
937
|
{
|
|
929
|
-
"
|
|
930
|
-
"
|
|
931
|
-
"
|
|
938
|
+
"key": "options.irdevices",
|
|
939
|
+
"notitle": false,
|
|
940
|
+
"type": "tabarray",
|
|
941
|
+
"title": "{{ value.configDeviceName || value.deviceId || 'New IR Device' }}",
|
|
942
|
+
"expandable": true,
|
|
943
|
+
"expanded": false,
|
|
944
|
+
"orderable": false,
|
|
932
945
|
"items": [
|
|
933
946
|
"options.irdevices[].deviceId",
|
|
934
947
|
"options.irdevices[].hide_device",
|
package/dist/devices/bots.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
3
|
import { PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
4
|
-
import { device, devicesConfig, serviceData, switchbot, deviceStatusResponse } from '../settings';
|
|
4
|
+
import { device, devicesConfig, serviceData, switchbot, deviceStatusResponse, deviceStatus } from '../settings';
|
|
5
5
|
/**
|
|
6
6
|
* Platform Accessory
|
|
7
7
|
* An instance of this class is created for each accessory your platform registers
|
|
@@ -26,9 +26,11 @@ export declare class Bot {
|
|
|
26
26
|
OnCached: CharacteristicValue;
|
|
27
27
|
BatteryLevel: CharacteristicValue;
|
|
28
28
|
StatusLowBattery: CharacteristicValue;
|
|
29
|
+
power: deviceStatus['power'];
|
|
29
30
|
deviceStatus: deviceStatusResponse;
|
|
30
31
|
connected?: boolean;
|
|
31
32
|
switchbot: switchbot;
|
|
33
|
+
SwitchToOpenAPI?: boolean;
|
|
32
34
|
serviceData: serviceData;
|
|
33
35
|
mode: serviceData['mode'];
|
|
34
36
|
state: serviceData['state'];
|
|
@@ -41,6 +43,7 @@ export declare class Bot {
|
|
|
41
43
|
botUpdateInProgress: boolean;
|
|
42
44
|
doBotUpdate: Subject<void>;
|
|
43
45
|
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: device & devicesConfig);
|
|
46
|
+
config(device: device & devicesConfig): void;
|
|
44
47
|
removeOutletService(accessory: PlatformAccessory): void;
|
|
45
48
|
removeGarageDoorService(accessory: PlatformAccessory): void;
|
|
46
49
|
removeDoorService(accessory: PlatformAccessory): void;
|
|
@@ -65,7 +68,6 @@ export declare class Bot {
|
|
|
65
68
|
* Asks the SwitchBot API for the latest device information
|
|
66
69
|
*/
|
|
67
70
|
refreshStatus(): Promise<void>;
|
|
68
|
-
connectBLE(): Promise<any>;
|
|
69
71
|
private BLERefreshStatus;
|
|
70
72
|
private openAPIRefreshStatus;
|
|
71
73
|
/**
|
|
@@ -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,EAAE,WAAW,EAAM,SAAS,EAAE,oBAAoB,EAAW,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"bots.d.ts","sourceRoot":"","sources":["../../src/devices/bots.ts"],"names":[],"mappings":"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"}
|
package/dist/devices/bots.js
CHANGED
|
@@ -19,6 +19,7 @@ class Bot {
|
|
|
19
19
|
this.scan();
|
|
20
20
|
this.refreshRate();
|
|
21
21
|
this.PressOrSwitch();
|
|
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;
|
|
@@ -254,12 +252,22 @@ class Bot {
|
|
|
254
252
|
this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
255
253
|
this.outletService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
|
|
256
254
|
}
|
|
257
|
-
|
|
255
|
+
// Battery Service
|
|
256
|
+
if (!device.ble) {
|
|
257
|
+
this.debugLog(`Bot: ${accessory.displayName} Removing Battery Service`);
|
|
258
|
+
this.batteryService = this.accessory.getService(this.platform.Service.Battery);
|
|
259
|
+
accessory.removeService(this.batteryService);
|
|
260
|
+
}
|
|
261
|
+
else if (device.ble && !this.batteryService) {
|
|
262
|
+
this.debugLog(`Bot: ${accessory.displayName} Add Battery Service`);
|
|
258
263
|
(this.batteryService =
|
|
259
|
-
accessory.getService(this.platform.Service.Battery) ||
|
|
260
|
-
accessory.addService(this.platform.Service.Battery)), `${accessory.displayName} Battery`;
|
|
264
|
+
this.accessory.getService(this.platform.Service.Battery) ||
|
|
265
|
+
this.accessory.addService(this.platform.Service.Battery)), `${accessory.displayName} Battery`;
|
|
261
266
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
262
267
|
}
|
|
268
|
+
else {
|
|
269
|
+
this.debugLog(`Bot: ${accessory.displayName} Battery Service Not Added`);
|
|
270
|
+
}
|
|
263
271
|
// Retrieve initial values and updateHomekit
|
|
264
272
|
this.updateHomeKitCharacteristics();
|
|
265
273
|
// Start an update interval
|
|
@@ -296,6 +304,11 @@ class Bot {
|
|
|
296
304
|
this.botUpdateInProgress = false;
|
|
297
305
|
});
|
|
298
306
|
}
|
|
307
|
+
config(device) {
|
|
308
|
+
if (device.bot !== undefined || device.ble !== undefined) {
|
|
309
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(device.bot)}, BLE: ${device.ble}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
299
312
|
removeOutletService(accessory) {
|
|
300
313
|
// If outletService still pressent, then remove first
|
|
301
314
|
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
@@ -379,13 +392,13 @@ class Bot {
|
|
|
379
392
|
refreshRate() {
|
|
380
393
|
if (this.device.refreshRate) {
|
|
381
394
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
382
|
-
if (this.
|
|
395
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
383
396
|
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
384
397
|
}
|
|
385
398
|
}
|
|
386
399
|
else if (this.platform.config.options.refreshRate) {
|
|
387
400
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
|
|
388
|
-
if (this.
|
|
401
|
+
if (this.deviceLogging === 'debug') {
|
|
389
402
|
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
390
403
|
}
|
|
391
404
|
}
|
|
@@ -393,13 +406,13 @@ class Bot {
|
|
|
393
406
|
scan() {
|
|
394
407
|
if (this.device.scanDuration) {
|
|
395
408
|
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
396
|
-
if (this.
|
|
409
|
+
if (this.device.ble && (this.deviceLogging === 'debug' || this.deviceLogging === 'standard')) {
|
|
397
410
|
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
398
411
|
}
|
|
399
412
|
}
|
|
400
413
|
else {
|
|
401
414
|
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
402
|
-
if (this.
|
|
415
|
+
if (this.device.ble && this.deviceLogging === 'debug') {
|
|
403
416
|
this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
404
417
|
}
|
|
405
418
|
}
|
|
@@ -447,11 +460,11 @@ class Bot {
|
|
|
447
460
|
* Parse the device status from the SwitchBot api
|
|
448
461
|
*/
|
|
449
462
|
async parseStatus() {
|
|
450
|
-
if (this.device.ble) {
|
|
451
|
-
await this.
|
|
463
|
+
if (this.SwitchToOpenAPI || !this.device.ble) {
|
|
464
|
+
await this.openAPIparseStatus();
|
|
452
465
|
}
|
|
453
466
|
else {
|
|
454
|
-
await this.
|
|
467
|
+
await this.BLEparseStatus();
|
|
455
468
|
}
|
|
456
469
|
}
|
|
457
470
|
async BLEparseStatus() {
|
|
@@ -484,6 +497,9 @@ class Bot {
|
|
|
484
497
|
this.debugLog(`Bot: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
485
498
|
}
|
|
486
499
|
async openAPIparseStatus() {
|
|
500
|
+
if (this.device.ble) {
|
|
501
|
+
this.SwitchToOpenAPI = false;
|
|
502
|
+
}
|
|
487
503
|
if (this.platform.config.credentials?.openToken) {
|
|
488
504
|
this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI parseStatus`);
|
|
489
505
|
if (this.botMode === 'press') {
|
|
@@ -492,7 +508,7 @@ class Bot {
|
|
|
492
508
|
this.accessory.context.On = this.OnCached;
|
|
493
509
|
}
|
|
494
510
|
else {
|
|
495
|
-
/*if (this.
|
|
511
|
+
/*if (this.power === 'on') {
|
|
496
512
|
this.On = true;
|
|
497
513
|
this.OnCached = this.On;
|
|
498
514
|
this.accessory.context.On = this.OnCached;
|
|
@@ -521,34 +537,12 @@ class Bot {
|
|
|
521
537
|
await this.openAPIRefreshStatus();
|
|
522
538
|
}
|
|
523
539
|
}
|
|
524
|
-
async connectBLE() {
|
|
525
|
-
let switchbot;
|
|
526
|
-
try {
|
|
527
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
528
|
-
const Switchbot = require('node-switchbot');
|
|
529
|
-
switchbot = new Switchbot();
|
|
530
|
-
// Convert to BLE Address
|
|
531
|
-
this.device.bleMac = ((this.device.deviceId.match(/.{1,2}/g)).join(':')).toLowerCase();
|
|
532
|
-
this.debugLog(`Bot: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
533
|
-
}
|
|
534
|
-
catch (e) {
|
|
535
|
-
switchbot = false;
|
|
536
|
-
this.errorLog(`Bot: ${this.accessory.displayName} 'node-switchbot' found: ${switchbot}`);
|
|
537
|
-
if (this.deviceLogging === 'debug') {
|
|
538
|
-
this.errorLog(`Bot: ${this.accessory.displayName} 'node-switchbot' found: ${switchbot},`
|
|
539
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
540
|
-
}
|
|
541
|
-
if (this.platform.debugMode) {
|
|
542
|
-
this.errorLog(`Bot: ${this.accessory.displayName} 'node-switchbot' found: ${switchbot},`
|
|
543
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
return switchbot;
|
|
547
|
-
}
|
|
548
540
|
async BLERefreshStatus() {
|
|
549
541
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE refreshStatus`);
|
|
542
|
+
const switchbot = await this.platform.connectBLE();
|
|
550
543
|
// Convert to BLE Address
|
|
551
|
-
|
|
544
|
+
this.device.bleMac = ((this.device.deviceId.match(/.{1,2}/g)).join(':')).toLowerCase();
|
|
545
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
552
546
|
// Start to monitor advertisement packets
|
|
553
547
|
if (switchbot === false) {
|
|
554
548
|
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection: ${switchbot}`);
|
|
@@ -588,6 +582,7 @@ class Bot {
|
|
|
588
582
|
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
589
583
|
if (this.platform.config.credentials?.openToken) {
|
|
590
584
|
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
585
|
+
this.SwitchToOpenAPI = true;
|
|
591
586
|
await this.openAPIRefreshStatus();
|
|
592
587
|
}
|
|
593
588
|
}
|
|
@@ -603,6 +598,7 @@ class Bot {
|
|
|
603
598
|
}
|
|
604
599
|
if (this.platform.config.credentials?.openToken) {
|
|
605
600
|
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
601
|
+
this.SwitchToOpenAPI = true;
|
|
606
602
|
await this.openAPIRefreshStatus();
|
|
607
603
|
}
|
|
608
604
|
this.apiError(e);
|
|
@@ -614,6 +610,7 @@ class Bot {
|
|
|
614
610
|
try {
|
|
615
611
|
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
|
|
616
612
|
this.debugLog(`Bot: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
|
|
613
|
+
this.power = this.deviceStatus.body.power;
|
|
617
614
|
this.parseStatus();
|
|
618
615
|
this.updateHomeKitCharacteristics();
|
|
619
616
|
}
|
|
@@ -656,7 +653,10 @@ class Bot {
|
|
|
656
653
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.OnCached}`);
|
|
657
654
|
if (this.On !== this.OnCached) {
|
|
658
655
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges`);
|
|
659
|
-
const switchbot = await this.connectBLE();
|
|
656
|
+
const switchbot = await this.platform.connectBLE();
|
|
657
|
+
// Convert to BLE Address
|
|
658
|
+
this.device.bleMac = ((this.device.deviceId.match(/.{1,2}/g)).join(':')).toLowerCase();
|
|
659
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
660
660
|
//if (switchbot !== false) {
|
|
661
661
|
if (this.botMode === 'press') {
|
|
662
662
|
this.debugLog(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|