@switchbot/homebridge-switchbot 1.7.1-beta.0 → 1.7.1-beta.12
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 +12 -2
- package/config.schema.json +80 -36
- package/dist/devices/bots.d.ts +7 -5
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +72 -69
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +9 -4
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +46 -36
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +6 -3
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +59 -108
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +11 -4
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +67 -44
- 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 +39 -36
- 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 +10 -3
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +114 -68
- 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 +13 -1
- 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 +74 -72
- package/src/devices/colorbulb.ts +52 -39
- package/src/devices/contact.ts +61 -113
- package/src/devices/curtains.ts +76 -48
- package/src/devices/humidifiers.ts +47 -37
- package/src/devices/meters.ts +79 -113
- package/src/devices/motion.ts +125 -74
- 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 +14 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,14 +2,24 @@
|
|
|
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
|
+
* Add option to Hide Motion Sensor's Light Sensor.
|
|
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.
|
|
10
13
|
* Fixed Bug: Contact Sensors's Motion Sensor and Light Sensor showing undefined values.
|
|
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
|
+
* Change: Changed Curtain `refreshRate` to `updateRate`.
|
|
19
|
+
* You will have to update your config for it to pickup the new `updateRate`.
|
|
20
|
+
* Housekeeping and updated dependencies.
|
|
11
21
|
|
|
12
|
-
**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.7.0...v1.
|
|
22
|
+
**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v1.7.0...v1.8.0
|
|
13
23
|
|
|
14
24
|
## [Version 1.7.0](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v1.7.0) (2022-01-05)
|
|
15
25
|
|
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": {
|
|
@@ -321,8 +322,8 @@
|
|
|
321
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);"
|
|
322
323
|
}
|
|
323
324
|
},
|
|
324
|
-
"
|
|
325
|
-
"title": "Curtain
|
|
325
|
+
"updateRate": {
|
|
326
|
+
"title": "Curtain Update Rate",
|
|
326
327
|
"type": "number",
|
|
327
328
|
"minimum": 1,
|
|
328
329
|
"placeholder": 5,
|
|
@@ -398,6 +399,34 @@
|
|
|
398
399
|
}
|
|
399
400
|
}
|
|
400
401
|
},
|
|
402
|
+
"motion": {
|
|
403
|
+
"type": "object",
|
|
404
|
+
"properties": {
|
|
405
|
+
"hide_lightsensor": {
|
|
406
|
+
"title": "Hide Motion Sensor's Light Sensor",
|
|
407
|
+
"type": "boolean",
|
|
408
|
+
"condition": {
|
|
409
|
+
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Motion Sensor' && model.options.devices[arrayIndices].deviceId);"
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
"set_minlux": {
|
|
413
|
+
"title": "Set Min Lux",
|
|
414
|
+
"type": "number",
|
|
415
|
+
"placeholder": "1",
|
|
416
|
+
"condition": {
|
|
417
|
+
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Motion Sensor' && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].motion.hide_lightsensor);"
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
"set_maxlux": {
|
|
421
|
+
"title": "Set Max Lux",
|
|
422
|
+
"type": "number",
|
|
423
|
+
"placeholder": "6001",
|
|
424
|
+
"condition": {
|
|
425
|
+
"functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Motion Sensor' && model.options.devices[arrayIndices].deviceId && !model.options.devices[arrayIndices].motion.hide_lightsensor);"
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
},
|
|
401
430
|
"colorbulb": {
|
|
402
431
|
"type": "object",
|
|
403
432
|
"properties": {
|
|
@@ -427,7 +456,7 @@
|
|
|
427
456
|
"placeholder": 360,
|
|
428
457
|
"description": "Indicates the number of seconds between polls of SwitchBot API.",
|
|
429
458
|
"condition": {
|
|
430
|
-
"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);"
|
|
431
460
|
}
|
|
432
461
|
},
|
|
433
462
|
"logging": {
|
|
@@ -454,11 +483,17 @@
|
|
|
454
483
|
}
|
|
455
484
|
],
|
|
456
485
|
"condition": {
|
|
457
|
-
"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);"
|
|
458
487
|
}
|
|
459
488
|
}
|
|
460
|
-
}
|
|
461
|
-
|
|
489
|
+
},
|
|
490
|
+
"required": [
|
|
491
|
+
"deviceId",
|
|
492
|
+
"configDeviceType",
|
|
493
|
+
"configDeviceName"
|
|
494
|
+
]
|
|
495
|
+
},
|
|
496
|
+
"uniqueItems": true
|
|
462
497
|
},
|
|
463
498
|
"irdevices": {
|
|
464
499
|
"type": "array",
|
|
@@ -776,11 +811,16 @@
|
|
|
776
811
|
}
|
|
777
812
|
],
|
|
778
813
|
"condition": {
|
|
779
|
-
"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);"
|
|
780
815
|
}
|
|
781
816
|
}
|
|
782
|
-
}
|
|
783
|
-
|
|
817
|
+
},
|
|
818
|
+
"required": [
|
|
819
|
+
"deviceId",
|
|
820
|
+
"configRemoteType"
|
|
821
|
+
]
|
|
822
|
+
},
|
|
823
|
+
"uniqueItems": true
|
|
784
824
|
},
|
|
785
825
|
"refreshRate": {
|
|
786
826
|
"title": "Refresh Rate",
|
|
@@ -821,7 +861,10 @@
|
|
|
821
861
|
}
|
|
822
862
|
}
|
|
823
863
|
}
|
|
824
|
-
}
|
|
864
|
+
},
|
|
865
|
+
"required": [
|
|
866
|
+
"name"
|
|
867
|
+
]
|
|
825
868
|
},
|
|
826
869
|
"layout": [
|
|
827
870
|
{
|
|
@@ -834,28 +877,27 @@
|
|
|
834
877
|
]
|
|
835
878
|
},
|
|
836
879
|
{
|
|
837
|
-
"key": "options.devices",
|
|
838
|
-
"notitle": false,
|
|
839
|
-
"add": "Add Another Device",
|
|
840
880
|
"type": "fieldset",
|
|
841
881
|
"title": "Optional SwitchBot Device Settings",
|
|
842
882
|
"expandable": true,
|
|
843
883
|
"expanded": false,
|
|
844
|
-
"orderable": false,
|
|
845
|
-
"buttonText": "Add Device",
|
|
846
884
|
"items": [
|
|
847
885
|
{
|
|
848
|
-
"
|
|
849
|
-
"
|
|
850
|
-
"
|
|
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,
|
|
851
893
|
"items": [
|
|
852
894
|
"options.devices[].configDeviceName",
|
|
853
895
|
"options.devices[].deviceId",
|
|
854
896
|
"options.devices[].hide_device",
|
|
897
|
+
"options.devices[].configDeviceType",
|
|
855
898
|
"options.devices[].offline",
|
|
856
899
|
"options.devices[].ble",
|
|
857
900
|
"options.devices[].scanDuration",
|
|
858
|
-
"options.devices[].configDeviceType",
|
|
859
901
|
"options.devices[].bot.mode",
|
|
860
902
|
"options.devices[].bot.deviceType",
|
|
861
903
|
"options.devices[].bot.doublePress",
|
|
@@ -866,7 +908,7 @@
|
|
|
866
908
|
"options.devices[].curtain.set_minStep",
|
|
867
909
|
"options.devices[].curtain.set_min",
|
|
868
910
|
"options.devices[].curtain.set_max",
|
|
869
|
-
"options.devices[].curtain.
|
|
911
|
+
"options.devices[].curtain.updateRate",
|
|
870
912
|
"options.devices[].curtain.disable_group",
|
|
871
913
|
"options.devices[].curtain.hide_lightsensor",
|
|
872
914
|
"options.devices[].curtain.set_minlux",
|
|
@@ -875,6 +917,9 @@
|
|
|
875
917
|
"options.devices[].contact.set_minlux",
|
|
876
918
|
"options.devices[].contact.set_maxlux",
|
|
877
919
|
"options.devices[].contact.hide_motionsensor",
|
|
920
|
+
"options.devices[].motion.hide_lightsensor",
|
|
921
|
+
"options.devices[].motion.set_minlux",
|
|
922
|
+
"options.devices[].motion.set_maxlux",
|
|
878
923
|
"options.devices[].colorbulb.set_minStep",
|
|
879
924
|
"options.devices[].colorbulb.adaptiveLightingShift",
|
|
880
925
|
"options.devices[].refreshRate",
|
|
@@ -884,20 +929,19 @@
|
|
|
884
929
|
]
|
|
885
930
|
},
|
|
886
931
|
{
|
|
887
|
-
"key": "options.irdevices",
|
|
888
|
-
"notitle": false,
|
|
889
|
-
"add": "Add Another IR Device",
|
|
890
932
|
"type": "fieldset",
|
|
891
933
|
"title": "Optional IR Device Settings",
|
|
892
934
|
"expandable": true,
|
|
893
935
|
"expanded": false,
|
|
894
|
-
"orderable": false,
|
|
895
|
-
"buttonText": "Add IR Device",
|
|
896
936
|
"items": [
|
|
897
937
|
{
|
|
898
|
-
"
|
|
899
|
-
"
|
|
900
|
-
"
|
|
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,
|
|
901
945
|
"items": [
|
|
902
946
|
"options.irdevices[].deviceId",
|
|
903
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'];
|
|
@@ -51,9 +53,10 @@ export declare class Bot {
|
|
|
51
53
|
removeWindowCoveringService(accessory: PlatformAccessory): void;
|
|
52
54
|
removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): void;
|
|
53
55
|
removeSwitchService(accessory: PlatformAccessory): void;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
scan(device: device & devicesConfig): void;
|
|
57
|
+
config(device: device & devicesConfig): void;
|
|
58
|
+
refreshRate(device: device & devicesConfig): void;
|
|
59
|
+
logs(device: device & devicesConfig): void;
|
|
57
60
|
PressOrSwitch(): void;
|
|
58
61
|
/**
|
|
59
62
|
* Parse the device status from the SwitchBot api
|
|
@@ -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":[],"mapp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IAcnC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAgBrC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAU1C,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAgBnC,aAAa;IAgBb;;OAEG;IACG,WAAW;YAQH,cAAc;YA6Bd,kBAAkB;IA8BhC;;OAEG;IACG,aAAa;YAQL,gBAAgB;YAmEhB,oBAAoB;IAwBlC;;;;;;OAMG;IACG,WAAW;YAcH,cAAc;IAoF5B,OAAO,CAAC,SAAS;YAQH,kBAAkB;IAmDhC;;OAEG;IACH,4BAA4B;IA4KrB,QAAQ,CAAC,CAAC,EAAE,GAAG;IAuCtB,OAAO,CAAC,UAAU;IA+BlB,OAAO,CAAC,UAAU;IAWlB;;OAEG;IACH,OAAO,CAAC,WAAW;IA6CnB;;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();
|
|
18
|
+
this.logs(device);
|
|
19
|
+
this.scan(device);
|
|
20
|
+
this.refreshRate(device);
|
|
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
|
|
@@ -376,53 +384,61 @@ class Bot {
|
|
|
376
384
|
}
|
|
377
385
|
accessory.removeService(this.switchService);
|
|
378
386
|
}
|
|
379
|
-
|
|
380
|
-
if (
|
|
381
|
-
this.
|
|
382
|
-
if (
|
|
383
|
-
this.
|
|
387
|
+
scan(device) {
|
|
388
|
+
if (device.scanDuration) {
|
|
389
|
+
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
390
|
+
if (device.ble) {
|
|
391
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
384
392
|
}
|
|
385
393
|
}
|
|
386
|
-
else
|
|
387
|
-
this.
|
|
388
|
-
if (this.
|
|
389
|
-
this.
|
|
394
|
+
else {
|
|
395
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
396
|
+
if (this.device.ble) {
|
|
397
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
390
398
|
}
|
|
391
399
|
}
|
|
392
400
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (
|
|
397
|
-
|
|
401
|
+
config(device) {
|
|
402
|
+
const config = device.bot;
|
|
403
|
+
if (device.bot !== undefined) {
|
|
404
|
+
if (device.ble !== undefined) {
|
|
405
|
+
config['ble'] = device.ble;
|
|
398
406
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
402
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
403
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
407
|
+
if (device.logging !== undefined) {
|
|
408
|
+
config['logging'] = device.logging;
|
|
404
409
|
}
|
|
410
|
+
if (device.refreshRate !== undefined) {
|
|
411
|
+
config['refreshRate'] = device.refreshRate;
|
|
412
|
+
}
|
|
413
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
405
414
|
}
|
|
406
415
|
}
|
|
407
|
-
|
|
416
|
+
refreshRate(device) {
|
|
417
|
+
if (device.refreshRate) {
|
|
418
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
419
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
420
|
+
}
|
|
421
|
+
else if (this.platform.config.options.refreshRate) {
|
|
422
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
|
|
423
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
logs(device) {
|
|
408
427
|
if (this.platform.debugMode) {
|
|
409
|
-
this.deviceLogging = this.accessory.context.logging = '
|
|
410
|
-
this.
|
|
428
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
429
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
411
430
|
}
|
|
412
|
-
else if (
|
|
413
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
414
|
-
|
|
415
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
416
|
-
}
|
|
431
|
+
else if (device.logging) {
|
|
432
|
+
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
433
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
417
434
|
}
|
|
418
435
|
else if (this.platform.config.options?.logging) {
|
|
419
436
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
420
|
-
|
|
421
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
422
|
-
}
|
|
437
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
423
438
|
}
|
|
424
439
|
else {
|
|
425
440
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
441
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
426
442
|
}
|
|
427
443
|
}
|
|
428
444
|
PressOrSwitch() {
|
|
@@ -447,11 +463,11 @@ class Bot {
|
|
|
447
463
|
* Parse the device status from the SwitchBot api
|
|
448
464
|
*/
|
|
449
465
|
async parseStatus() {
|
|
450
|
-
if (this.device.ble) {
|
|
451
|
-
await this.
|
|
466
|
+
if (this.SwitchToOpenAPI || !this.device.ble) {
|
|
467
|
+
await this.openAPIparseStatus();
|
|
452
468
|
}
|
|
453
469
|
else {
|
|
454
|
-
await this.
|
|
470
|
+
await this.BLEparseStatus();
|
|
455
471
|
}
|
|
456
472
|
}
|
|
457
473
|
async BLEparseStatus() {
|
|
@@ -484,6 +500,9 @@ class Bot {
|
|
|
484
500
|
this.debugLog(`Bot: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
485
501
|
}
|
|
486
502
|
async openAPIparseStatus() {
|
|
503
|
+
if (this.device.ble) {
|
|
504
|
+
this.SwitchToOpenAPI = false;
|
|
505
|
+
}
|
|
487
506
|
if (this.platform.config.credentials?.openToken) {
|
|
488
507
|
this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI parseStatus`);
|
|
489
508
|
if (this.botMode === 'press') {
|
|
@@ -492,7 +511,7 @@ class Bot {
|
|
|
492
511
|
this.accessory.context.On = this.OnCached;
|
|
493
512
|
}
|
|
494
513
|
else {
|
|
495
|
-
/*if (this.
|
|
514
|
+
/*if (this.power === 'on') {
|
|
496
515
|
this.On = true;
|
|
497
516
|
this.OnCached = this.On;
|
|
498
517
|
this.accessory.context.On = this.OnCached;
|
|
@@ -521,34 +540,12 @@ class Bot {
|
|
|
521
540
|
await this.openAPIRefreshStatus();
|
|
522
541
|
}
|
|
523
542
|
}
|
|
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
543
|
async BLERefreshStatus() {
|
|
549
544
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE refreshStatus`);
|
|
545
|
+
const switchbot = await this.platform.connectBLE();
|
|
550
546
|
// Convert to BLE Address
|
|
551
|
-
|
|
547
|
+
this.device.bleMac = ((this.device.deviceId.match(/.{1,2}/g)).join(':')).toLowerCase();
|
|
548
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
552
549
|
// Start to monitor advertisement packets
|
|
553
550
|
if (switchbot === false) {
|
|
554
551
|
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection: ${switchbot}`);
|
|
@@ -588,6 +585,7 @@ class Bot {
|
|
|
588
585
|
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
589
586
|
if (this.platform.config.credentials?.openToken) {
|
|
590
587
|
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
588
|
+
this.SwitchToOpenAPI = true;
|
|
591
589
|
await this.openAPIRefreshStatus();
|
|
592
590
|
}
|
|
593
591
|
}
|
|
@@ -603,6 +601,7 @@ class Bot {
|
|
|
603
601
|
}
|
|
604
602
|
if (this.platform.config.credentials?.openToken) {
|
|
605
603
|
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
604
|
+
this.SwitchToOpenAPI = true;
|
|
606
605
|
await this.openAPIRefreshStatus();
|
|
607
606
|
}
|
|
608
607
|
this.apiError(e);
|
|
@@ -614,6 +613,7 @@ class Bot {
|
|
|
614
613
|
try {
|
|
615
614
|
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
|
|
616
615
|
this.debugLog(`Bot: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
|
|
616
|
+
this.power = this.deviceStatus.body.power;
|
|
617
617
|
this.parseStatus();
|
|
618
618
|
this.updateHomeKitCharacteristics();
|
|
619
619
|
}
|
|
@@ -656,7 +656,10 @@ class Bot {
|
|
|
656
656
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.OnCached}`);
|
|
657
657
|
if (this.On !== this.OnCached) {
|
|
658
658
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges`);
|
|
659
|
-
const switchbot = await this.connectBLE();
|
|
659
|
+
const switchbot = await this.platform.connectBLE();
|
|
660
|
+
// Convert to BLE Address
|
|
661
|
+
this.device.bleMac = ((this.device.deviceId.match(/.{1,2}/g)).join(':')).toLowerCase();
|
|
662
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
660
663
|
//if (switchbot !== false) {
|
|
661
664
|
if (this.botMode === 'press') {
|
|
662
665
|
this.debugLog(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|