@switchbot/homebridge-switchbot 4.1.1-beta.0 → 4.1.1-beta.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/dist/device/bot.js +1 -1
- package/dist/irdevice/other.js +38 -38
- package/package.json +1 -1
- package/src/device/bot.ts +1 -1
- package/src/irdevice/other.ts +38 -38
package/dist/device/bot.js
CHANGED
|
@@ -690,7 +690,7 @@ export class Bot extends deviceBase {
|
|
|
690
690
|
}
|
|
691
691
|
async getBotConfigSettings(device) {
|
|
692
692
|
// Bot Device Type
|
|
693
|
-
this.botDeviceType = device.type ?? '
|
|
693
|
+
this.botDeviceType = device.type ?? 'Outlet';
|
|
694
694
|
const botDeviceType = device.type ? 'Device Config' : 'Default';
|
|
695
695
|
await this.debugWarnLog(`Use ${botDeviceType} Device Type: ${this.botDeviceType}`);
|
|
696
696
|
// Bot Mode
|
package/dist/irdevice/other.js
CHANGED
|
@@ -26,7 +26,7 @@ export class Others extends irdeviceBase {
|
|
|
26
26
|
// default placeholders
|
|
27
27
|
this.getOtherConfigSettings(accessory, device);
|
|
28
28
|
// deviceType
|
|
29
|
-
if (this.otherDeviceType === '
|
|
29
|
+
if (this.otherDeviceType === 'Switch') {
|
|
30
30
|
// Set category
|
|
31
31
|
accessory.category = 8 /* this.hap.Categories.SWITCH */;
|
|
32
32
|
// Initialize Switch Service
|
|
@@ -50,7 +50,7 @@ export class Others extends irdeviceBase {
|
|
|
50
50
|
this.removeWindowCoveringService(accessory);
|
|
51
51
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
52
52
|
}
|
|
53
|
-
else if (this.otherDeviceType === '
|
|
53
|
+
else if (this.otherDeviceType === 'GarageDoor') {
|
|
54
54
|
// Set category
|
|
55
55
|
accessory.category = 4 /* this.hap.Categories.GARAGE_DOOR_OPENER */;
|
|
56
56
|
// Initialize GarageDoor Service
|
|
@@ -79,7 +79,7 @@ export class Others extends irdeviceBase {
|
|
|
79
79
|
this.removeWindowCoveringService(accessory);
|
|
80
80
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
81
81
|
}
|
|
82
|
-
else if (this.otherDeviceType === '
|
|
82
|
+
else if (this.otherDeviceType === 'Door') {
|
|
83
83
|
// Set category
|
|
84
84
|
accessory.category = 12 /* this.hap.Categories.DOOR */;
|
|
85
85
|
// Initialize Door Service
|
|
@@ -108,7 +108,7 @@ export class Others extends irdeviceBase {
|
|
|
108
108
|
this.removeWindowCoveringService(accessory);
|
|
109
109
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
110
110
|
}
|
|
111
|
-
else if (this.otherDeviceType === '
|
|
111
|
+
else if (this.otherDeviceType === 'Window') {
|
|
112
112
|
// Set category
|
|
113
113
|
accessory.category = 13 /* this.hap.Categories.WINDOW */;
|
|
114
114
|
// Initialize Window Service
|
|
@@ -137,7 +137,7 @@ export class Others extends irdeviceBase {
|
|
|
137
137
|
this.removeWindowCoveringService(accessory);
|
|
138
138
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
139
139
|
}
|
|
140
|
-
else if (this.otherDeviceType === '
|
|
140
|
+
else if (this.otherDeviceType === 'WindowCovering') {
|
|
141
141
|
// Set category
|
|
142
142
|
accessory.category = 14 /* this.hap.Categories.WINDOW_COVERING */;
|
|
143
143
|
// Initialize WindowCovering Service
|
|
@@ -166,7 +166,7 @@ export class Others extends irdeviceBase {
|
|
|
166
166
|
this.removeGarageDoorService(accessory);
|
|
167
167
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
168
168
|
}
|
|
169
|
-
else if (this.otherDeviceType === '
|
|
169
|
+
else if (this.otherDeviceType === 'Lock') {
|
|
170
170
|
// Set category
|
|
171
171
|
accessory.category = 6 /* this.hap.Categories.DOOR_LOCK */;
|
|
172
172
|
// Initialize Lock Service
|
|
@@ -190,7 +190,7 @@ export class Others extends irdeviceBase {
|
|
|
190
190
|
this.removeWindowCoveringService(accessory);
|
|
191
191
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
192
192
|
}
|
|
193
|
-
else if (this.otherDeviceType === '
|
|
193
|
+
else if (this.otherDeviceType === 'Faucet') {
|
|
194
194
|
// Set category
|
|
195
195
|
accessory.category = 29 /* this.hap.Categories.FAUCET */;
|
|
196
196
|
// Initialize Faucet Service
|
|
@@ -214,7 +214,7 @@ export class Others extends irdeviceBase {
|
|
|
214
214
|
this.removeWindowCoveringService(accessory);
|
|
215
215
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
216
216
|
}
|
|
217
|
-
else if (this.otherDeviceType === '
|
|
217
|
+
else if (this.otherDeviceType === 'Fan') {
|
|
218
218
|
// Set category
|
|
219
219
|
accessory.category = 3 /* this.hap.Categories.FAN */;
|
|
220
220
|
// Initialize Fan Service
|
|
@@ -238,7 +238,7 @@ export class Others extends irdeviceBase {
|
|
|
238
238
|
this.removeWindowCoveringService(accessory);
|
|
239
239
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
240
240
|
}
|
|
241
|
-
else if (this.otherDeviceType === '
|
|
241
|
+
else if (this.otherDeviceType === 'Stateful') {
|
|
242
242
|
// Set category
|
|
243
243
|
accessory.category = 15 /* this.hap.Categories.PROGRAMMABLE_SWITCH */;
|
|
244
244
|
// Initialize StatefulProgrammableSwitch Service
|
|
@@ -262,7 +262,7 @@ export class Others extends irdeviceBase {
|
|
|
262
262
|
this.removeGarageDoorService(accessory);
|
|
263
263
|
this.removeWindowCoveringService(accessory);
|
|
264
264
|
}
|
|
265
|
-
else if (this.otherDeviceType === '
|
|
265
|
+
else if (this.otherDeviceType === 'Outlet') {
|
|
266
266
|
// Set category
|
|
267
267
|
accessory.category = 7 /* this.hap.Categories.OUTLET */;
|
|
268
268
|
// Initialize Switch property
|
|
@@ -294,49 +294,49 @@ export class Others extends irdeviceBase {
|
|
|
294
294
|
* Handle requests to set the "On" characteristic
|
|
295
295
|
*/
|
|
296
296
|
async OnSet(value) {
|
|
297
|
-
if (this.otherDeviceType === '
|
|
297
|
+
if (this.otherDeviceType === 'Switch') {
|
|
298
298
|
if (this.Switch) {
|
|
299
299
|
await this.debugLog(`Set On: ${value}`);
|
|
300
300
|
this.On = value !== false;
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
else if (this.otherDeviceType === '
|
|
303
|
+
else if (this.otherDeviceType === 'GarageDoor') {
|
|
304
304
|
if (this.GarageDoor) {
|
|
305
305
|
await this.debugLog(`Set TargetDoorState: ${value}`);
|
|
306
306
|
this.On = value !== this.hap.Characteristic.TargetDoorState.CLOSED;
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
|
-
else if (this.otherDeviceType === '
|
|
309
|
+
else if (this.otherDeviceType === 'Door') {
|
|
310
310
|
if (this.Door) {
|
|
311
311
|
await this.debugLog(`Set TargetPosition: ${value}`);
|
|
312
312
|
this.On = value !== 0;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
else if (this.otherDeviceType === '
|
|
315
|
+
else if (this.otherDeviceType === 'Window') {
|
|
316
316
|
if (this.Window) {
|
|
317
317
|
await this.debugLog(`Set TargetPosition: ${value}`);
|
|
318
318
|
this.On = value !== 0;
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
else if (this.otherDeviceType === '
|
|
321
|
+
else if (this.otherDeviceType === 'WindowCovering') {
|
|
322
322
|
if (this.WindowCovering) {
|
|
323
323
|
await this.debugLog(`Set TargetPosition: ${value}`);
|
|
324
324
|
this.On = value !== 0;
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
else if (this.otherDeviceType === '
|
|
327
|
+
else if (this.otherDeviceType === 'Lock') {
|
|
328
328
|
if (this.LockMechanism) {
|
|
329
329
|
await this.debugLog(`Set LockTargetState: ${value}`);
|
|
330
330
|
this.On = value !== this.hap.Characteristic.LockTargetState.SECURED;
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
else if (this.otherDeviceType === '
|
|
333
|
+
else if (this.otherDeviceType === 'Faucet') {
|
|
334
334
|
if (this.Faucet) {
|
|
335
335
|
await this.debugLog(`Set Active: ${value}`);
|
|
336
336
|
this.On = value !== this.hap.Characteristic.Active.INACTIVE;
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
else if (this.otherDeviceType === '
|
|
339
|
+
else if (this.otherDeviceType === 'Stateful') {
|
|
340
340
|
if (this.StatefulProgrammableSwitch) {
|
|
341
341
|
await this.debugLog(`Set ProgrammableSwitchOutputState: ${value}`);
|
|
342
342
|
this.On = value !== 0;
|
|
@@ -430,7 +430,7 @@ export class Others extends irdeviceBase {
|
|
|
430
430
|
async updateHomeKitCharacteristics() {
|
|
431
431
|
await this.debugLog('updateHomeKitCharacteristics');
|
|
432
432
|
// State
|
|
433
|
-
if (this.otherDeviceType === '
|
|
433
|
+
if (this.otherDeviceType === 'Switch' && this.Switch) {
|
|
434
434
|
if (this.On === undefined) {
|
|
435
435
|
await this.debugLog(`On: ${this.On}`);
|
|
436
436
|
}
|
|
@@ -439,7 +439,7 @@ export class Others extends irdeviceBase {
|
|
|
439
439
|
await this.debugLog(`updateCharacteristic On: ${this.On}`);
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
else if (this.otherDeviceType === '
|
|
442
|
+
else if (this.otherDeviceType === 'GarageDoor' && this.GarageDoor) {
|
|
443
443
|
if (this.On === undefined) {
|
|
444
444
|
await this.debugLog(`On: ${this.On}`);
|
|
445
445
|
}
|
|
@@ -457,7 +457,7 @@ export class Others extends irdeviceBase {
|
|
|
457
457
|
}
|
|
458
458
|
await this.debugLog(`Garage Door On: ${this.On}`);
|
|
459
459
|
}
|
|
460
|
-
else if (this.otherDeviceType === '
|
|
460
|
+
else if (this.otherDeviceType === 'Door' && this.Door) {
|
|
461
461
|
if (this.On === undefined) {
|
|
462
462
|
await this.debugLog(`On: ${this.On}`);
|
|
463
463
|
}
|
|
@@ -477,7 +477,7 @@ export class Others extends irdeviceBase {
|
|
|
477
477
|
}
|
|
478
478
|
await this.debugLog(`Door On: ${this.On}`);
|
|
479
479
|
}
|
|
480
|
-
else if (this.otherDeviceType === '
|
|
480
|
+
else if (this.otherDeviceType === 'Window' && this.Window) {
|
|
481
481
|
if (this.On === undefined) {
|
|
482
482
|
await this.debugLog(`On: ${this.On}`);
|
|
483
483
|
}
|
|
@@ -497,7 +497,7 @@ export class Others extends irdeviceBase {
|
|
|
497
497
|
}
|
|
498
498
|
await this.debugLog(`Window On: ${this.On}`);
|
|
499
499
|
}
|
|
500
|
-
else if (this.otherDeviceType === '
|
|
500
|
+
else if (this.otherDeviceType === 'WindowCovering' && this.WindowCovering) {
|
|
501
501
|
if (this.On === undefined) {
|
|
502
502
|
await this.debugLog(`On: ${this.On}`);
|
|
503
503
|
}
|
|
@@ -517,7 +517,7 @@ export class Others extends irdeviceBase {
|
|
|
517
517
|
}
|
|
518
518
|
await this.debugLog(`Window Covering On: ${this.On}`);
|
|
519
519
|
}
|
|
520
|
-
else if (this.otherDeviceType === '
|
|
520
|
+
else if (this.otherDeviceType === 'Lock' && this.LockMechanism) {
|
|
521
521
|
if (this.On === undefined) {
|
|
522
522
|
await this.debugLog(`On: ${this.On}`);
|
|
523
523
|
}
|
|
@@ -535,7 +535,7 @@ export class Others extends irdeviceBase {
|
|
|
535
535
|
}
|
|
536
536
|
await this.debugLog(`Lock On: ${this.On}`);
|
|
537
537
|
}
|
|
538
|
-
else if (this.otherDeviceType === '
|
|
538
|
+
else if (this.otherDeviceType === 'Faucet' && this.Faucet) {
|
|
539
539
|
if (this.On === undefined) {
|
|
540
540
|
await this.debugLog(`On: ${this.On}`);
|
|
541
541
|
}
|
|
@@ -551,7 +551,7 @@ export class Others extends irdeviceBase {
|
|
|
551
551
|
}
|
|
552
552
|
await this.debugLog(`Faucet On: ${this.On}`);
|
|
553
553
|
}
|
|
554
|
-
else if (this.otherDeviceType === '
|
|
554
|
+
else if (this.otherDeviceType === 'Fan' && this.Fan) {
|
|
555
555
|
if (this.On === undefined) {
|
|
556
556
|
await this.debugLog(`On: ${this.On}`);
|
|
557
557
|
}
|
|
@@ -567,7 +567,7 @@ export class Others extends irdeviceBase {
|
|
|
567
567
|
}
|
|
568
568
|
await this.debugLog(`Fan On: ${this.On}`);
|
|
569
569
|
}
|
|
570
|
-
else if (this.otherDeviceType === '
|
|
570
|
+
else if (this.otherDeviceType === 'Stateful' && this.StatefulProgrammableSwitch) {
|
|
571
571
|
if (this.On === undefined) {
|
|
572
572
|
await this.debugLog(`On: ${this.On}`);
|
|
573
573
|
}
|
|
@@ -585,7 +585,7 @@ export class Others extends irdeviceBase {
|
|
|
585
585
|
}
|
|
586
586
|
await this.debugLog(`StatefulProgrammableSwitch On: ${this.On}`);
|
|
587
587
|
}
|
|
588
|
-
else if (this.otherDeviceType === '
|
|
588
|
+
else if (this.otherDeviceType === 'Outlet' && this.Outlet) {
|
|
589
589
|
if (this.On === undefined) {
|
|
590
590
|
await this.debugLog(`On: ${this.On}`);
|
|
591
591
|
}
|
|
@@ -599,57 +599,57 @@ export class Others extends irdeviceBase {
|
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
601
|
async apiError(e) {
|
|
602
|
-
if (this.otherDeviceType === '
|
|
602
|
+
if (this.otherDeviceType === 'GarageDoor') {
|
|
603
603
|
if (this.GarageDoor) {
|
|
604
604
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e);
|
|
605
605
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e);
|
|
606
606
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
else if (this.otherDeviceType === '
|
|
609
|
+
else if (this.otherDeviceType === 'Door') {
|
|
610
610
|
if (this.Door) {
|
|
611
611
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
612
612
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
613
613
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
|
-
else if (this.otherDeviceType === '
|
|
616
|
+
else if (this.otherDeviceType === 'Window') {
|
|
617
617
|
if (this.Window) {
|
|
618
618
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
619
619
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
620
620
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
|
-
else if (this.otherDeviceType === '
|
|
623
|
+
else if (this.otherDeviceType === 'WindowCovering') {
|
|
624
624
|
if (this.WindowCovering) {
|
|
625
625
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
626
626
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
627
627
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
|
-
else if (this.otherDeviceType === '
|
|
630
|
+
else if (this.otherDeviceType === 'Lock') {
|
|
631
631
|
if (this.LockMechanism) {
|
|
632
632
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, e);
|
|
633
633
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e);
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
-
else if (this.otherDeviceType === '
|
|
636
|
+
else if (this.otherDeviceType === 'Faucet') {
|
|
637
637
|
if (this.Faucet) {
|
|
638
638
|
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
|
-
else if (this.otherDeviceType === '
|
|
641
|
+
else if (this.otherDeviceType === 'Fan') {
|
|
642
642
|
if (this.Fan) {
|
|
643
643
|
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
644
644
|
}
|
|
645
645
|
}
|
|
646
|
-
else if (this.otherDeviceType === '
|
|
646
|
+
else if (this.otherDeviceType === 'Stateful') {
|
|
647
647
|
if (this.StatefulProgrammableSwitch) {
|
|
648
648
|
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
649
649
|
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
|
-
else if (this.otherDeviceType === '
|
|
652
|
+
else if (this.otherDeviceType === 'Switch') {
|
|
653
653
|
if (this.Switch) {
|
|
654
654
|
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
655
655
|
}
|
|
@@ -771,7 +771,7 @@ export class Others extends irdeviceBase {
|
|
|
771
771
|
accessory.removeService(this.Switch.Service);
|
|
772
772
|
}
|
|
773
773
|
async getOtherConfigSettings(accessory, device) {
|
|
774
|
-
this.otherDeviceType = device.type ?? '
|
|
774
|
+
this.otherDeviceType = device.type ?? 'Outlet';
|
|
775
775
|
const deviceType = device.type ? 'Device Config' : 'Default';
|
|
776
776
|
await this.debugLog(`Use ${deviceType} Device Type: ${this.otherDeviceType}`);
|
|
777
777
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@switchbot/homebridge-switchbot",
|
|
3
3
|
"displayName": "SwitchBot",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.1.1-beta.
|
|
5
|
+
"version": "4.1.1-beta.1",
|
|
6
6
|
"description": "The SwitchBot plugin allows you to access your SwitchBot device(s) from HomeKit.",
|
|
7
7
|
"author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
|
|
8
8
|
"contributors": [
|
package/src/device/bot.ts
CHANGED
|
@@ -777,7 +777,7 @@ export class Bot extends deviceBase {
|
|
|
777
777
|
|
|
778
778
|
async getBotConfigSettings(device: device & devicesConfig) {
|
|
779
779
|
// Bot Device Type
|
|
780
|
-
this.botDeviceType = (device as botConfig).type ?? '
|
|
780
|
+
this.botDeviceType = (device as botConfig).type ?? 'Outlet'
|
|
781
781
|
const botDeviceType = (device as botConfig).type ? 'Device Config' : 'Default'
|
|
782
782
|
await this.debugWarnLog(`Use ${botDeviceType} Device Type: ${this.botDeviceType}`)
|
|
783
783
|
// Bot Mode
|
package/src/irdevice/other.ts
CHANGED
|
@@ -83,7 +83,7 @@ export class Others extends irdeviceBase {
|
|
|
83
83
|
this.getOtherConfigSettings(accessory, device)
|
|
84
84
|
|
|
85
85
|
// deviceType
|
|
86
|
-
if (this.otherDeviceType === '
|
|
86
|
+
if (this.otherDeviceType === 'Switch') {
|
|
87
87
|
// Set category
|
|
88
88
|
accessory.category = this.hap.Categories.SWITCH
|
|
89
89
|
// Initialize Switch Service
|
|
@@ -106,7 +106,7 @@ export class Others extends irdeviceBase {
|
|
|
106
106
|
this.removeGarageDoorService(accessory)
|
|
107
107
|
this.removeWindowCoveringService(accessory)
|
|
108
108
|
this.removeStatefulProgrammableSwitchService(accessory)
|
|
109
|
-
} else if (this.otherDeviceType === '
|
|
109
|
+
} else if (this.otherDeviceType === 'GarageDoor') {
|
|
110
110
|
// Set category
|
|
111
111
|
accessory.category = this.hap.Categories.GARAGE_DOOR_OPENER
|
|
112
112
|
// Initialize GarageDoor Service
|
|
@@ -134,7 +134,7 @@ export class Others extends irdeviceBase {
|
|
|
134
134
|
this.removeWindowService(accessory)
|
|
135
135
|
this.removeWindowCoveringService(accessory)
|
|
136
136
|
this.removeStatefulProgrammableSwitchService(accessory)
|
|
137
|
-
} else if (this.otherDeviceType === '
|
|
137
|
+
} else if (this.otherDeviceType === 'Door') {
|
|
138
138
|
// Set category
|
|
139
139
|
accessory.category = this.hap.Categories.DOOR
|
|
140
140
|
// Initialize Door Service
|
|
@@ -162,7 +162,7 @@ export class Others extends irdeviceBase {
|
|
|
162
162
|
this.removeGarageDoorService(accessory)
|
|
163
163
|
this.removeWindowCoveringService(accessory)
|
|
164
164
|
this.removeStatefulProgrammableSwitchService(accessory)
|
|
165
|
-
} else if (this.otherDeviceType === '
|
|
165
|
+
} else if (this.otherDeviceType === 'Window') {
|
|
166
166
|
// Set category
|
|
167
167
|
accessory.category = this.hap.Categories.WINDOW
|
|
168
168
|
// Initialize Window Service
|
|
@@ -190,7 +190,7 @@ export class Others extends irdeviceBase {
|
|
|
190
190
|
this.removeGarageDoorService(accessory)
|
|
191
191
|
this.removeWindowCoveringService(accessory)
|
|
192
192
|
this.removeStatefulProgrammableSwitchService(accessory)
|
|
193
|
-
} else if (this.otherDeviceType === '
|
|
193
|
+
} else if (this.otherDeviceType === 'WindowCovering') {
|
|
194
194
|
// Set category
|
|
195
195
|
accessory.category = this.hap.Categories.WINDOW_COVERING
|
|
196
196
|
// Initialize WindowCovering Service
|
|
@@ -218,7 +218,7 @@ export class Others extends irdeviceBase {
|
|
|
218
218
|
this.removeWindowService(accessory)
|
|
219
219
|
this.removeGarageDoorService(accessory)
|
|
220
220
|
this.removeStatefulProgrammableSwitchService(accessory)
|
|
221
|
-
} else if (this.otherDeviceType === '
|
|
221
|
+
} else if (this.otherDeviceType === 'Lock') {
|
|
222
222
|
// Set category
|
|
223
223
|
accessory.category = this.hap.Categories.DOOR_LOCK
|
|
224
224
|
// Initialize Lock Service
|
|
@@ -241,7 +241,7 @@ export class Others extends irdeviceBase {
|
|
|
241
241
|
this.removeGarageDoorService(accessory)
|
|
242
242
|
this.removeWindowCoveringService(accessory)
|
|
243
243
|
this.removeStatefulProgrammableSwitchService(accessory)
|
|
244
|
-
} else if (this.otherDeviceType === '
|
|
244
|
+
} else if (this.otherDeviceType === 'Faucet') {
|
|
245
245
|
// Set category
|
|
246
246
|
accessory.category = this.hap.Categories.FAUCET
|
|
247
247
|
// Initialize Faucet Service
|
|
@@ -264,7 +264,7 @@ export class Others extends irdeviceBase {
|
|
|
264
264
|
this.removeGarageDoorService(accessory)
|
|
265
265
|
this.removeWindowCoveringService(accessory)
|
|
266
266
|
this.removeStatefulProgrammableSwitchService(accessory)
|
|
267
|
-
} else if (this.otherDeviceType === '
|
|
267
|
+
} else if (this.otherDeviceType === 'Fan') {
|
|
268
268
|
// Set category
|
|
269
269
|
accessory.category = this.hap.Categories.FAN
|
|
270
270
|
// Initialize Fan Service
|
|
@@ -287,7 +287,7 @@ export class Others extends irdeviceBase {
|
|
|
287
287
|
this.removeGarageDoorService(accessory)
|
|
288
288
|
this.removeWindowCoveringService(accessory)
|
|
289
289
|
this.removeStatefulProgrammableSwitchService(accessory)
|
|
290
|
-
} else if (this.otherDeviceType === '
|
|
290
|
+
} else if (this.otherDeviceType === 'Stateful') {
|
|
291
291
|
// Set category
|
|
292
292
|
accessory.category = this.hap.Categories.PROGRAMMABLE_SWITCH
|
|
293
293
|
// Initialize StatefulProgrammableSwitch Service
|
|
@@ -310,7 +310,7 @@ export class Others extends irdeviceBase {
|
|
|
310
310
|
this.removeWindowService(accessory)
|
|
311
311
|
this.removeGarageDoorService(accessory)
|
|
312
312
|
this.removeWindowCoveringService(accessory)
|
|
313
|
-
} else if (this.otherDeviceType === '
|
|
313
|
+
} else if (this.otherDeviceType === 'Outlet') {
|
|
314
314
|
// Set category
|
|
315
315
|
accessory.category = this.hap.Categories.OUTLET
|
|
316
316
|
// Initialize Switch property
|
|
@@ -342,42 +342,42 @@ export class Others extends irdeviceBase {
|
|
|
342
342
|
* Handle requests to set the "On" characteristic
|
|
343
343
|
*/
|
|
344
344
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
345
|
-
if (this.otherDeviceType === '
|
|
345
|
+
if (this.otherDeviceType === 'Switch') {
|
|
346
346
|
if (this.Switch) {
|
|
347
347
|
await this.debugLog(`Set On: ${value}`)
|
|
348
348
|
this.On = value !== false
|
|
349
349
|
}
|
|
350
|
-
} else if (this.otherDeviceType === '
|
|
350
|
+
} else if (this.otherDeviceType === 'GarageDoor') {
|
|
351
351
|
if (this.GarageDoor) {
|
|
352
352
|
await this.debugLog(`Set TargetDoorState: ${value}`)
|
|
353
353
|
this.On = value !== this.hap.Characteristic.TargetDoorState.CLOSED
|
|
354
354
|
}
|
|
355
|
-
} else if (this.otherDeviceType === '
|
|
355
|
+
} else if (this.otherDeviceType === 'Door') {
|
|
356
356
|
if (this.Door) {
|
|
357
357
|
await this.debugLog(`Set TargetPosition: ${value}`)
|
|
358
358
|
this.On = value !== 0
|
|
359
359
|
}
|
|
360
|
-
} else if (this.otherDeviceType === '
|
|
360
|
+
} else if (this.otherDeviceType === 'Window') {
|
|
361
361
|
if (this.Window) {
|
|
362
362
|
await this.debugLog(`Set TargetPosition: ${value}`)
|
|
363
363
|
this.On = value !== 0
|
|
364
364
|
}
|
|
365
|
-
} else if (this.otherDeviceType === '
|
|
365
|
+
} else if (this.otherDeviceType === 'WindowCovering') {
|
|
366
366
|
if (this.WindowCovering) {
|
|
367
367
|
await this.debugLog(`Set TargetPosition: ${value}`)
|
|
368
368
|
this.On = value !== 0
|
|
369
369
|
}
|
|
370
|
-
} else if (this.otherDeviceType === '
|
|
370
|
+
} else if (this.otherDeviceType === 'Lock') {
|
|
371
371
|
if (this.LockMechanism) {
|
|
372
372
|
await this.debugLog(`Set LockTargetState: ${value}`)
|
|
373
373
|
this.On = value !== this.hap.Characteristic.LockTargetState.SECURED
|
|
374
374
|
}
|
|
375
|
-
} else if (this.otherDeviceType === '
|
|
375
|
+
} else if (this.otherDeviceType === 'Faucet') {
|
|
376
376
|
if (this.Faucet) {
|
|
377
377
|
await this.debugLog(`Set Active: ${value}`)
|
|
378
378
|
this.On = value !== this.hap.Characteristic.Active.INACTIVE
|
|
379
379
|
}
|
|
380
|
-
} else if (this.otherDeviceType === '
|
|
380
|
+
} else if (this.otherDeviceType === 'Stateful') {
|
|
381
381
|
if (this.StatefulProgrammableSwitch) {
|
|
382
382
|
await this.debugLog(`Set ProgrammableSwitchOutputState: ${value}`)
|
|
383
383
|
this.On = value !== 0
|
|
@@ -468,14 +468,14 @@ export class Others extends irdeviceBase {
|
|
|
468
468
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
469
469
|
await this.debugLog('updateHomeKitCharacteristics')
|
|
470
470
|
// State
|
|
471
|
-
if (this.otherDeviceType === '
|
|
471
|
+
if (this.otherDeviceType === 'Switch' && this.Switch) {
|
|
472
472
|
if (this.On === undefined) {
|
|
473
473
|
await this.debugLog(`On: ${this.On}`)
|
|
474
474
|
} else {
|
|
475
475
|
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.On)
|
|
476
476
|
await this.debugLog(`updateCharacteristic On: ${this.On}`)
|
|
477
477
|
}
|
|
478
|
-
} else if (this.otherDeviceType === '
|
|
478
|
+
} else if (this.otherDeviceType === 'GarageDoor' && this.GarageDoor) {
|
|
479
479
|
if (this.On === undefined) {
|
|
480
480
|
await this.debugLog(`On: ${this.On}`)
|
|
481
481
|
} else {
|
|
@@ -490,7 +490,7 @@ export class Others extends irdeviceBase {
|
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
492
|
await this.debugLog(`Garage Door On: ${this.On}`)
|
|
493
|
-
} else if (this.otherDeviceType === '
|
|
493
|
+
} else if (this.otherDeviceType === 'Door' && this.Door) {
|
|
494
494
|
if (this.On === undefined) {
|
|
495
495
|
await this.debugLog(`On: ${this.On}`)
|
|
496
496
|
} else {
|
|
@@ -507,7 +507,7 @@ export class Others extends irdeviceBase {
|
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
await this.debugLog(`Door On: ${this.On}`)
|
|
510
|
-
} else if (this.otherDeviceType === '
|
|
510
|
+
} else if (this.otherDeviceType === 'Window' && this.Window) {
|
|
511
511
|
if (this.On === undefined) {
|
|
512
512
|
await this.debugLog(`On: ${this.On}`)
|
|
513
513
|
} else {
|
|
@@ -524,7 +524,7 @@ export class Others extends irdeviceBase {
|
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
526
|
await this.debugLog(`Window On: ${this.On}`)
|
|
527
|
-
} else if (this.otherDeviceType === '
|
|
527
|
+
} else if (this.otherDeviceType === 'WindowCovering' && this.WindowCovering) {
|
|
528
528
|
if (this.On === undefined) {
|
|
529
529
|
await this.debugLog(`On: ${this.On}`)
|
|
530
530
|
} else {
|
|
@@ -541,7 +541,7 @@ export class Others extends irdeviceBase {
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
await this.debugLog(`Window Covering On: ${this.On}`)
|
|
544
|
-
} else if (this.otherDeviceType === '
|
|
544
|
+
} else if (this.otherDeviceType === 'Lock' && this.LockMechanism) {
|
|
545
545
|
if (this.On === undefined) {
|
|
546
546
|
await this.debugLog(`On: ${this.On}`)
|
|
547
547
|
} else {
|
|
@@ -556,7 +556,7 @@ export class Others extends irdeviceBase {
|
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
558
|
await this.debugLog(`Lock On: ${this.On}`)
|
|
559
|
-
} else if (this.otherDeviceType === '
|
|
559
|
+
} else if (this.otherDeviceType === 'Faucet' && this.Faucet) {
|
|
560
560
|
if (this.On === undefined) {
|
|
561
561
|
await this.debugLog(`On: ${this.On}`)
|
|
562
562
|
} else {
|
|
@@ -569,7 +569,7 @@ export class Others extends irdeviceBase {
|
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
571
|
await this.debugLog(`Faucet On: ${this.On}`)
|
|
572
|
-
} else if (this.otherDeviceType === '
|
|
572
|
+
} else if (this.otherDeviceType === 'Fan' && this.Fan) {
|
|
573
573
|
if (this.On === undefined) {
|
|
574
574
|
await this.debugLog(`On: ${this.On}`)
|
|
575
575
|
} else {
|
|
@@ -582,7 +582,7 @@ export class Others extends irdeviceBase {
|
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
584
|
await this.debugLog(`Fan On: ${this.On}`)
|
|
585
|
-
} else if (this.otherDeviceType === '
|
|
585
|
+
} else if (this.otherDeviceType === 'Stateful' && this.StatefulProgrammableSwitch) {
|
|
586
586
|
if (this.On === undefined) {
|
|
587
587
|
await this.debugLog(`On: ${this.On}`)
|
|
588
588
|
} else {
|
|
@@ -597,7 +597,7 @@ export class Others extends irdeviceBase {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
await this.debugLog(`StatefulProgrammableSwitch On: ${this.On}`)
|
|
600
|
-
} else if (this.otherDeviceType === '
|
|
600
|
+
} else if (this.otherDeviceType === 'Outlet' && this.Outlet) {
|
|
601
601
|
if (this.On === undefined) {
|
|
602
602
|
await this.debugLog(`On: ${this.On}`)
|
|
603
603
|
} else {
|
|
@@ -610,49 +610,49 @@ export class Others extends irdeviceBase {
|
|
|
610
610
|
}
|
|
611
611
|
|
|
612
612
|
async apiError(e: any): Promise<void> {
|
|
613
|
-
if (this.otherDeviceType === '
|
|
613
|
+
if (this.otherDeviceType === 'GarageDoor') {
|
|
614
614
|
if (this.GarageDoor) {
|
|
615
615
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e)
|
|
616
616
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e)
|
|
617
617
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e)
|
|
618
618
|
}
|
|
619
|
-
} else if (this.otherDeviceType === '
|
|
619
|
+
} else if (this.otherDeviceType === 'Door') {
|
|
620
620
|
if (this.Door) {
|
|
621
621
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e)
|
|
622
622
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e)
|
|
623
623
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e)
|
|
624
624
|
}
|
|
625
|
-
} else if (this.otherDeviceType === '
|
|
625
|
+
} else if (this.otherDeviceType === 'Window') {
|
|
626
626
|
if (this.Window) {
|
|
627
627
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e)
|
|
628
628
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e)
|
|
629
629
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e)
|
|
630
630
|
}
|
|
631
|
-
} else if (this.otherDeviceType === '
|
|
631
|
+
} else if (this.otherDeviceType === 'WindowCovering') {
|
|
632
632
|
if (this.WindowCovering) {
|
|
633
633
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e)
|
|
634
634
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e)
|
|
635
635
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e)
|
|
636
636
|
}
|
|
637
|
-
} else if (this.otherDeviceType === '
|
|
637
|
+
} else if (this.otherDeviceType === 'Lock') {
|
|
638
638
|
if (this.LockMechanism) {
|
|
639
639
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, e)
|
|
640
640
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e)
|
|
641
641
|
}
|
|
642
|
-
} else if (this.otherDeviceType === '
|
|
642
|
+
} else if (this.otherDeviceType === 'Faucet') {
|
|
643
643
|
if (this.Faucet) {
|
|
644
644
|
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, e)
|
|
645
645
|
}
|
|
646
|
-
} else if (this.otherDeviceType === '
|
|
646
|
+
} else if (this.otherDeviceType === 'Fan') {
|
|
647
647
|
if (this.Fan) {
|
|
648
648
|
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, e)
|
|
649
649
|
}
|
|
650
|
-
} else if (this.otherDeviceType === '
|
|
650
|
+
} else if (this.otherDeviceType === 'Stateful') {
|
|
651
651
|
if (this.StatefulProgrammableSwitch) {
|
|
652
652
|
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e)
|
|
653
653
|
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e)
|
|
654
654
|
}
|
|
655
|
-
} else if (this.otherDeviceType === '
|
|
655
|
+
} else if (this.otherDeviceType === 'Switch') {
|
|
656
656
|
if (this.Switch) {
|
|
657
657
|
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e)
|
|
658
658
|
}
|
|
@@ -784,7 +784,7 @@ export class Others extends irdeviceBase {
|
|
|
784
784
|
}
|
|
785
785
|
|
|
786
786
|
async getOtherConfigSettings(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): Promise<void> {
|
|
787
|
-
this.otherDeviceType = (device as irOtherConfig).type ?? '
|
|
787
|
+
this.otherDeviceType = (device as irOtherConfig).type ?? 'Outlet'
|
|
788
788
|
const deviceType = (device as irOtherConfig).type ? 'Device Config' : 'Default'
|
|
789
789
|
await this.debugLog(`Use ${deviceType} Device Type: ${this.otherDeviceType}`)
|
|
790
790
|
}
|