@switchbot/homebridge-switchbot 1.7.1-beta.6 → 1.8.0
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 +5 -1
- package/config.schema.json +49 -36
- package/dist/devices/bots.d.ts +4 -3
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +42 -33
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +4 -3
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +38 -29
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +4 -3
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +42 -34
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +2 -1
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +24 -10
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +1 -0
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +20 -1
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +4 -3
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +46 -34
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +4 -3
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +42 -30
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +4 -3
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +42 -30
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +2 -1
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +19 -12
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +4 -3
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +23 -16
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +2 -1
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +19 -12
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +2 -1
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +19 -12
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +2 -1
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +19 -12
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +3 -2
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +23 -16
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +2 -1
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +19 -12
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +2 -1
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +19 -12
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +2 -1
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +19 -12
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/settings.d.ts +7 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +71 -71
- package/src/devices/bots.ts +43 -35
- package/src/devices/colorbulb.ts +39 -31
- package/src/devices/contact.ts +43 -35
- package/src/devices/curtains.ts +26 -12
- package/src/devices/humidifiers.ts +21 -1
- package/src/devices/meters.ts +47 -34
- package/src/devices/motion.ts +43 -30
- package/src/devices/plugs.ts +43 -30
- package/src/irdevices/airconditioners.ts +20 -12
- package/src/irdevices/airpurifiers.ts +24 -16
- package/src/irdevices/cameras.ts +20 -12
- package/src/irdevices/fans.ts +20 -12
- package/src/irdevices/lights.ts +20 -12
- package/src/irdevices/others.ts +24 -16
- package/src/irdevices/tvs.ts +20 -12
- package/src/irdevices/vacuumcleaners.ts +20 -12
- package/src/irdevices/waterheaters.ts +20 -12
- package/src/settings.ts +7 -1
package/package.json
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
"displayName": "Homebridge SwitchBot",
|
|
3
|
+
"name": "@switchbot/homebridge-switchbot",
|
|
4
|
+
"version": "1.8.0",
|
|
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.3.9",
|
|
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
|
+
},
|
|
28
|
+
"funding": [
|
|
29
|
+
{
|
|
30
|
+
"type": "Paypal",
|
|
31
|
+
"url": "https://paypal.me/donavanbecker"
|
|
11
32
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"engines": {
|
|
16
|
-
"homebridge": "^1.3.9",
|
|
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
|
-
},
|
|
28
|
-
"funding": [
|
|
29
|
-
{
|
|
30
|
-
"type": "Paypal",
|
|
31
|
-
"url": "https://paypal.me/donavanbecker"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"type": "GitHub",
|
|
35
|
-
"url": "https://github.com/sponsors/donavanbecker"
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
"publishConfig": {
|
|
39
|
-
"access": "public"
|
|
40
|
-
},
|
|
41
|
-
"keywords": [
|
|
42
|
-
"homebridge-plugin",
|
|
43
|
-
"switchbot",
|
|
44
|
-
"humidifier",
|
|
45
|
-
"humidity",
|
|
46
|
-
"temperature",
|
|
47
|
-
"bot",
|
|
48
|
-
"curtains",
|
|
49
|
-
"windows",
|
|
50
|
-
"ble",
|
|
51
|
-
"ir"
|
|
52
|
-
],
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"@homebridge/plugin-ui-utils": "^0.0.19",
|
|
55
|
-
"axios": "^0.24.0",
|
|
56
|
-
"rxjs": "^7.5.2"
|
|
57
|
-
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"@types/node": "^17.0.8",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
61
|
-
"@typescript-eslint/parser": "^5.9.1",
|
|
62
|
-
"eslint": "^8.6.0",
|
|
63
|
-
"homebridge": "^1.3.9",
|
|
64
|
-
"nodemon": "^2.0.15",
|
|
65
|
-
"npm-check-updates": "^12.1.0",
|
|
66
|
-
"rimraf": "^3.0.2",
|
|
67
|
-
"ts-node": "^10.4.0",
|
|
68
|
-
"typescript": "^4.5.4",
|
|
69
|
-
"typescript-axios-wb": "^1.0.3"
|
|
70
|
-
},
|
|
71
|
-
"optionalDependencies": {
|
|
72
|
-
"node-switchbot": "^1.1.2"
|
|
33
|
+
{
|
|
34
|
+
"type": "GitHub",
|
|
35
|
+
"url": "https://github.com/sponsors/donavanbecker"
|
|
73
36
|
}
|
|
74
|
-
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"homebridge-plugin",
|
|
43
|
+
"switchbot",
|
|
44
|
+
"humidifier",
|
|
45
|
+
"humidity",
|
|
46
|
+
"temperature",
|
|
47
|
+
"bot",
|
|
48
|
+
"curtains",
|
|
49
|
+
"windows",
|
|
50
|
+
"ble",
|
|
51
|
+
"ir"
|
|
52
|
+
],
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@homebridge/plugin-ui-utils": "^0.0.19",
|
|
55
|
+
"axios": "^0.24.0",
|
|
56
|
+
"rxjs": "^7.5.2"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^17.0.8",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
61
|
+
"@typescript-eslint/parser": "^5.9.1",
|
|
62
|
+
"eslint": "^8.6.0",
|
|
63
|
+
"homebridge": "^1.3.9",
|
|
64
|
+
"nodemon": "^2.0.15",
|
|
65
|
+
"npm-check-updates": "^12.1.0",
|
|
66
|
+
"rimraf": "^3.0.2",
|
|
67
|
+
"ts-node": "^10.4.0",
|
|
68
|
+
"typescript": "^4.5.4",
|
|
69
|
+
"typescript-axios-wb": "^1.0.3"
|
|
70
|
+
},
|
|
71
|
+
"optionalDependencies": {
|
|
72
|
+
"node-switchbot": "^1.1.2"
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/devices/bots.ts
CHANGED
|
@@ -64,11 +64,11 @@ export class Bot {
|
|
|
64
64
|
public device: device & devicesConfig,
|
|
65
65
|
) {
|
|
66
66
|
// default placeholders
|
|
67
|
-
this.logs();
|
|
68
|
-
this.scan();
|
|
69
|
-
this.refreshRate();
|
|
67
|
+
this.logs(device);
|
|
68
|
+
this.scan(device);
|
|
69
|
+
this.refreshRate(device);
|
|
70
70
|
this.PressOrSwitch();
|
|
71
|
-
|
|
71
|
+
this.config(device);
|
|
72
72
|
if (this.On === undefined) {
|
|
73
73
|
this.On = false;
|
|
74
74
|
this.accessory.context.On = this.On;
|
|
@@ -84,10 +84,6 @@ export class Bot {
|
|
|
84
84
|
this.BatteryLevel = 100;
|
|
85
85
|
this.StatusLowBattery = 0;
|
|
86
86
|
|
|
87
|
-
// Bot Config
|
|
88
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Config: (ble: ${device.ble}, offline: ${device.offline}, mode: ${device.bot?.mode},`
|
|
89
|
-
+ ` deviceType: ${device.bot?.deviceType}, doublePress: ${this.doublePress})`);
|
|
90
|
-
|
|
91
87
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
92
88
|
this.doBotUpdate = new Subject();
|
|
93
89
|
this.botUpdateInProgress = false;
|
|
@@ -467,50 +463,62 @@ export class Bot {
|
|
|
467
463
|
accessory.removeService(this.switchService!);
|
|
468
464
|
}
|
|
469
465
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
466
|
+
config(device: device & devicesConfig) {
|
|
467
|
+
const config: any = device.bot;
|
|
468
|
+
if (device.ble !== undefined) {
|
|
469
|
+
config['ble'] = device.ble;
|
|
470
|
+
}
|
|
471
|
+
if (device.logging !== undefined) {
|
|
472
|
+
config['logging'] = device.logging;
|
|
473
|
+
}
|
|
474
|
+
if (device.refreshRate !== undefined) {
|
|
475
|
+
config['refreshRate'] = device.refreshRate;
|
|
476
|
+
}
|
|
477
|
+
if (device.scanDuration !== undefined) {
|
|
478
|
+
config['scanDuration'] = device.scanDuration;
|
|
479
|
+
}
|
|
480
|
+
if (config !== undefined) {
|
|
481
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
refreshRate(device: device & devicesConfig) {
|
|
486
|
+
if (device.refreshRate) {
|
|
487
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
488
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
476
489
|
} else if (this.platform.config.options!.refreshRate) {
|
|
477
490
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
478
|
-
|
|
479
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
480
|
-
}
|
|
491
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
481
492
|
}
|
|
482
493
|
}
|
|
483
494
|
|
|
484
|
-
scan() {
|
|
485
|
-
if (
|
|
486
|
-
this.scanDuration = this.accessory.context.scanDuration =
|
|
487
|
-
if (
|
|
488
|
-
this.
|
|
495
|
+
scan(device: device & devicesConfig) {
|
|
496
|
+
if (device.scanDuration) {
|
|
497
|
+
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
498
|
+
if (device.ble) {
|
|
499
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
489
500
|
}
|
|
490
501
|
} else {
|
|
491
502
|
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
492
|
-
if (this.
|
|
493
|
-
this.
|
|
503
|
+
if (this.device.ble) {
|
|
504
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
494
505
|
}
|
|
495
506
|
}
|
|
496
507
|
}
|
|
497
508
|
|
|
498
|
-
logs() {
|
|
509
|
+
logs(device: device & devicesConfig) {
|
|
499
510
|
if (this.platform.debugMode) {
|
|
500
|
-
this.deviceLogging = this.accessory.context.logging = '
|
|
501
|
-
this.
|
|
502
|
-
} else if (
|
|
503
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
504
|
-
|
|
505
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
506
|
-
}
|
|
511
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
512
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
513
|
+
} else if (device.logging) {
|
|
514
|
+
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
515
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
507
516
|
} else if (this.platform.config.options?.logging) {
|
|
508
517
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
509
|
-
|
|
510
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
511
|
-
}
|
|
518
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
512
519
|
} else {
|
|
513
520
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
521
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
514
522
|
}
|
|
515
523
|
}
|
|
516
524
|
|
package/src/devices/colorbulb.ts
CHANGED
|
@@ -58,9 +58,10 @@ export class ColorBulb {
|
|
|
58
58
|
public device: device & devicesConfig,
|
|
59
59
|
) {
|
|
60
60
|
// default placeholders
|
|
61
|
-
this.logs();
|
|
62
|
-
this.refreshRate();
|
|
63
|
-
this.adaptiveLighting();
|
|
61
|
+
this.logs(device);
|
|
62
|
+
this.refreshRate(device);
|
|
63
|
+
this.adaptiveLighting(device);
|
|
64
|
+
this.config(device);
|
|
64
65
|
if (this.On === undefined) {
|
|
65
66
|
this.On = false;
|
|
66
67
|
} else {
|
|
@@ -72,11 +73,6 @@ export class ColorBulb {
|
|
|
72
73
|
this.ColorTemperature = 140;
|
|
73
74
|
this.minKelvin = 2000;
|
|
74
75
|
this.maxKelvin = 9000;
|
|
75
|
-
|
|
76
|
-
// ColorBulb Config
|
|
77
|
-
this.debugLog(`Color Bulb: ${this.accessory.displayName} Config: (ble: ${device.ble}, set_minStep: ${device.colorbulb?.set_minStep},`
|
|
78
|
-
+ ` adaptiveLighting: ${device.colorbulb?.adaptiveLightingShift})`);
|
|
79
|
-
|
|
80
76
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
81
77
|
this.doColorBulbUpdate = new Subject();
|
|
82
78
|
this.colorBulbUpdateInProgress = false;
|
|
@@ -218,42 +214,54 @@ export class ColorBulb {
|
|
|
218
214
|
});
|
|
219
215
|
}
|
|
220
216
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
217
|
+
config(device: device & devicesConfig) {
|
|
218
|
+
const config: any = device.colorbulb;
|
|
219
|
+
if (device.ble !== undefined) {
|
|
220
|
+
config['ble'] = device.ble;
|
|
221
|
+
}
|
|
222
|
+
if (device.logging !== undefined) {
|
|
223
|
+
config['logging'] = device.logging;
|
|
224
|
+
}
|
|
225
|
+
if (device.refreshRate !== undefined) {
|
|
226
|
+
config['refreshRate'] = device.refreshRate;
|
|
227
|
+
}
|
|
228
|
+
if (device.scanDuration !== undefined) {
|
|
229
|
+
config['scanDuration'] = device.scanDuration;
|
|
230
|
+
}
|
|
231
|
+
if (config !== undefined) {
|
|
232
|
+
this.warnLog(`Color Bulb: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
refreshRate(device: device & devicesConfig) {
|
|
237
|
+
if (device.refreshRate) {
|
|
238
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
239
|
+
this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
227
240
|
} else if (this.platform.config.options!.refreshRate) {
|
|
228
241
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
229
|
-
|
|
230
|
-
this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
231
|
-
}
|
|
242
|
+
this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
232
243
|
}
|
|
233
244
|
}
|
|
234
245
|
|
|
235
|
-
logs() {
|
|
246
|
+
logs(device: device & devicesConfig) {
|
|
236
247
|
if (this.platform.debugMode) {
|
|
237
|
-
this.deviceLogging = this.accessory.context.logging = '
|
|
238
|
-
this.
|
|
239
|
-
} else if (
|
|
240
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
241
|
-
|
|
242
|
-
this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
243
|
-
}
|
|
248
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
249
|
+
this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
250
|
+
} else if (device.logging) {
|
|
251
|
+
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
252
|
+
this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
244
253
|
} else if (this.platform.config.options?.logging) {
|
|
245
254
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
246
|
-
|
|
247
|
-
this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
248
|
-
}
|
|
255
|
+
this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
249
256
|
} else {
|
|
250
257
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
258
|
+
this.debugLog(`Color Bulb: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
251
259
|
}
|
|
252
260
|
}
|
|
253
261
|
|
|
254
|
-
adaptiveLighting() {
|
|
255
|
-
if (
|
|
256
|
-
this.adaptiveLightingShift =
|
|
262
|
+
adaptiveLighting(device: device & devicesConfig) {
|
|
263
|
+
if (device.colorbulb?.adaptiveLightingShift) {
|
|
264
|
+
this.adaptiveLightingShift = device.colorbulb.adaptiveLightingShift;
|
|
257
265
|
this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
|
|
258
266
|
} else {
|
|
259
267
|
this.adaptiveLightingShift = 0;
|
package/src/devices/contact.ts
CHANGED
|
@@ -56,16 +56,12 @@ export class Contact {
|
|
|
56
56
|
public device: device & devicesConfig,
|
|
57
57
|
) {
|
|
58
58
|
// default placeholders
|
|
59
|
-
this.logs();
|
|
60
|
-
this.scan();
|
|
61
|
-
this.refreshRate();
|
|
59
|
+
this.logs(device);
|
|
60
|
+
this.scan(device);
|
|
61
|
+
this.refreshRate(device);
|
|
62
|
+
this.config(device);
|
|
62
63
|
this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
|
|
63
64
|
|
|
64
|
-
// Contact Config
|
|
65
|
-
this.debugLog(`Contact Sensor: ${this.accessory.displayName} Config: (ble: ${device.ble}, offline: ${device.offline},`
|
|
66
|
-
+ ` hide_lightsensor: ${device.contact?.hide_lightsensor}, hide_motionsensor: ${device.contact?.hide_motionsensor},`
|
|
67
|
-
+ ` set_minLux: ${this.device.contact?.set_minLux}, set_maxLux: ${this.device.contact?.set_maxLux})`);
|
|
68
|
-
|
|
69
65
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
70
66
|
this.doContactUpdate = new Subject();
|
|
71
67
|
this.contactUbpdateInProgress = false;
|
|
@@ -159,50 +155,62 @@ export class Contact {
|
|
|
159
155
|
});
|
|
160
156
|
}
|
|
161
157
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
158
|
+
config(device: device & devicesConfig) {
|
|
159
|
+
const config: any = device.contact;
|
|
160
|
+
if (device.ble !== undefined) {
|
|
161
|
+
config['ble'] = device.ble;
|
|
162
|
+
}
|
|
163
|
+
if (device.logging !== undefined) {
|
|
164
|
+
config['logging'] = device.logging;
|
|
165
|
+
}
|
|
166
|
+
if (device.refreshRate !== undefined) {
|
|
167
|
+
config['refreshRate'] = device.refreshRate;
|
|
168
|
+
}
|
|
169
|
+
if (device.scanDuration !== undefined) {
|
|
170
|
+
config['scanDuration'] = device.scanDuration;
|
|
171
|
+
}
|
|
172
|
+
if (config !== undefined) {
|
|
173
|
+
this.warnLog(`Contact Sensor: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
refreshRate(device: device & devicesConfig) {
|
|
178
|
+
if (device.refreshRate) {
|
|
179
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
180
|
+
this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
168
181
|
} else if (this.platform.config.options!.refreshRate) {
|
|
169
182
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
170
|
-
|
|
171
|
-
this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
172
|
-
}
|
|
183
|
+
this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
173
184
|
}
|
|
174
185
|
}
|
|
175
186
|
|
|
176
|
-
scan() {
|
|
177
|
-
if (
|
|
178
|
-
this.scanDuration = this.accessory.context.scanDuration =
|
|
179
|
-
if (
|
|
180
|
-
this.
|
|
187
|
+
scan(device: device & devicesConfig) {
|
|
188
|
+
if (device.scanDuration) {
|
|
189
|
+
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
190
|
+
if (device.ble) {
|
|
191
|
+
this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
181
192
|
}
|
|
182
193
|
} else {
|
|
183
194
|
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
184
|
-
if (this.
|
|
185
|
-
this.
|
|
195
|
+
if (this.device.ble) {
|
|
196
|
+
this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
186
197
|
}
|
|
187
198
|
}
|
|
188
199
|
}
|
|
189
200
|
|
|
190
|
-
logs() {
|
|
201
|
+
logs(device: device & devicesConfig) {
|
|
191
202
|
if (this.platform.debugMode) {
|
|
192
|
-
this.deviceLogging = this.accessory.context.logging = '
|
|
193
|
-
this.
|
|
194
|
-
} else if (
|
|
195
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
196
|
-
|
|
197
|
-
this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
198
|
-
}
|
|
203
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
204
|
+
this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
205
|
+
} else if (device.logging) {
|
|
206
|
+
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
207
|
+
this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
199
208
|
} else if (this.platform.config.options?.logging) {
|
|
200
209
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
201
|
-
|
|
202
|
-
this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
203
|
-
}
|
|
210
|
+
this.debugLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
204
211
|
} else {
|
|
205
212
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
213
|
+
this.debugLog(`Contact Sensor: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
206
214
|
}
|
|
207
215
|
}
|
|
208
216
|
|
package/src/devices/curtains.ts
CHANGED
|
@@ -43,7 +43,7 @@ export class Curtain {
|
|
|
43
43
|
|
|
44
44
|
// Config
|
|
45
45
|
set_minStep!: number;
|
|
46
|
-
|
|
46
|
+
updateRate!: number;
|
|
47
47
|
set_minLux!: number;
|
|
48
48
|
set_maxLux!: number;
|
|
49
49
|
scanDuration!: number;
|
|
@@ -64,16 +64,11 @@ export class Curtain {
|
|
|
64
64
|
this.scan();
|
|
65
65
|
this.setMinMax();
|
|
66
66
|
this.refreshRate();
|
|
67
|
+
this.config(device);
|
|
67
68
|
this.CurrentPosition = 0;
|
|
68
69
|
this.TargetPosition = 0;
|
|
69
70
|
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
70
71
|
|
|
71
|
-
// Curtain Config
|
|
72
|
-
this.debugLog(`Curtain: ${this.accessory.displayName} Config: (ble: ${device.ble}, disable_group: ${device.curtain?.disable_group},`
|
|
73
|
-
+ ` hide_lightsensor: ${device.curtain?.hide_lightsensor}, set_minLux: ${device.curtain?.set_minLux}, set_maxLux: `
|
|
74
|
-
+ `${device.curtain?.set_maxLux}, refreshRate: ${device.curtain?.refreshRate}, set_max: ${device.curtain?.set_max}, set_min: `
|
|
75
|
-
+ `${device.curtain?.set_min}, set_minStep: ${device.curtain?.set_minStep})`);
|
|
76
|
-
|
|
77
72
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
78
73
|
this.doCurtainUpdate = new Subject();
|
|
79
74
|
this.curtainUpdateInProgress = false;
|
|
@@ -175,7 +170,7 @@ export class Curtain {
|
|
|
175
170
|
});
|
|
176
171
|
|
|
177
172
|
// update slide progress
|
|
178
|
-
interval(this.
|
|
173
|
+
interval(this.updateRate * 1000)
|
|
179
174
|
.pipe(skipWhile(() => this.curtainUpdateInProgress))
|
|
180
175
|
.subscribe(() => {
|
|
181
176
|
if (this.PositionState === this.platform.Characteristic.PositionState.STOPPED) {
|
|
@@ -214,6 +209,25 @@ export class Curtain {
|
|
|
214
209
|
});
|
|
215
210
|
}
|
|
216
211
|
|
|
212
|
+
config(device: device & devicesConfig) {
|
|
213
|
+
const config: any = device.curtain;
|
|
214
|
+
if (device.ble !== undefined) {
|
|
215
|
+
config['ble'] = device.ble;
|
|
216
|
+
}
|
|
217
|
+
if (device.logging !== undefined) {
|
|
218
|
+
config['logging'] = device.logging;
|
|
219
|
+
}
|
|
220
|
+
if (device.refreshRate !== undefined) {
|
|
221
|
+
config['refreshRate'] = device.refreshRate;
|
|
222
|
+
}
|
|
223
|
+
if (device.scanDuration !== undefined) {
|
|
224
|
+
config['scanDuration'] = device.scanDuration;
|
|
225
|
+
}
|
|
226
|
+
if (config !== undefined) {
|
|
227
|
+
this.warnLog(`Curtain: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
217
231
|
refreshRate() {
|
|
218
232
|
// refreshRate
|
|
219
233
|
if (this.device.refreshRate) {
|
|
@@ -227,14 +241,14 @@ export class Curtain {
|
|
|
227
241
|
this.warnLog(`Curtain: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
228
242
|
}
|
|
229
243
|
}
|
|
230
|
-
//
|
|
231
|
-
if (this.device?.curtain?.
|
|
232
|
-
this.
|
|
244
|
+
// updateRate
|
|
245
|
+
if (this.device?.curtain?.updateRate) {
|
|
246
|
+
this.updateRate = this.device?.curtain?.updateRate;
|
|
233
247
|
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
234
248
|
this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config Curtain refreshRate: ${this.deviceRefreshRate}`);
|
|
235
249
|
}
|
|
236
250
|
} else {
|
|
237
|
-
this.
|
|
251
|
+
this.updateRate = 5;
|
|
238
252
|
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
239
253
|
this.warnLog(`Curtain: ${this.accessory.displayName} Using Default Curtain Refresh Rate.`);
|
|
240
254
|
}
|
|
@@ -59,6 +59,7 @@ export class Humidifier {
|
|
|
59
59
|
this.logs();
|
|
60
60
|
this.scan();
|
|
61
61
|
this.refreshRate();
|
|
62
|
+
this.config(device);
|
|
62
63
|
this.CurrentRelativeHumidity = 0;
|
|
63
64
|
this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
64
65
|
this.CurrentHumidifierDehumidifierState = this.platform.Characteristic.CurrentHumidifierDehumidifierState.INACTIVE;
|
|
@@ -153,7 +154,7 @@ export class Humidifier {
|
|
|
153
154
|
minStep: 0.1,
|
|
154
155
|
})
|
|
155
156
|
.onGet(() => {
|
|
156
|
-
return
|
|
157
|
+
return this.CurrentTemperature;
|
|
157
158
|
});
|
|
158
159
|
} else {
|
|
159
160
|
this.debugLog(`Humidifier: ${accessory.displayName} Temperature Sensor Service Not Added`);
|
|
@@ -197,6 +198,25 @@ export class Humidifier {
|
|
|
197
198
|
});
|
|
198
199
|
}
|
|
199
200
|
|
|
201
|
+
config(device: device & devicesConfig) {
|
|
202
|
+
const config: any = device.humidifier;
|
|
203
|
+
if (device.ble !== undefined) {
|
|
204
|
+
config['ble'] = device.ble;
|
|
205
|
+
}
|
|
206
|
+
if (device.logging !== undefined) {
|
|
207
|
+
config['logging'] = device.logging;
|
|
208
|
+
}
|
|
209
|
+
if (device.refreshRate !== undefined) {
|
|
210
|
+
config['refreshRate'] = device.refreshRate;
|
|
211
|
+
}
|
|
212
|
+
if (device.scanDuration !== undefined) {
|
|
213
|
+
config['scanDuration'] = device.scanDuration;
|
|
214
|
+
}
|
|
215
|
+
if (config !== undefined) {
|
|
216
|
+
this.warnLog(`Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
200
220
|
refreshRate() {
|
|
201
221
|
if (this.device.refreshRate) {
|
|
202
222
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|