@switchbot/homebridge-switchbot 3.5.1-beta.1 → 3.5.1-beta.11
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/README.md +16 -0
- package/dist/device/blindtilt.d.ts +15 -6
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +203 -255
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +9 -4
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +196 -218
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +9 -4
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +203 -249
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +10 -5
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +329 -378
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +9 -4
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +99 -142
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +19 -7
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +203 -264
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +28 -32
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +186 -225
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +9 -4
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +198 -227
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +9 -5
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +106 -231
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +12 -4
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +192 -232
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +9 -4
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +91 -157
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -5
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +287 -367
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +10 -5
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +171 -216
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +9 -4
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +93 -158
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +9 -4
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +94 -155
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +9 -4
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +84 -142
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -4
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +99 -124
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +9 -6
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +170 -253
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +12 -4
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +105 -129
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +2 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +45 -51
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +2 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +17 -17
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +2 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +9 -9
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +19 -19
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +24 -11
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +90 -68
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +2 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +15 -17
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +2 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +76 -76
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +2 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +35 -35
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +2 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +9 -9
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +2 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +9 -9
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +15 -15
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +288 -271
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +49 -191
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +19 -0
- package/dist/settings.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +279 -0
- package/dist/types/bledevicestatus.d.ts.map +1 -0
- package/dist/types/bledevicestatus.js +2 -0
- package/dist/types/bledevicestatus.js.map +1 -0
- package/dist/types/devicelist.d.ts +89 -0
- package/dist/types/devicelist.d.ts.map +1 -0
- package/dist/types/devicelist.js +6 -0
- package/dist/types/devicelist.js.map +1 -0
- package/dist/types/deviceresponse.d.ts +13 -0
- package/dist/types/deviceresponse.d.ts.map +1 -0
- package/dist/types/deviceresponse.js +2 -0
- package/dist/types/deviceresponse.js.map +1 -0
- package/dist/types/devicestatus.d.ts +149 -0
- package/dist/types/devicestatus.d.ts.map +1 -0
- package/dist/types/devicestatus.js +3 -0
- package/dist/types/devicestatus.js.map +1 -0
- package/dist/types/devicewebhookstatus.d.ts +156 -0
- package/dist/types/devicewebhookstatus.d.ts.map +1 -0
- package/dist/types/devicewebhookstatus.js +2 -0
- package/dist/types/devicewebhookstatus.js.map +1 -0
- package/dist/types/irdevicelist.d.ts +10 -0
- package/dist/types/irdevicelist.d.ts.map +1 -0
- package/dist/types/irdevicelist.js +2 -0
- package/dist/types/irdevicelist.js.map +1 -0
- package/dist/types/pushbody.d.ts +6 -0
- package/dist/types/pushbody.d.ts.map +1 -0
- package/dist/types/pushbody.js +2 -0
- package/dist/types/pushbody.js.map +1 -0
- package/dist/utils.d.ts +25 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +28 -0
- package/dist/utils.js.map +1 -1
- package/package.json +10 -10
- package/src/device/blindtilt.ts +224 -264
- package/src/device/bot.ts +208 -221
- package/src/device/ceilinglight.ts +211 -261
- package/src/device/colorbulb.ts +334 -397
- package/src/device/contact.ts +111 -146
- package/src/device/curtain.ts +220 -283
- package/src/device/device.ts +194 -245
- package/src/device/fan.ts +214 -230
- package/src/device/hub.ts +126 -246
- package/src/device/humidifier.ts +216 -243
- package/src/device/iosensor.ts +114 -166
- package/src/device/lightstrip.ts +302 -377
- package/src/device/lock.ts +187 -221
- package/src/device/meter.ts +116 -177
- package/src/device/meterplus.ts +117 -174
- package/src/device/motion.ts +99 -144
- package/src/device/plug.ts +110 -128
- package/src/device/robotvacuumcleaner.ts +189 -252
- package/src/device/waterdetector.ts +123 -139
- package/src/irdevice/airconditioner.ts +47 -52
- package/src/irdevice/airpurifier.ts +19 -18
- package/src/irdevice/camera.ts +11 -10
- package/src/irdevice/fan.ts +21 -20
- package/src/irdevice/irdevice.ts +95 -70
- package/src/irdevice/light.ts +17 -18
- package/src/irdevice/other.ts +78 -77
- package/src/irdevice/tv.ts +37 -36
- package/src/irdevice/vacuumcleaner.ts +11 -10
- package/src/irdevice/waterheater.ts +11 -10
- package/src/platform.ts +290 -272
- package/src/settings.ts +30 -239
- package/src/types/bledevicestatus.ts +305 -0
- package/src/types/devicelist.ts +124 -0
- package/src/types/deviceresponse.ts +15 -0
- package/src/types/devicestatus.ts +178 -0
- package/src/types/devicewebhookstatus.ts +196 -0
- package/src/types/irdevicelist.ts +15 -0
- package/src/types/pushbody.ts +9 -0
- package/src/utils.ts +33 -0
package/src/irdevice/other.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { irdeviceBase } from './irdevice.js';
|
|
6
6
|
|
|
7
7
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
8
|
-
import type { irDevicesConfig
|
|
8
|
+
import type { irDevicesConfig } from '../settings.js';
|
|
9
|
+
import type { irdevice } from '../types/irdevicelist.js';
|
|
9
10
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -98,7 +99,7 @@ export class Others extends irdeviceBase {
|
|
|
98
99
|
On: accessory.context.On ?? false,
|
|
99
100
|
};
|
|
100
101
|
accessory.context.Switch = this.Switch as object;
|
|
101
|
-
this.debugWarnLog(
|
|
102
|
+
this.debugWarnLog('Displaying as Switch');
|
|
102
103
|
|
|
103
104
|
this.Switch.Service
|
|
104
105
|
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
@@ -127,7 +128,7 @@ export class Others extends irdeviceBase {
|
|
|
127
128
|
On: accessory.context.On ?? false,
|
|
128
129
|
};
|
|
129
130
|
accessory.context.GarageDoor = this.GarageDoor as object;
|
|
130
|
-
this.debugWarnLog(
|
|
131
|
+
this.debugWarnLog('Displaying as Garage Door Opener');
|
|
131
132
|
|
|
132
133
|
this.GarageDoor.Service
|
|
133
134
|
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
@@ -157,7 +158,7 @@ export class Others extends irdeviceBase {
|
|
|
157
158
|
On: accessory.context.On ?? false,
|
|
158
159
|
};
|
|
159
160
|
accessory.context.Door = this.Door as object;
|
|
160
|
-
this.debugWarnLog(
|
|
161
|
+
this.debugWarnLog('Displaying as Door');
|
|
161
162
|
|
|
162
163
|
this.Door!.Service
|
|
163
164
|
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
@@ -193,7 +194,7 @@ export class Others extends irdeviceBase {
|
|
|
193
194
|
On: accessory.context.On ?? false,
|
|
194
195
|
};
|
|
195
196
|
accessory.context.Window = this.Window as object;
|
|
196
|
-
this.debugWarnLog(
|
|
197
|
+
this.debugWarnLog('Displaying as Window');
|
|
197
198
|
|
|
198
199
|
this.Window!.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
199
200
|
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
@@ -228,7 +229,7 @@ export class Others extends irdeviceBase {
|
|
|
228
229
|
On: accessory.context.On ?? false,
|
|
229
230
|
};
|
|
230
231
|
accessory.context.WindowCovering = this.WindowCovering as object;
|
|
231
|
-
this.debugWarnLog(
|
|
232
|
+
this.debugWarnLog('Displaying as Window Covering');
|
|
232
233
|
|
|
233
234
|
this.WindowCovering.Service
|
|
234
235
|
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
@@ -264,7 +265,7 @@ export class Others extends irdeviceBase {
|
|
|
264
265
|
On: accessory.context.On ?? false,
|
|
265
266
|
};
|
|
266
267
|
accessory.context.LockMechanism = this.LockMechanism as object;
|
|
267
|
-
this.debugWarnLog(
|
|
268
|
+
this.debugWarnLog('Displaying as Lock');
|
|
268
269
|
|
|
269
270
|
this.LockMechanism.Service
|
|
270
271
|
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
@@ -293,7 +294,7 @@ export class Others extends irdeviceBase {
|
|
|
293
294
|
On: accessory.context.On ?? false,
|
|
294
295
|
};
|
|
295
296
|
accessory.context.Faucet = this.Faucet as object;
|
|
296
|
-
this.debugWarnLog(
|
|
297
|
+
this.debugWarnLog('Displaying as Faucet');
|
|
297
298
|
|
|
298
299
|
this.Faucet.Service
|
|
299
300
|
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
@@ -322,7 +323,7 @@ export class Others extends irdeviceBase {
|
|
|
322
323
|
On: accessory.context.On ?? false,
|
|
323
324
|
};
|
|
324
325
|
accessory.context.Fan = this.Fan as object;
|
|
325
|
-
this.debugWarnLog(
|
|
326
|
+
this.debugWarnLog('Displaying as Fan');
|
|
326
327
|
|
|
327
328
|
this.Fan.Service
|
|
328
329
|
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
@@ -352,7 +353,7 @@ export class Others extends irdeviceBase {
|
|
|
352
353
|
On: accessory.context.On ?? false,
|
|
353
354
|
};
|
|
354
355
|
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch as object;
|
|
355
|
-
this.debugWarnLog(
|
|
356
|
+
this.debugWarnLog('Displaying as Stateful Programmable Switch');
|
|
356
357
|
|
|
357
358
|
this.StatefulProgrammableSwitch.Service
|
|
358
359
|
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
@@ -381,7 +382,7 @@ export class Others extends irdeviceBase {
|
|
|
381
382
|
On: accessory.context.On ?? false,
|
|
382
383
|
};
|
|
383
384
|
accessory.context.Outlet = this.Outlet as object;
|
|
384
|
-
this.debugWarnLog(
|
|
385
|
+
this.debugWarnLog('Displaying as Outlet');
|
|
385
386
|
|
|
386
387
|
this.Outlet.Service
|
|
387
388
|
.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
|
|
@@ -410,7 +411,7 @@ export class Others extends irdeviceBase {
|
|
|
410
411
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
411
412
|
let On: boolean;
|
|
412
413
|
if (this.otherDeviceType === 'garagedoor') {
|
|
413
|
-
this.infoLog(
|
|
414
|
+
this.infoLog(`Set TargetDoorState: ${value}`);
|
|
414
415
|
if (value === this.hap.Characteristic.TargetDoorState.CLOSED) {
|
|
415
416
|
this.GarageDoor!.On = false;
|
|
416
417
|
} else {
|
|
@@ -418,7 +419,7 @@ export class Others extends irdeviceBase {
|
|
|
418
419
|
}
|
|
419
420
|
On = this.GarageDoor!.On;
|
|
420
421
|
} else if (this.otherDeviceType === 'door') {
|
|
421
|
-
this.infoLog(
|
|
422
|
+
this.infoLog(`Set TargetPosition: ${value}`);
|
|
422
423
|
if (value === 0) {
|
|
423
424
|
this.Door!.On = false;
|
|
424
425
|
} else {
|
|
@@ -426,7 +427,7 @@ export class Others extends irdeviceBase {
|
|
|
426
427
|
}
|
|
427
428
|
On = this.Door!.On;
|
|
428
429
|
} else if (this.otherDeviceType === 'window') {
|
|
429
|
-
this.infoLog(
|
|
430
|
+
this.infoLog(`Set TargetPosition: ${value}`);
|
|
430
431
|
if (value === 0) {
|
|
431
432
|
this.Window!.On = false;
|
|
432
433
|
} else {
|
|
@@ -434,7 +435,7 @@ export class Others extends irdeviceBase {
|
|
|
434
435
|
}
|
|
435
436
|
On = this.Window!.On;
|
|
436
437
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
437
|
-
this.infoLog(
|
|
438
|
+
this.infoLog(`Set TargetPosition: ${value}`);
|
|
438
439
|
if (value === 0) {
|
|
439
440
|
this.WindowCovering!.On = false;
|
|
440
441
|
} else {
|
|
@@ -442,7 +443,7 @@ export class Others extends irdeviceBase {
|
|
|
442
443
|
}
|
|
443
444
|
On = this.WindowCovering!.On;
|
|
444
445
|
} else if (this.otherDeviceType === 'lock') {
|
|
445
|
-
this.infoLog(
|
|
446
|
+
this.infoLog(`Set LockTargetState: ${value}`);
|
|
446
447
|
if (value === this.hap.Characteristic.LockTargetState.SECURED) {
|
|
447
448
|
this.LockMechanism!.On = false;
|
|
448
449
|
} else {
|
|
@@ -450,7 +451,7 @@ export class Others extends irdeviceBase {
|
|
|
450
451
|
}
|
|
451
452
|
On = this.LockMechanism!.On;
|
|
452
453
|
} else if (this.otherDeviceType === 'faucet') {
|
|
453
|
-
this.infoLog(
|
|
454
|
+
this.infoLog(`Set Active: ${value}`);
|
|
454
455
|
if (value === this.hap.Characteristic.Active.INACTIVE) {
|
|
455
456
|
this.Faucet!.On = false;
|
|
456
457
|
} else {
|
|
@@ -458,7 +459,7 @@ export class Others extends irdeviceBase {
|
|
|
458
459
|
}
|
|
459
460
|
On = this.Faucet!.On;
|
|
460
461
|
} else if (this.otherDeviceType === 'stateful') {
|
|
461
|
-
this.infoLog(
|
|
462
|
+
this.infoLog(`Set ProgrammableSwitchOutputState: ${value}`);
|
|
462
463
|
if (value === 0) {
|
|
463
464
|
this.StatefulProgrammableSwitch!.On = false;
|
|
464
465
|
} else {
|
|
@@ -467,7 +468,7 @@ export class Others extends irdeviceBase {
|
|
|
467
468
|
|
|
468
469
|
On = this.StatefulProgrammableSwitch!.On;
|
|
469
470
|
} else {
|
|
470
|
-
this.infoLog(
|
|
471
|
+
this.infoLog(`Set On: ${value}`);
|
|
471
472
|
this.Outlet!.On = value;
|
|
472
473
|
On = this.Outlet!.On ? true : false;
|
|
473
474
|
}
|
|
@@ -491,7 +492,7 @@ export class Others extends irdeviceBase {
|
|
|
491
492
|
* Other - "command" "channelSub" "default" = previous channel
|
|
492
493
|
*/
|
|
493
494
|
async pushOnChanges(On: boolean): Promise<void> {
|
|
494
|
-
this.debugLog(
|
|
495
|
+
await this.debugLog(`pushOnChanges On: ${On},`
|
|
495
496
|
+ ` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`);
|
|
496
497
|
if (this.device.customize) {
|
|
497
498
|
if (On === true && !this.disablePushOn) {
|
|
@@ -505,12 +506,12 @@ export class Others extends irdeviceBase {
|
|
|
505
506
|
await this.pushChanges(bodyChange);
|
|
506
507
|
}
|
|
507
508
|
} else {
|
|
508
|
-
this.errorLog(
|
|
509
|
+
this.errorLog('On Command not set');
|
|
509
510
|
}
|
|
510
511
|
}
|
|
511
512
|
|
|
512
513
|
async pushOffChanges(On: boolean): Promise<void> {
|
|
513
|
-
this.debugLog(
|
|
514
|
+
await this.debugLog(`pushOffChanges On: ${On},`
|
|
514
515
|
+ ` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`);
|
|
515
516
|
if (this.device.customize) {
|
|
516
517
|
if (On === false && !this.disablePushOff) {
|
|
@@ -524,14 +525,14 @@ export class Others extends irdeviceBase {
|
|
|
524
525
|
await this.pushChanges(bodyChange);
|
|
525
526
|
}
|
|
526
527
|
} else {
|
|
527
|
-
this.errorLog(
|
|
528
|
+
this.errorLog('Off Command not set.');
|
|
528
529
|
}
|
|
529
530
|
}
|
|
530
531
|
|
|
531
532
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
532
|
-
this.debugLog(
|
|
533
|
+
await this.debugLog('pushChanges');
|
|
533
534
|
if (this.device.connectionType === 'OpenAPI') {
|
|
534
|
-
this.infoLog(
|
|
535
|
+
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
535
536
|
try {
|
|
536
537
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
537
538
|
const deviceStatus: any = await body.json();
|
|
@@ -548,165 +549,165 @@ export class Others extends irdeviceBase {
|
|
|
548
549
|
await this.pushChangeError(e);
|
|
549
550
|
}
|
|
550
551
|
} else {
|
|
551
|
-
this.warnLog(
|
|
552
|
-
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
552
|
+
await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
|
|
556
556
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
557
|
+
await this.debugLog('updateHomeKitCharacteristics');
|
|
557
558
|
if (this.otherDeviceType === 'garagedoor') {
|
|
558
559
|
if (this.GarageDoor!.On === undefined) {
|
|
559
|
-
this.debugLog(
|
|
560
|
+
await this.debugLog(`On: ${this.GarageDoor!.On}`);
|
|
560
561
|
} else {
|
|
561
562
|
if (this.GarageDoor!.On) {
|
|
562
563
|
this.GarageDoor!.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.OPEN);
|
|
563
564
|
this.GarageDoor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.OPEN);
|
|
564
|
-
this.debugLog(
|
|
565
|
+
await this.debugLog('updateCharacteristic'
|
|
565
566
|
+ ` TargetDoorState: Open, CurrentDoorState: Open (${this.GarageDoor!.On})`);
|
|
566
567
|
} else {
|
|
567
568
|
this.GarageDoor!.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
|
|
568
569
|
this.GarageDoor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
|
|
569
|
-
this.debugLog(
|
|
570
|
+
await this.debugLog('updateCharacteristic'
|
|
570
571
|
+ ` TargetDoorState: Closed, CurrentDoorState: Closed (${this.GarageDoor!.On})`);
|
|
571
572
|
}
|
|
572
573
|
}
|
|
573
|
-
this.debugLog(
|
|
574
|
+
await this.debugLog(`Garage Door On: ${this.GarageDoor!.On}`);
|
|
574
575
|
} else if (this.otherDeviceType === 'door') {
|
|
575
576
|
if (this.Door!.On === undefined) {
|
|
576
|
-
this.debugLog(
|
|
577
|
+
await this.debugLog(`On: ${this.Door!.On}`);
|
|
577
578
|
} else {
|
|
578
579
|
if (this.Door!.On) {
|
|
579
580
|
this.Door!.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
580
581
|
this.Door!.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
581
582
|
this.Door!.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
582
|
-
this.debugLog(
|
|
583
|
+
await this.debugLog('updateCharacteristic'
|
|
583
584
|
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Door!.On})`);
|
|
584
585
|
} else {
|
|
585
586
|
this.Door!.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
586
587
|
this.Door!.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
587
588
|
this.Door!.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
588
|
-
this.debugLog(
|
|
589
|
+
await this.debugLog('updateCharacteristic'
|
|
589
590
|
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Door!.On})`);
|
|
590
591
|
}
|
|
591
592
|
}
|
|
592
|
-
this.debugLog(
|
|
593
|
+
await this.debugLog(`Door On: ${this.Door!.On}`);
|
|
593
594
|
} else if (this.otherDeviceType === 'window') {
|
|
594
595
|
if (this.Window!.On === undefined) {
|
|
595
|
-
this.debugLog(
|
|
596
|
+
await this.debugLog(`On: ${this.Window!.On}`);
|
|
596
597
|
} else {
|
|
597
598
|
if (this.Window!.On) {
|
|
598
599
|
this.Window!.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
599
600
|
this.Window!.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
600
601
|
this.Window!.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
601
|
-
this.debugLog(
|
|
602
|
+
await this.debugLog('updateCharacteristic'
|
|
602
603
|
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Window!.On})`);
|
|
603
604
|
} else {
|
|
604
605
|
this.Window!.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
605
606
|
this.Window!.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
606
607
|
this.Window!.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
607
|
-
this.debugLog(
|
|
608
|
+
await this.debugLog('updateCharacteristic'
|
|
608
609
|
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Window!.On})`);
|
|
609
610
|
}
|
|
610
611
|
}
|
|
611
|
-
this.debugLog(
|
|
612
|
+
await this.debugLog(`Window On: ${this.Window!.On}`);
|
|
612
613
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
613
614
|
if (this.WindowCovering!.On === undefined) {
|
|
614
|
-
this.debugLog(
|
|
615
|
+
await this.debugLog(`On: ${this.WindowCovering!.On}`);
|
|
615
616
|
} else {
|
|
616
617
|
if (this.WindowCovering!.On) {
|
|
617
618
|
this.WindowCovering!.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
618
619
|
this.WindowCovering!.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
619
620
|
this.WindowCovering!.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
620
|
-
this.debugLog(
|
|
621
|
+
await this.debugLog('updateCharacteristic'
|
|
621
622
|
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.WindowCovering!.On})`);
|
|
622
623
|
} else {
|
|
623
624
|
this.WindowCovering!.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
624
625
|
this.WindowCovering!.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
625
626
|
this.WindowCovering!.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
626
|
-
this.debugLog(
|
|
627
|
+
await this.debugLog('updateCharacteristic'
|
|
627
628
|
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.WindowCovering!.On})`);
|
|
628
629
|
}
|
|
629
630
|
}
|
|
630
|
-
this.debugLog(
|
|
631
|
+
await this.debugLog(`Window Covering On: ${this.WindowCovering!.On}`);
|
|
631
632
|
} else if (this.otherDeviceType === 'lock') {
|
|
632
633
|
if (this.LockMechanism?.On === undefined) {
|
|
633
|
-
this.debugLog(
|
|
634
|
+
await this.debugLog(`On: ${this.LockMechanism?.On}`);
|
|
634
635
|
} else {
|
|
635
636
|
if (this.LockMechanism.On) {
|
|
636
637
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState,
|
|
637
638
|
this.hap.Characteristic.LockTargetState.UNSECURED);
|
|
638
639
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState,
|
|
639
640
|
this.hap.Characteristic.LockCurrentState.UNSECURED);
|
|
640
|
-
this.debugLog(
|
|
641
|
+
await this.debugLog('updateCharacteristic'
|
|
641
642
|
+ ` LockTargetState: UNSECURED, LockCurrentState: UNSECURE (${this.LockMechanism.On})`);
|
|
642
643
|
} else {
|
|
643
644
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState,
|
|
644
645
|
this.hap.Characteristic.LockTargetState.SECURED);
|
|
645
646
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState,
|
|
646
647
|
this.hap.Characteristic.LockCurrentState.SECURED);
|
|
647
|
-
this.debugLog(
|
|
648
|
+
await this.debugLog('updateCharacteristic'
|
|
648
649
|
+ ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.LockMechanism.On})`);
|
|
649
650
|
}
|
|
650
651
|
}
|
|
651
|
-
this.debugLog(
|
|
652
|
+
await this.debugLog(`Lock On: ${this.LockMechanism?.On}`);
|
|
652
653
|
} else if (this.otherDeviceType === 'faucet') {
|
|
653
654
|
if (this.Faucet!.On === undefined) {
|
|
654
|
-
this.debugLog(
|
|
655
|
+
await this.debugLog(`On: ${this.Faucet!.On}`);
|
|
655
656
|
} else {
|
|
656
657
|
if (this.Faucet!.On) {
|
|
657
658
|
this.Faucet!.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
|
|
658
|
-
this.debugLog(
|
|
659
|
+
await this.debugLog(`updateCharacteristic Active: ${this.Faucet!.On}`);
|
|
659
660
|
} else {
|
|
660
661
|
this.Faucet!.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
661
|
-
this.debugLog(
|
|
662
|
+
await this.debugLog(`updateCharacteristic Active: ${this.Faucet!.On}`);
|
|
662
663
|
}
|
|
663
664
|
}
|
|
664
|
-
this.debugLog(
|
|
665
|
+
await this.debugLog(`Faucet On: ${this.Faucet!.On}`);
|
|
665
666
|
} else if (this.otherDeviceType === 'fan') {
|
|
666
667
|
if (this.Fan!.On === undefined) {
|
|
667
|
-
this.debugLog(
|
|
668
|
+
await this.debugLog(`On: ${this.Fan!.On}`);
|
|
668
669
|
} else {
|
|
669
670
|
if (this.Fan!.On) {
|
|
670
671
|
this.Fan!.Service.updateCharacteristic(this.hap.Characteristic.On, this.Fan!.On);
|
|
671
|
-
this.debugLog(
|
|
672
|
+
await this.debugLog(`updateCharacteristic On: ${this.Fan!.On}`);
|
|
672
673
|
} else {
|
|
673
674
|
this.Fan!.Service.updateCharacteristic(this.hap.Characteristic.On, this.Fan!.On);
|
|
674
|
-
this.debugLog(
|
|
675
|
+
await this.debugLog(`updateCharacteristic On: ${this.Fan!.On}`);
|
|
675
676
|
}
|
|
676
677
|
}
|
|
677
|
-
this.debugLog(
|
|
678
|
+
await this.debugLog(`Fan On: ${this.Fan!.On}`);
|
|
678
679
|
} else if (this.otherDeviceType === 'stateful') {
|
|
679
680
|
if (this.StatefulProgrammableSwitch!.On === undefined) {
|
|
680
|
-
this.debugLog(
|
|
681
|
+
await this.debugLog(`On: ${this.StatefulProgrammableSwitch!.On}`);
|
|
681
682
|
} else {
|
|
682
683
|
if (this.StatefulProgrammableSwitch!.On) {
|
|
683
684
|
this.StatefulProgrammableSwitch!.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
684
685
|
this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
685
686
|
this.StatefulProgrammableSwitch!.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
686
|
-
this.debugLog(
|
|
687
|
+
await this.debugLog('updateCharacteristic'
|
|
687
688
|
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1 (${this.StatefulProgrammableSwitch!.On})`);
|
|
688
689
|
} else {
|
|
689
690
|
this.StatefulProgrammableSwitch!.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
690
691
|
this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
691
692
|
this.StatefulProgrammableSwitch!.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
692
|
-
this.debugLog(
|
|
693
|
+
await this.debugLog('updateCharacteristic'
|
|
693
694
|
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0 (${this.StatefulProgrammableSwitch!.On})`);
|
|
694
695
|
}
|
|
695
696
|
}
|
|
696
|
-
this.debugLog(
|
|
697
|
+
await this.debugLog(`StatefulProgrammableSwitch On: ${this.StatefulProgrammableSwitch!.On}`);
|
|
697
698
|
} else if (this.otherDeviceType === 'switch') {
|
|
698
699
|
if (this.Switch!.On === undefined) {
|
|
699
|
-
this.debugLog(
|
|
700
|
+
await this.debugLog(`On: ${this.Switch!.On}`);
|
|
700
701
|
} else {
|
|
701
702
|
this.Switch!.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch!.On);
|
|
702
|
-
this.debugLog(
|
|
703
|
+
await this.debugLog(`updateCharacteristic On: ${this.Switch!.On}`);
|
|
703
704
|
}
|
|
704
705
|
} else {
|
|
705
706
|
if (this.Outlet!.On === undefined) {
|
|
706
|
-
this.debugLog(
|
|
707
|
+
await this.debugLog(`On: ${this.Outlet!.On}`);
|
|
707
708
|
} else {
|
|
708
709
|
this.Outlet!.Service.updateCharacteristic(this.hap.Characteristic.On, this.Outlet!.On);
|
|
709
|
-
this.debugLog(
|
|
710
|
+
await this.debugLog(`updateCharacteristic On: ${this.Outlet!.On}`);
|
|
710
711
|
}
|
|
711
712
|
}
|
|
712
713
|
}
|
|
@@ -769,7 +770,7 @@ export class Others extends irdeviceBase {
|
|
|
769
770
|
// If Outlet.Service still present, then remove first
|
|
770
771
|
if (this.Outlet?.Service) {
|
|
771
772
|
this.Outlet.Service = this.accessory.getService(this.hap.Service.Outlet) as Service;
|
|
772
|
-
this.warnLog(
|
|
773
|
+
this.warnLog('Removing Leftover Outlet Service');
|
|
773
774
|
accessory.removeService(this.Outlet.Service);
|
|
774
775
|
}
|
|
775
776
|
}
|
|
@@ -778,7 +779,7 @@ export class Others extends irdeviceBase {
|
|
|
778
779
|
// If GarageDoor.Service still present, then remove first
|
|
779
780
|
if (this.GarageDoor?.Service) {
|
|
780
781
|
this.GarageDoor.Service = this.accessory.getService(this.hap.Service.GarageDoorOpener) as Service;
|
|
781
|
-
this.warnLog(
|
|
782
|
+
this.warnLog('Removing Leftover Garage Door Service');
|
|
782
783
|
accessory.removeService(this.GarageDoor.Service);
|
|
783
784
|
}
|
|
784
785
|
}
|
|
@@ -787,7 +788,7 @@ export class Others extends irdeviceBase {
|
|
|
787
788
|
// If Door.Service still present, then remove first
|
|
788
789
|
if (this.Door?.Service) {
|
|
789
790
|
this.Door.Service = this.accessory.getService(this.hap.Service.Door) as Service;
|
|
790
|
-
this.warnLog(
|
|
791
|
+
this.warnLog('Removing Leftover Door Service');
|
|
791
792
|
accessory.removeService(this.Door.Service);
|
|
792
793
|
}
|
|
793
794
|
}
|
|
@@ -796,7 +797,7 @@ export class Others extends irdeviceBase {
|
|
|
796
797
|
// If Lock.Service still present, then remove first
|
|
797
798
|
if (this.LockMechanism?.Service) {
|
|
798
799
|
this.LockMechanism.Service = this.accessory.getService(this.hap.Service.LockMechanism) as Service;
|
|
799
|
-
this.warnLog(
|
|
800
|
+
this.warnLog('Removing Leftover Lock Service');
|
|
800
801
|
accessory.removeService(this.LockMechanism.Service);
|
|
801
802
|
}
|
|
802
803
|
}
|
|
@@ -805,7 +806,7 @@ export class Others extends irdeviceBase {
|
|
|
805
806
|
// If Faucet.Service still present, then remove first
|
|
806
807
|
if (this.Faucet?.Service) {
|
|
807
808
|
this.Faucet.Service = this.accessory.getService(this.hap.Service.Faucet) as Service;
|
|
808
|
-
this.warnLog(
|
|
809
|
+
this.warnLog('Removing Leftover Faucet Service');
|
|
809
810
|
accessory.removeService(this.Faucet.Service);
|
|
810
811
|
}
|
|
811
812
|
}
|
|
@@ -814,7 +815,7 @@ export class Others extends irdeviceBase {
|
|
|
814
815
|
// If Fan Service still present, then remove first
|
|
815
816
|
if (this.Fan?.Service) {
|
|
816
817
|
this.Fan.Service = this.accessory.getService(this.hap.Service.Fan) as Service;
|
|
817
|
-
this.warnLog(
|
|
818
|
+
this.warnLog('Removing Leftover Fan Service');
|
|
818
819
|
accessory.removeService(this.Fan.Service);
|
|
819
820
|
}
|
|
820
821
|
}
|
|
@@ -823,7 +824,7 @@ export class Others extends irdeviceBase {
|
|
|
823
824
|
// If Window.Service still present, then remove first
|
|
824
825
|
if (this.Window?.Service) {
|
|
825
826
|
this.Window.Service = this.accessory.getService(this.hap.Service.Window) as Service;
|
|
826
|
-
this.warnLog(
|
|
827
|
+
this.warnLog('Removing Leftover Window Service');
|
|
827
828
|
accessory.removeService(this.Window.Service);
|
|
828
829
|
}
|
|
829
830
|
}
|
|
@@ -832,7 +833,7 @@ export class Others extends irdeviceBase {
|
|
|
832
833
|
// If WindowCovering.Service still present, then remove first
|
|
833
834
|
if (this.WindowCovering?.Service) {
|
|
834
835
|
this.WindowCovering.Service = this.accessory.getService(this.hap.Service.WindowCovering) as Service;
|
|
835
|
-
this.warnLog(
|
|
836
|
+
this.warnLog('Removing Leftover Window Covering Service');
|
|
836
837
|
accessory.removeService(this.WindowCovering.Service);
|
|
837
838
|
}
|
|
838
839
|
}
|
|
@@ -841,7 +842,7 @@ export class Others extends irdeviceBase {
|
|
|
841
842
|
// If StatefulProgrammableSwitch.Service still present, then remove first
|
|
842
843
|
if (this.StatefulProgrammableSwitch?.Service) {
|
|
843
844
|
this.StatefulProgrammableSwitch.Service = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch) as Service;
|
|
844
|
-
this.warnLog(
|
|
845
|
+
this.warnLog('Removing Leftover Stateful Programmable Switch Service');
|
|
845
846
|
accessory.removeService(this.StatefulProgrammableSwitch.Service);
|
|
846
847
|
}
|
|
847
848
|
}
|
|
@@ -850,7 +851,7 @@ export class Others extends irdeviceBase {
|
|
|
850
851
|
// If Switch.Service still present, then remove first
|
|
851
852
|
if (this.Switch?.Service) {
|
|
852
853
|
this.Switch.Service = this.accessory.getService(this.hap.Service.Switch) as Service;
|
|
853
|
-
this.warnLog(
|
|
854
|
+
this.warnLog('Removing Leftover Switch Service');
|
|
854
855
|
accessory.removeService(this.Switch.Service);
|
|
855
856
|
}
|
|
856
857
|
}
|
|
@@ -858,15 +859,15 @@ export class Others extends irdeviceBase {
|
|
|
858
859
|
async getOtherConfigSettings(device: irdevice & irDevicesConfig): Promise<void> {
|
|
859
860
|
if (!device.other?.deviceType && this.accessory.context.deviceType) {
|
|
860
861
|
this.otherDeviceType = this.accessory.context.deviceType;
|
|
861
|
-
this.debugWarnLog(
|
|
862
|
+
await this.debugWarnLog(`Using Device Type: ${this.otherDeviceType}, from Accessory Cache.`);
|
|
862
863
|
} else if (device.other?.deviceType) {
|
|
863
864
|
this.accessory.context.deviceType = device.other.deviceType;
|
|
864
|
-
this.debugWarnLog(
|
|
865
|
+
await this.debugWarnLog(`Accessory Cache: ${this.accessory.context.deviceType}`);
|
|
865
866
|
this.otherDeviceType = this.accessory.context.deviceType;
|
|
866
|
-
this.debugWarnLog(
|
|
867
|
+
await this.debugWarnLog(`Using Device Type: ${this.otherDeviceType}`);
|
|
867
868
|
} else {
|
|
868
869
|
this.otherDeviceType = 'outlet';
|
|
869
|
-
this.warnLog(
|
|
870
|
+
this.warnLog(`no deviceType set, using default deviceType: ${this.otherDeviceType}`);
|
|
870
871
|
}
|
|
871
872
|
}
|
|
872
873
|
}
|