@switchbot/homebridge-switchbot 2.9.1-beta.4 → 2.9.1
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/.eslintrc +47 -14
- package/.vscode/settings.json +7 -1
- package/CHANGELOG.md +79 -70
- package/SECURITY.md +2 -2
- package/config.schema.json +348 -114
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +6 -4
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +42 -35
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +3 -2
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +3 -2
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +12 -11
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +9 -8
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.js +9 -9
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.js +6 -6
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +9 -8
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +3 -2
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +9 -7
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +9 -8
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +9 -8
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +9 -7
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +3 -2
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +6 -4
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +3 -2
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +3 -2
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +3 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +3 -2
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +3 -2
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +38 -32
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +12 -11
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +3 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +3 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/nodemon.json +4 -2
- package/package.json +3 -8
- package/src/device/blindtilt.ts +7 -5
- package/src/device/bot.ts +44 -37
- package/src/device/ceilinglight.ts +7 -6
- package/src/device/colorbulb.ts +5 -4
- package/src/device/contact.ts +13 -11
- package/src/device/curtain.ts +10 -9
- package/src/device/hub.ts +9 -9
- package/src/device/humidifier.ts +8 -8
- package/src/device/iosensor.ts +10 -9
- package/src/device/lightstrip.ts +5 -4
- package/src/device/lock.ts +13 -11
- package/src/device/meter.ts +11 -10
- package/src/device/meterplus.ts +10 -9
- package/src/device/motion.ts +10 -8
- package/src/device/plug.ts +3 -2
- package/src/device/robotvacuumcleaner.ts +12 -10
- package/src/irdevice/airconditioner.ts +3 -2
- package/src/irdevice/airpurifier.ts +3 -2
- package/src/irdevice/camera.ts +3 -2
- package/src/irdevice/fan.ts +3 -2
- package/src/irdevice/light.ts +3 -2
- package/src/irdevice/other.ts +38 -32
- package/src/irdevice/tv.ts +12 -11
- package/src/irdevice/vacuumcleaner.ts +3 -2
- package/src/irdevice/waterheater.ts +3 -2
- package/tsconfig.json +16 -4
- package/.github/npm-version-script.js +0 -81
- package/.prettierrc +0 -9
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Homebridge SwitchBot",
|
|
3
3
|
"name": "@switchbot/homebridge-switchbot",
|
|
4
|
-
"version": "2.9.1
|
|
4
|
+
"version": "2.9.1",
|
|
5
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
6
|
"author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
|
|
7
7
|
"license": "ISC",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
16
|
"homebridge": "^1.6.1",
|
|
17
|
-
"node": "^
|
|
17
|
+
"node": "^18.18.2 || ^20.8.1"
|
|
18
18
|
},
|
|
19
19
|
"main": "dist/index.js",
|
|
20
20
|
"scripts": {
|
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@homebridge/plugin-ui-utils": "^0.1.0",
|
|
59
59
|
"async-mqtt": "^2.6.3",
|
|
60
|
-
"crypto-js": "^4.1.1",
|
|
61
60
|
"fakegato-history": "^0.6.4",
|
|
62
61
|
"homebridge-lib": "^6.6.1",
|
|
63
62
|
"rxjs": "^7.8.1",
|
|
@@ -69,19 +68,15 @@
|
|
|
69
68
|
"node-switchbot": "^1.9.0"
|
|
70
69
|
},
|
|
71
70
|
"devDependencies": {
|
|
72
|
-
"@types/crypto-js": "^4.1.2",
|
|
73
71
|
"@types/node": "^20.8.6",
|
|
74
72
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
75
73
|
"@typescript-eslint/parser": "^6.7.5",
|
|
76
74
|
"eslint": "^8.51.0",
|
|
77
|
-
"eslint-config-prettier": "9.0.0",
|
|
78
|
-
"eslint-plugin-prettier": "5.0.1",
|
|
79
75
|
"homebridge": "^1.6.1",
|
|
80
76
|
"nodemon": "^3.0.1",
|
|
81
77
|
"npm-check-updates": "^16.14.6",
|
|
82
|
-
"prettier": "3.0.3",
|
|
83
78
|
"rimraf": "^5.0.5",
|
|
84
79
|
"ts-node": "^10.9.1",
|
|
85
80
|
"typescript": "^5.2.2"
|
|
86
81
|
}
|
|
87
|
-
}
|
|
82
|
+
}
|
package/src/device/blindtilt.ts
CHANGED
|
@@ -118,9 +118,10 @@ export class BlindTilt {
|
|
|
118
118
|
|
|
119
119
|
// get the WindowCovering service if it exists, otherwise create a new WindowCovering service
|
|
120
120
|
// you can create multiple services for each accessory
|
|
121
|
+
const windowCoveringService = `${device.deviceName} ${device.deviceType}`;
|
|
121
122
|
(this.windowCoveringService =
|
|
122
|
-
accessory.getService(this.platform.Service.WindowCovering)
|
|
123
|
-
|
|
123
|
+
accessory.getService(this.platform.Service.WindowCovering)
|
|
124
|
+
|| accessory.addService(this.platform.Service.WindowCovering)), windowCoveringService;
|
|
124
125
|
|
|
125
126
|
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
126
127
|
if (!this.windowCoveringService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -178,8 +179,9 @@ export class BlindTilt {
|
|
|
178
179
|
.onSet(this.TargetHorizontalTiltAngleSet.bind(this));
|
|
179
180
|
|
|
180
181
|
// Battery Service
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
183
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
184
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
183
185
|
|
|
184
186
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
185
187
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -438,7 +440,7 @@ export class BlindTilt {
|
|
|
438
440
|
this.BatteryLevel = 100;
|
|
439
441
|
}
|
|
440
442
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
441
|
-
|
|
443
|
+
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
442
444
|
|
|
443
445
|
// FirmwareRevision
|
|
444
446
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
package/src/device/bot.ts
CHANGED
|
@@ -109,8 +109,9 @@ export class Bot {
|
|
|
109
109
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
110
110
|
|
|
111
111
|
// Add switchService
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
const switchService = `${accessory.displayName} Switch`;
|
|
113
|
+
(this.switchService = accessory.getService(this.platform.Service.Switch)
|
|
114
|
+
|| accessory.addService(this.platform.Service.Switch)), switchService;
|
|
114
115
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Switch`);
|
|
115
116
|
|
|
116
117
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -129,10 +130,10 @@ export class Bot {
|
|
|
129
130
|
this.removeWindowCoveringService(accessory);
|
|
130
131
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
131
132
|
|
|
132
|
-
// Add
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
// Add garageDoorService
|
|
134
|
+
const garageDoorService = `${accessory.displayName} Garage Door Opener`;
|
|
135
|
+
(this.garageDoorService = accessory.getService(this.platform.Service.GarageDoorOpener)
|
|
136
|
+
|| accessory.addService(this.platform.Service.GarageDoorOpener)), garageDoorService;
|
|
136
137
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
137
138
|
|
|
138
139
|
this.garageDoorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -152,9 +153,10 @@ export class Bot {
|
|
|
152
153
|
this.removeWindowCoveringService(accessory);
|
|
153
154
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
154
155
|
|
|
155
|
-
// Add
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
// Add doorService
|
|
157
|
+
const doorService = `${accessory.displayName} Door`;
|
|
158
|
+
(this.doorService = accessory.getService(this.platform.Service.Door)
|
|
159
|
+
|| accessory.addService(this.platform.Service.Door)), doorService;
|
|
158
160
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Door`);
|
|
159
161
|
|
|
160
162
|
this.doorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -182,9 +184,10 @@ export class Bot {
|
|
|
182
184
|
this.removeWindowCoveringService(accessory);
|
|
183
185
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
184
186
|
|
|
185
|
-
// Add
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
// Add windowService
|
|
188
|
+
const windowService = `${accessory.displayName} Window`;
|
|
189
|
+
(this.windowService = accessory.getService(this.platform.Service.Window)
|
|
190
|
+
|| accessory.addService(this.platform.Service.Window)), windowService;
|
|
188
191
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window`);
|
|
189
192
|
|
|
190
193
|
this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -212,10 +215,10 @@ export class Bot {
|
|
|
212
215
|
this.removeGarageDoorService(accessory);
|
|
213
216
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
214
217
|
|
|
215
|
-
// Add
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
218
|
+
// Add windowCoveringService
|
|
219
|
+
const windowCoveringService = `${accessory.displayName} Window Covering`;
|
|
220
|
+
(this.windowCoveringService = accessory.getService(this.platform.Service.WindowCovering)
|
|
221
|
+
|| accessory.addService(this.platform.Service.WindowCovering)), windowCoveringService;
|
|
219
222
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
220
223
|
|
|
221
224
|
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -243,9 +246,10 @@ export class Bot {
|
|
|
243
246
|
this.removeWindowCoveringService(accessory);
|
|
244
247
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
245
248
|
|
|
246
|
-
// Add
|
|
247
|
-
|
|
248
|
-
|
|
249
|
+
// Add lockService
|
|
250
|
+
const lockService = `${accessory.displayName} Lock`;
|
|
251
|
+
(this.lockService = accessory.getService(this.platform.Service.LockMechanism)
|
|
252
|
+
|| accessory.addService(this.platform.Service.LockMechanism)), lockService;
|
|
249
253
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Lock`);
|
|
250
254
|
|
|
251
255
|
this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -264,9 +268,10 @@ export class Bot {
|
|
|
264
268
|
this.removeWindowCoveringService(accessory);
|
|
265
269
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
266
270
|
|
|
267
|
-
// Add
|
|
268
|
-
|
|
269
|
-
|
|
271
|
+
// Add faucetService
|
|
272
|
+
const faucetService = `${accessory.displayName} Faucet`;
|
|
273
|
+
(this.faucetService = accessory.getService(this.platform.Service.Faucet)
|
|
274
|
+
|| accessory.addService(this.platform.Service.Faucet)), faucetService;
|
|
270
275
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Faucet`);
|
|
271
276
|
|
|
272
277
|
this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -285,9 +290,10 @@ export class Bot {
|
|
|
285
290
|
this.removeWindowCoveringService(accessory);
|
|
286
291
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
287
292
|
|
|
288
|
-
// Add
|
|
289
|
-
|
|
290
|
-
|
|
293
|
+
// Add fanService
|
|
294
|
+
const fanService = `${accessory.displayName} Fan`;
|
|
295
|
+
(this.fanService = accessory.getService(this.platform.Service.Fan)
|
|
296
|
+
|| accessory.addService(this.platform.Service.Fan)), fanService;
|
|
291
297
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Fan`);
|
|
292
298
|
|
|
293
299
|
this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -306,11 +312,10 @@ export class Bot {
|
|
|
306
312
|
this.removeGarageDoorService(accessory);
|
|
307
313
|
this.removeWindowCoveringService(accessory);
|
|
308
314
|
|
|
309
|
-
// Add
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
accessory.addService(this.platform.Service.StatefulProgrammableSwitch)),
|
|
313
|
-
`${accessory.displayName} Stateful Programmable Switch`;
|
|
315
|
+
// Add statefulProgrammableSwitchService
|
|
316
|
+
const statefulProgrammableSwitchService = `${accessory.displayName} Stateful Programmable Switch`;
|
|
317
|
+
(this.statefulProgrammableSwitchService = accessory.getService(this.platform.Service.StatefulProgrammableSwitch) ||
|
|
318
|
+
accessory.addService(this.platform.Service.StatefulProgrammableSwitch)), statefulProgrammableSwitchService;
|
|
314
319
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
315
320
|
|
|
316
321
|
this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -332,8 +337,9 @@ export class Bot {
|
|
|
332
337
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
333
338
|
|
|
334
339
|
// Add outletService
|
|
335
|
-
|
|
336
|
-
|
|
340
|
+
const outletService = `${accessory.displayName} Outlet`;
|
|
341
|
+
(this.outletService = accessory.getService(this.platform.Service.Outlet)
|
|
342
|
+
|| accessory.addService(this.platform.Service.Outlet)), outletService;
|
|
337
343
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Outlet`);
|
|
338
344
|
|
|
339
345
|
this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -343,9 +349,10 @@ export class Bot {
|
|
|
343
349
|
this.outletService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
344
350
|
}
|
|
345
351
|
|
|
346
|
-
//
|
|
347
|
-
|
|
348
|
-
|
|
352
|
+
// batteryService
|
|
353
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
354
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
355
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
349
356
|
|
|
350
357
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
351
358
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -437,7 +444,7 @@ export class Bot {
|
|
|
437
444
|
this.BatteryLevel = 100;
|
|
438
445
|
}
|
|
439
446
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
440
|
-
|
|
447
|
+
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
441
448
|
}
|
|
442
449
|
|
|
443
450
|
async openAPIparseStatus(): Promise<void> {
|
|
@@ -464,7 +471,7 @@ export class Bot {
|
|
|
464
471
|
this.BatteryLevel = 100;
|
|
465
472
|
}
|
|
466
473
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
467
|
-
|
|
474
|
+
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
468
475
|
|
|
469
476
|
// FirmwareRevision
|
|
470
477
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
@@ -91,8 +91,9 @@ export class CeilingLight {
|
|
|
91
91
|
|
|
92
92
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
93
93
|
// you can create multiple services for each accessory
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const lightBulbService = `${accessory.displayName} ${device.deviceType}`;
|
|
95
|
+
(this.lightBulbService = accessory.getService(this.platform.Service.Lightbulb)
|
|
96
|
+
|| accessory.addService(this.platform.Service.Lightbulb)), lightBulbService;
|
|
96
97
|
|
|
97
98
|
if (this.adaptiveLightingShift === -1 && this.accessory.context.adaptiveLighting) {
|
|
98
99
|
this.accessory.removeService(this.lightBulbService);
|
|
@@ -310,8 +311,8 @@ export class CeilingLight {
|
|
|
310
311
|
async refreshStatus(): Promise<void> {
|
|
311
312
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
312
313
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
313
|
-
|
|
314
|
-
|
|
314
|
+
/*} else if (this.BLE) {
|
|
315
|
+
await this.BLERefreshStatus();*/
|
|
315
316
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
316
317
|
await this.openAPIRefreshStatus();
|
|
317
318
|
} else {
|
|
@@ -441,8 +442,8 @@ export class CeilingLight {
|
|
|
441
442
|
async pushChanges(): Promise<void> {
|
|
442
443
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
443
444
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
/*} else if (this.BLE) {
|
|
446
|
+
await this.BLEpushChanges();*/
|
|
446
447
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
447
448
|
await this.openAPIpushChanges();
|
|
448
449
|
} else {
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -97,8 +97,9 @@ export class ColorBulb {
|
|
|
97
97
|
|
|
98
98
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
99
99
|
// you can create multiple services for each accessory
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
const lightBulbService = `${accessory.displayName} ${device.deviceType}`;
|
|
101
|
+
(this.lightBulbService = accessory.getService(this.platform.Service.Lightbulb)
|
|
102
|
+
|| accessory.addService(this.platform.Service.Lightbulb)), lightBulbService;
|
|
102
103
|
|
|
103
104
|
if (this.adaptiveLightingShift === -1 && this.accessory.context.adaptiveLighting) {
|
|
104
105
|
this.accessory.removeService(this.lightBulbService);
|
|
@@ -468,8 +469,8 @@ export class ColorBulb {
|
|
|
468
469
|
async pushChanges(): Promise<void> {
|
|
469
470
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
470
471
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
471
|
-
|
|
472
|
-
|
|
472
|
+
/*} else if (this.BLE) {
|
|
473
|
+
await this.BLEpushChanges();*/
|
|
473
474
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
474
475
|
await this.openAPIpushChanges();
|
|
475
476
|
} else {
|
package/src/device/contact.ts
CHANGED
|
@@ -87,9 +87,9 @@ export class Contact {
|
|
|
87
87
|
|
|
88
88
|
// get the Contact service if it exists, otherwise create a new Contact service
|
|
89
89
|
// you can create multiple services for each accessory
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
const contactSensorservice = `${accessory.displayName} Contact Sensor`;
|
|
91
|
+
(this.contactSensorservice = accessory.getService(this.platform.Service.ContactSensor)
|
|
92
|
+
|| accessory.addService(this.platform.Service.ContactSensor)), contactSensorservice;
|
|
93
93
|
|
|
94
94
|
this.contactSensorservice.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
95
95
|
if (!this.contactSensorservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -103,9 +103,9 @@ export class Contact {
|
|
|
103
103
|
accessory.removeService(this.motionService!);
|
|
104
104
|
} else if (!this.motionService) {
|
|
105
105
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Motion Sensor Service`);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
const motionService = `${accessory.displayName} Motion Sensor`;
|
|
107
|
+
(this.motionService = this.accessory.getService(this.platform.Service.MotionSensor)
|
|
108
|
+
|| this.accessory.addService(this.platform.Service.MotionSensor)), motionService;
|
|
109
109
|
|
|
110
110
|
this.motionService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Motion Sensor`);
|
|
111
111
|
this.motionService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Motion Sensor`);
|
|
@@ -120,9 +120,10 @@ export class Contact {
|
|
|
120
120
|
accessory.removeService(this.lightSensorService!);
|
|
121
121
|
} else if (!this.lightSensorService) {
|
|
122
122
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Light Sensor Service`);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
|
|
124
|
+
const lightSensorService = `${accessory.displayName} Light Sensor`;
|
|
125
|
+
(this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor)
|
|
126
|
+
|| this.accessory.addService(this.platform.Service.LightSensor)), lightSensorService;
|
|
126
127
|
|
|
127
128
|
this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
|
|
128
129
|
this.lightSensorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Light Sensor`);
|
|
@@ -131,8 +132,9 @@ export class Contact {
|
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
// Battery Service
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
136
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
137
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
136
138
|
|
|
137
139
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
138
140
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
package/src/device/curtain.ts
CHANGED
|
@@ -106,9 +106,9 @@ export class Curtain {
|
|
|
106
106
|
|
|
107
107
|
// get the WindowCovering service if it exists, otherwise create a new WindowCovering service
|
|
108
108
|
// you can create multiple services for each accessory
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
const windowCoveringService = `${accessory.displayName} ${device.deviceType}`;
|
|
110
|
+
(this.windowCoveringService = accessory.getService(this.platform.Service.WindowCovering)
|
|
111
|
+
|| accessory.addService(this.platform.Service.WindowCovering)), windowCoveringService;
|
|
112
112
|
|
|
113
113
|
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
114
114
|
if (!this.windowCoveringService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -150,9 +150,9 @@ export class Curtain {
|
|
|
150
150
|
accessory.removeService(this.lightSensorService!);
|
|
151
151
|
} else if (!this.lightSensorService) {
|
|
152
152
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Light Sensor Service`);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
const lightSensorService = `${accessory.displayName} Light Sensor`;
|
|
154
|
+
(this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor)
|
|
155
|
+
|| this.accessory.addService(this.platform.Service.LightSensor)), lightSensorService;
|
|
156
156
|
|
|
157
157
|
this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
|
|
158
158
|
if (!this.lightSensorService?.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -163,8 +163,9 @@ export class Curtain {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
// Battery Service
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
167
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
168
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
168
169
|
|
|
169
170
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
170
171
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -465,7 +466,7 @@ export class Curtain {
|
|
|
465
466
|
this.BatteryLevel = 100;
|
|
466
467
|
}
|
|
467
468
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
468
|
-
|
|
469
|
+
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
469
470
|
|
|
470
471
|
// FirmwareRevision
|
|
471
472
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
package/src/device/hub.ts
CHANGED
|
@@ -81,9 +81,9 @@ export class Hub {
|
|
|
81
81
|
accessory.removeService(this.temperatureService!);
|
|
82
82
|
} else if (!this.temperatureService) {
|
|
83
83
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
const temperatureService = `${accessory.displayName} Temperature Sensor`;
|
|
85
|
+
(this.temperatureService = this.accessory.getService(this.platform.Service.TemperatureSensor)
|
|
86
|
+
|| this.accessory.addService(this.platform.Service.TemperatureSensor)), temperatureService;
|
|
87
87
|
|
|
88
88
|
this.temperatureService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
|
|
89
89
|
if (!this.temperatureService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -112,9 +112,9 @@ export class Hub {
|
|
|
112
112
|
accessory.removeService(this.humidityService!);
|
|
113
113
|
} else if (!this.humidityService) {
|
|
114
114
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Humidity Sensor Service`);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
const humidityService = `${accessory.displayName} Humidity Sensor`;
|
|
116
|
+
(this.humidityService = this.accessory.getService(this.platform.Service.HumiditySensor)
|
|
117
|
+
|| this.accessory.addService(this.platform.Service.HumiditySensor)), humidityService;
|
|
118
118
|
|
|
119
119
|
this.humidityService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
|
|
120
120
|
if (!this.humidityService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -139,9 +139,9 @@ export class Hub {
|
|
|
139
139
|
accessory.removeService(this.lightSensorService!);
|
|
140
140
|
} else if (!this.lightSensorService) {
|
|
141
141
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Light Sensor Service`);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
const lightSensorService = `${accessory.displayName} Light Sensor`;
|
|
143
|
+
(this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor)
|
|
144
|
+
|| this.accessory.addService(this.platform.Service.LightSensor)), lightSensorService;
|
|
145
145
|
|
|
146
146
|
this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
|
|
147
147
|
this.lightSensorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Light Sensor`);
|
package/src/device/humidifier.ts
CHANGED
|
@@ -84,9 +84,9 @@ export class Humidifier {
|
|
|
84
84
|
|
|
85
85
|
// get the service if it exists, otherwise create a new service
|
|
86
86
|
// you can create multiple services for each accessory
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
const humidifierService = `${accessory.displayName} Humidifier`;
|
|
88
|
+
(this.humidifierService = accessory.getService(this.platform.Service.HumidifierDehumidifier)
|
|
89
|
+
|| accessory.addService(this.platform.Service.HumidifierDehumidifier)), humidifierService;
|
|
90
90
|
|
|
91
91
|
this.humidifierService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
92
92
|
if (!this.humidifierService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -131,9 +131,9 @@ export class Humidifier {
|
|
|
131
131
|
accessory.removeService(this.temperatureservice!);
|
|
132
132
|
} else if (!this.temperatureservice && !this.BLE) {
|
|
133
133
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
const temperatureservice = `${accessory.displayName} Temperature Sensor`;
|
|
135
|
+
(this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor)
|
|
136
|
+
|| this.accessory.addService(this.platform.Service.TemperatureSensor)), temperatureservice;
|
|
137
137
|
|
|
138
138
|
this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
|
|
139
139
|
if (!this.temperatureservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -408,8 +408,8 @@ export class Humidifier {
|
|
|
408
408
|
async pushChanges(): Promise<void> {
|
|
409
409
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
410
410
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
411
|
-
|
|
412
|
-
|
|
411
|
+
/*} else if (this.BLE) {
|
|
412
|
+
await this.BLEpushChanges();*/
|
|
413
413
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
414
414
|
await this.openAPIpushChanges();
|
|
415
415
|
} else {
|
package/src/device/iosensor.ts
CHANGED
|
@@ -98,9 +98,9 @@ export class IOSensor {
|
|
|
98
98
|
accessory.removeService(this.temperatureservice!);
|
|
99
99
|
} else if (!this.temperatureservice) {
|
|
100
100
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
const temperatureservice = `${accessory.displayName} Temperature Sensor`;
|
|
102
|
+
(this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor)
|
|
103
|
+
|| this.accessory.addService(this.platform.Service.TemperatureSensor)), temperatureservice;
|
|
104
104
|
|
|
105
105
|
this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
|
|
106
106
|
if (!this.temperatureservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -129,9 +129,9 @@ export class IOSensor {
|
|
|
129
129
|
accessory.removeService(this.humidityservice!);
|
|
130
130
|
} else if (!this.humidityservice) {
|
|
131
131
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Humidity Sensor Service`);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
const humidityservice = `${accessory.displayName} Humidity Sensor`;
|
|
133
|
+
(this.humidityservice = this.accessory.getService(this.platform.Service.HumiditySensor)
|
|
134
|
+
|| this.accessory.addService(this.platform.Service.HumiditySensor)), humidityservice;
|
|
135
135
|
|
|
136
136
|
this.humidityservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
|
|
137
137
|
if (!this.humidityservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -150,8 +150,9 @@ export class IOSensor {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// Battery Service
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
154
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
155
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
155
156
|
|
|
156
157
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
157
158
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -248,7 +249,7 @@ export class IOSensor {
|
|
|
248
249
|
this.BatteryLevel = 100;
|
|
249
250
|
}
|
|
250
251
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
251
|
-
|
|
252
|
+
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
252
253
|
|
|
253
254
|
// FirmwareRevision
|
|
254
255
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -89,8 +89,9 @@ export class StripLight {
|
|
|
89
89
|
|
|
90
90
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
91
91
|
// you can create multiple services for each accessory
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
const lightBulbService = `${accessory.displayName} ${device.deviceType}`;
|
|
93
|
+
(this.lightBulbService = accessory.getService(this.platform.Service.Lightbulb)
|
|
94
|
+
|| accessory.addService(this.platform.Service.Lightbulb)), lightBulbService;
|
|
94
95
|
|
|
95
96
|
if (this.adaptiveLightingShift === -1 && this.accessory.context.adaptiveLighting) {
|
|
96
97
|
this.accessory.removeService(this.lightBulbService);
|
|
@@ -406,8 +407,8 @@ export class StripLight {
|
|
|
406
407
|
async pushChanges(): Promise<void> {
|
|
407
408
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
408
409
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
409
|
-
|
|
410
|
-
|
|
410
|
+
/* }else if (this.BLE) {
|
|
411
|
+
await this.BLEpushChanges();*/
|
|
411
412
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
412
413
|
await this.openAPIpushChanges();
|
|
413
414
|
} else {
|
package/src/device/lock.ts
CHANGED
|
@@ -77,8 +77,9 @@ export class Lock {
|
|
|
77
77
|
|
|
78
78
|
// get the LockMechanism service if it exists, otherwise create a new LockMechanism service
|
|
79
79
|
// you can create multiple services for each accessory
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
const lockService = `${accessory.displayName} ${device.deviceType}`;
|
|
81
|
+
(this.lockService = accessory.getService(this.platform.Service.LockMechanism)
|
|
82
|
+
|| accessory.addService(this.platform.Service.LockMechanism)), lockService;
|
|
82
83
|
|
|
83
84
|
this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
84
85
|
if (!this.lockService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -98,9 +99,9 @@ export class Lock {
|
|
|
98
99
|
accessory.removeService(this.contactSensorService!);
|
|
99
100
|
} else if (!this.contactSensorService) {
|
|
100
101
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Contact Sensor Service`);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
const contactSensorService = `${accessory.displayName} Contact Sensor`;
|
|
103
|
+
(this.contactSensorService = this.accessory.getService(this.platform.Service.ContactSensor)
|
|
104
|
+
|| this.accessory.addService(this.platform.Service.ContactSensor)), contactSensorService;
|
|
104
105
|
|
|
105
106
|
this.contactSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Contact Sensor`);
|
|
106
107
|
if (!this.contactSensorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -111,8 +112,9 @@ export class Lock {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
// Battery Service
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
116
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
117
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
116
118
|
|
|
117
119
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
118
120
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -159,8 +161,8 @@ export class Lock {
|
|
|
159
161
|
async parseStatus(): Promise<void> {
|
|
160
162
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
161
163
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
+
/* } else if (this.BLE) {
|
|
165
|
+
await this.BLEparseStatus();*/
|
|
164
166
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
165
167
|
await this.openAPIparseStatus();
|
|
166
168
|
} else {
|
|
@@ -367,8 +369,8 @@ export class Lock {
|
|
|
367
369
|
async pushChanges(): Promise<void> {
|
|
368
370
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
369
371
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
370
|
-
|
|
371
|
-
|
|
372
|
+
/*} else if (this.BLE) {
|
|
373
|
+
await this.BLEpushChanges();*/
|
|
372
374
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
373
375
|
await this.openAPIpushChanges();
|
|
374
376
|
} else {
|