@switchbot/homebridge-switchbot 3.5.0-beta.3 → 3.5.0-beta.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -1
- package/config.schema.json +147 -9
- package/dist/device/blindtilt.d.ts +21 -94
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +347 -756
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +25 -71
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +582 -759
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +13 -67
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +209 -587
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +13 -74
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +250 -632
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +14 -65
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +204 -531
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +17 -86
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +335 -786
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +59 -0
- package/dist/device/device.d.ts.map +1 -0
- package/dist/device/device.js +654 -0
- package/dist/device/device.js.map +1 -0
- package/dist/device/fan.d.ts +51 -0
- package/dist/device/fan.d.ts.map +1 -0
- package/dist/device/fan.js +499 -0
- package/dist/device/fan.js.map +1 -0
- package/dist/device/hub.d.ts +15 -59
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +242 -596
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +10 -65
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +207 -571
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +11 -64
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +174 -584
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -68
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +252 -568
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +15 -62
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +210 -542
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +13 -63
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +170 -577
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +13 -64
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +159 -577
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +13 -69
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +136 -518
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -57
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +82 -452
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +11 -62
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +140 -451
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +9 -70
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +121 -664
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/irdevice/airconditioner.d.ts +8 -48
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +309 -419
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +7 -38
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +72 -304
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +6 -35
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +34 -278
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +6 -39
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +67 -311
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +40 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -0
- package/dist/irdevice/irdevice.js +509 -0
- package/dist/irdevice/irdevice.js.map +1 -0
- package/dist/irdevice/light.d.ts +6 -34
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +23 -272
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +18 -47
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +352 -546
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +7 -39
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +82 -321
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +6 -35
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +41 -284
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +6 -35
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +42 -287
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +14 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +237 -94
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +40 -10
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +0 -552
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +77 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +638 -1
- package/dist/utils.js.map +1 -1
- package/package.json +16 -15
- package/src/custom.d.ts +2 -1
- package/src/device/blindtilt.ts +373 -782
- package/src/device/bot.ts +616 -844
- package/src/device/ceilinglight.ts +222 -607
- package/src/device/colorbulb.ts +264 -656
- package/src/device/contact.ts +229 -553
- package/src/device/curtain.ts +355 -810
- package/src/device/device.ts +681 -0
- package/src/device/fan.ts +548 -0
- package/src/device/hub.ts +268 -623
- package/src/device/humidifier.ts +237 -618
- package/src/device/iosensor.ts +200 -610
- package/src/device/lightstrip.ts +273 -596
- package/src/device/lock.ts +247 -582
- package/src/device/meter.ts +196 -601
- package/src/device/meterplus.ts +184 -602
- package/src/device/motion.ts +156 -541
- package/src/device/plug.ts +92 -480
- package/src/device/robotvacuumcleaner.ts +161 -477
- package/src/device/waterdetector.ts +139 -689
- package/src/index.ts +1 -1
- package/src/irdevice/airconditioner.ts +330 -446
- package/src/irdevice/airpurifier.ts +89 -321
- package/src/irdevice/camera.ts +42 -293
- package/src/irdevice/fan.ts +78 -327
- package/src/irdevice/irdevice.ts +526 -0
- package/src/irdevice/light.ts +32 -287
- package/src/irdevice/other.ts +396 -615
- package/src/irdevice/tv.ts +100 -339
- package/src/irdevice/vacuumcleaner.ts +49 -305
- package/src/irdevice/waterheater.ts +50 -310
- package/src/platform.ts +247 -102
- package/src/settings.ts +56 -565
- package/src/utils.ts +642 -1
package/dist/irdevice/other.js
CHANGED
|
@@ -1,61 +1,42 @@
|
|
|
1
|
+
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* other.ts: @switchbot/homebridge-switchbot.
|
|
4
|
+
*/
|
|
1
5
|
import { request } from 'undici';
|
|
6
|
+
import { irdeviceBase } from './irdevice.js';
|
|
2
7
|
import { Devices } from '../settings.js';
|
|
3
8
|
/**
|
|
4
9
|
* Platform Accessory
|
|
5
10
|
* An instance of this class is created for each accessory your platform registers
|
|
6
11
|
* Each accessory may expose multiple services of different service types.
|
|
7
12
|
*/
|
|
8
|
-
export class Others {
|
|
13
|
+
export class Others extends irdeviceBase {
|
|
9
14
|
platform;
|
|
10
|
-
accessory;
|
|
11
|
-
device;
|
|
12
|
-
api;
|
|
13
|
-
log;
|
|
14
|
-
config;
|
|
15
|
-
hap;
|
|
16
15
|
// Services
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// Characteristic Values
|
|
28
|
-
On;
|
|
29
|
-
FirmwareRevision;
|
|
16
|
+
Switch;
|
|
17
|
+
GarageDoor;
|
|
18
|
+
Door;
|
|
19
|
+
Window;
|
|
20
|
+
WindowCovering;
|
|
21
|
+
Lock;
|
|
22
|
+
Faucet;
|
|
23
|
+
Fan;
|
|
24
|
+
StatefulProgrammableSwitch;
|
|
25
|
+
Outlet;
|
|
30
26
|
// Config
|
|
31
|
-
deviceLogging;
|
|
32
|
-
disablePushOn;
|
|
33
27
|
otherDeviceType;
|
|
34
|
-
disablePushOff;
|
|
35
28
|
constructor(platform, accessory, device) {
|
|
29
|
+
super(platform, accessory, device);
|
|
36
30
|
this.platform = platform;
|
|
37
|
-
this.accessory = accessory;
|
|
38
|
-
this.device = device;
|
|
39
|
-
this.api = this.platform.api;
|
|
40
|
-
this.log = this.platform.log;
|
|
41
|
-
this.config = this.platform.config;
|
|
42
|
-
this.hap = this.api.hap;
|
|
43
31
|
// default placeholders
|
|
44
|
-
this.
|
|
45
|
-
this.deviceType(device);
|
|
46
|
-
this.deviceContext();
|
|
47
|
-
this.disablePushOnChanges(device);
|
|
48
|
-
this.disablePushOffChanges(device);
|
|
49
|
-
this.deviceConfig(device);
|
|
50
|
-
// set accessory information
|
|
51
|
-
accessory
|
|
52
|
-
.getService(this.hap.Service.AccessoryInformation)
|
|
53
|
-
.setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
|
|
54
|
-
.setCharacteristic(this.hap.Characteristic.Model, device.remoteType)
|
|
55
|
-
.setCharacteristic(this.hap.Characteristic.SerialNumber, device.deviceId)
|
|
56
|
-
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
32
|
+
this.getOtherConfigSettings(device);
|
|
57
33
|
// deviceType
|
|
58
34
|
if (this.otherDeviceType === 'switch') {
|
|
35
|
+
// Initialize Switch property
|
|
36
|
+
this.Switch = {
|
|
37
|
+
Service: accessory.getService(this.hap.Service.Switch),
|
|
38
|
+
On: accessory.context.On || false,
|
|
39
|
+
};
|
|
59
40
|
this.removeFanService(accessory);
|
|
60
41
|
this.removeLockService(accessory);
|
|
61
42
|
this.removeDoorService(accessory);
|
|
@@ -65,18 +46,20 @@ export class Others {
|
|
|
65
46
|
this.removeGarageDoorService(accessory);
|
|
66
47
|
this.removeWindowCoveringService(accessory);
|
|
67
48
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
68
|
-
// Add
|
|
69
|
-
const
|
|
70
|
-
(this.
|
|
71
|
-
|| accessory.addService(this.hap.Service.Switch)),
|
|
49
|
+
// Add Switch Service
|
|
50
|
+
const SwitchService = `${accessory.displayName} Switch`;
|
|
51
|
+
(this.Switch.Service = accessory.getService(this.hap.Service.Switch)
|
|
52
|
+
|| accessory.addService(this.hap.Service.Switch)), SwitchService;
|
|
72
53
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Switch`);
|
|
73
|
-
this.
|
|
74
|
-
|
|
75
|
-
this.switchService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
76
|
-
}
|
|
77
|
-
this.switchService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
54
|
+
this.Switch.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
55
|
+
this.Switch.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
78
56
|
}
|
|
79
57
|
else if (this.otherDeviceType === 'garagedoor') {
|
|
58
|
+
// Initialize Garage Door property
|
|
59
|
+
this.GarageDoor = {
|
|
60
|
+
Service: accessory.getService(this.hap.Service.GarageDoorOpener),
|
|
61
|
+
On: accessory.context.On || false,
|
|
62
|
+
};
|
|
80
63
|
this.removeFanService(accessory);
|
|
81
64
|
this.removeLockService(accessory);
|
|
82
65
|
this.removeDoorService(accessory);
|
|
@@ -86,19 +69,21 @@ export class Others {
|
|
|
86
69
|
this.removeWindowService(accessory);
|
|
87
70
|
this.removeWindowCoveringService(accessory);
|
|
88
71
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
89
|
-
// Add
|
|
90
|
-
const
|
|
91
|
-
(this.
|
|
92
|
-
|| accessory.addService(this.hap.Service.GarageDoorOpener)),
|
|
72
|
+
// Add GarageDoor Service
|
|
73
|
+
const GarageDoorService = `${accessory.displayName} Garage Door Opener`;
|
|
74
|
+
(this.GarageDoor.Service = accessory.getService(this.hap.Service.GarageDoorOpener)
|
|
75
|
+
|| accessory.addService(this.hap.Service.GarageDoorOpener)), GarageDoorService;
|
|
93
76
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
94
|
-
this.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
this.garageDoorService.getCharacteristic(this.hap.Characteristic.TargetDoorState).onSet(this.OnSet.bind(this));
|
|
99
|
-
this.garageDoorService.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false);
|
|
77
|
+
this.GarageDoor.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
78
|
+
this.GarageDoor.Service.getCharacteristic(this.hap.Characteristic.TargetDoorState).onSet(this.OnSet.bind(this));
|
|
79
|
+
this.GarageDoor.Service.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false);
|
|
100
80
|
}
|
|
101
81
|
else if (this.otherDeviceType === 'door') {
|
|
82
|
+
// Initialize Door property
|
|
83
|
+
this.Door = {
|
|
84
|
+
Service: accessory.getService(this.hap.Service.Door),
|
|
85
|
+
On: accessory.context.On || false,
|
|
86
|
+
};
|
|
102
87
|
this.removeFanService(accessory);
|
|
103
88
|
this.removeLockService(accessory);
|
|
104
89
|
this.removeOutletService(accessory);
|
|
@@ -108,16 +93,13 @@ export class Others {
|
|
|
108
93
|
this.removeGarageDoorService(accessory);
|
|
109
94
|
this.removeWindowCoveringService(accessory);
|
|
110
95
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
111
|
-
// Add
|
|
112
|
-
const
|
|
113
|
-
(this.
|
|
114
|
-
|| accessory.addService(this.hap.Service.Door)),
|
|
96
|
+
// Add Door Service
|
|
97
|
+
const DoorService = `${accessory.displayName} Door`;
|
|
98
|
+
(this.Door.Service = accessory.getService(this.hap.Service.Door)
|
|
99
|
+
|| accessory.addService(this.hap.Service.Door)), DoorService;
|
|
115
100
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Door`);
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
this.doorService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
119
|
-
}
|
|
120
|
-
this.doorService
|
|
101
|
+
this.Door.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
102
|
+
this.Door.Service
|
|
121
103
|
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
122
104
|
.setProps({
|
|
123
105
|
validValues: [0, 100],
|
|
@@ -126,9 +108,14 @@ export class Others {
|
|
|
126
108
|
minStep: 100,
|
|
127
109
|
})
|
|
128
110
|
.onSet(this.OnSet.bind(this));
|
|
129
|
-
this.
|
|
111
|
+
this.Door.Service.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
130
112
|
}
|
|
131
113
|
else if (this.otherDeviceType === 'window') {
|
|
114
|
+
// Initialize Window property
|
|
115
|
+
this.Window = {
|
|
116
|
+
Service: accessory.getService(this.hap.Service.Window),
|
|
117
|
+
On: accessory.context.On || false,
|
|
118
|
+
};
|
|
132
119
|
this.removeFanService(accessory);
|
|
133
120
|
this.removeLockService(accessory);
|
|
134
121
|
this.removeDoorService(accessory);
|
|
@@ -138,16 +125,13 @@ export class Others {
|
|
|
138
125
|
this.removeGarageDoorService(accessory);
|
|
139
126
|
this.removeWindowCoveringService(accessory);
|
|
140
127
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
141
|
-
// Add
|
|
142
|
-
const
|
|
143
|
-
(this.
|
|
144
|
-
|| accessory.addService(this.hap.Service.Window)),
|
|
128
|
+
// Add Window Service
|
|
129
|
+
const WindowService = `${accessory.displayName} Window`;
|
|
130
|
+
(this.Window.Service = accessory.getService(this.hap.Service.Window)
|
|
131
|
+
|| accessory.addService(this.hap.Service.Window)), WindowService;
|
|
145
132
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window`);
|
|
146
|
-
this.
|
|
147
|
-
|
|
148
|
-
this.windowService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
149
|
-
}
|
|
150
|
-
this.windowService
|
|
133
|
+
this.Window.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
134
|
+
this.Window.Service
|
|
151
135
|
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
152
136
|
.setProps({
|
|
153
137
|
validValues: [0, 100],
|
|
@@ -156,9 +140,14 @@ export class Others {
|
|
|
156
140
|
minStep: 100,
|
|
157
141
|
})
|
|
158
142
|
.onSet(this.OnSet.bind(this));
|
|
159
|
-
this.
|
|
143
|
+
this.Window.Service.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
160
144
|
}
|
|
161
145
|
else if (this.otherDeviceType === 'windowcovering') {
|
|
146
|
+
// Initialize WindowCovering property
|
|
147
|
+
this.WindowCovering = {
|
|
148
|
+
Service: accessory.getService(this.hap.Service.WindowCovering),
|
|
149
|
+
On: accessory.context.On || false,
|
|
150
|
+
};
|
|
162
151
|
this.removeFanService(accessory);
|
|
163
152
|
this.removeLockService(accessory);
|
|
164
153
|
this.removeDoorService(accessory);
|
|
@@ -168,16 +157,13 @@ export class Others {
|
|
|
168
157
|
this.removeWindowService(accessory);
|
|
169
158
|
this.removeGarageDoorService(accessory);
|
|
170
159
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
171
|
-
// Add
|
|
172
|
-
const
|
|
173
|
-
(this.
|
|
174
|
-
|| accessory.addService(this.hap.Service.WindowCovering)),
|
|
160
|
+
// Add WindowCovering Service
|
|
161
|
+
const WindowCoveringService = `${accessory.displayName} Window Covering`;
|
|
162
|
+
(this.WindowCovering.Service = accessory.getService(this.hap.Service.WindowCovering)
|
|
163
|
+
|| accessory.addService(this.hap.Service.WindowCovering)), WindowCoveringService;
|
|
175
164
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
176
|
-
this.
|
|
177
|
-
|
|
178
|
-
this.windowCoveringService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
179
|
-
}
|
|
180
|
-
this.windowCoveringService
|
|
165
|
+
this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
166
|
+
this.WindowCovering.Service
|
|
181
167
|
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
182
168
|
.setProps({
|
|
183
169
|
validValues: [0, 100],
|
|
@@ -186,9 +172,14 @@ export class Others {
|
|
|
186
172
|
minStep: 100,
|
|
187
173
|
})
|
|
188
174
|
.onSet(this.OnSet.bind(this));
|
|
189
|
-
this.
|
|
175
|
+
this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
190
176
|
}
|
|
191
177
|
else if (this.otherDeviceType === 'lock') {
|
|
178
|
+
// Initialize Lock property
|
|
179
|
+
this.Lock = {
|
|
180
|
+
Service: accessory.getService(this.hap.Service.LockMechanism),
|
|
181
|
+
On: accessory.context.On || false,
|
|
182
|
+
};
|
|
192
183
|
this.removeFanService(accessory);
|
|
193
184
|
this.removeDoorService(accessory);
|
|
194
185
|
this.removeOutletService(accessory);
|
|
@@ -198,18 +189,20 @@ export class Others {
|
|
|
198
189
|
this.removeGarageDoorService(accessory);
|
|
199
190
|
this.removeWindowCoveringService(accessory);
|
|
200
191
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
201
|
-
// Add
|
|
202
|
-
const
|
|
203
|
-
(this.
|
|
204
|
-
|| accessory.addService(this.hap.Service.LockMechanism)),
|
|
192
|
+
// Add Lock Service
|
|
193
|
+
const LockService = `${accessory.displayName} Lock`;
|
|
194
|
+
(this.Lock.Service = accessory.getService(this.hap.Service.LockMechanism)
|
|
195
|
+
|| accessory.addService(this.hap.Service.LockMechanism)), LockService;
|
|
205
196
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Lock`);
|
|
206
|
-
this.
|
|
207
|
-
|
|
208
|
-
this.lockService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
209
|
-
}
|
|
210
|
-
this.lockService.getCharacteristic(this.hap.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
|
|
197
|
+
this.Lock.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
198
|
+
this.Lock.Service.getCharacteristic(this.hap.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
|
|
211
199
|
}
|
|
212
200
|
else if (this.otherDeviceType === 'faucet') {
|
|
201
|
+
// Initialize Faucet property
|
|
202
|
+
this.Faucet = {
|
|
203
|
+
Service: accessory.getService(this.hap.Service.Faucet),
|
|
204
|
+
On: accessory.context.On || false,
|
|
205
|
+
};
|
|
213
206
|
this.removeFanService(accessory);
|
|
214
207
|
this.removeLockService(accessory);
|
|
215
208
|
this.removeDoorService(accessory);
|
|
@@ -219,18 +212,20 @@ export class Others {
|
|
|
219
212
|
this.removeGarageDoorService(accessory);
|
|
220
213
|
this.removeWindowCoveringService(accessory);
|
|
221
214
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
222
|
-
// Add
|
|
223
|
-
const
|
|
224
|
-
(this.
|
|
225
|
-
|| accessory.addService(this.hap.Service.Faucet)),
|
|
215
|
+
// Add Faucet Service
|
|
216
|
+
const FaucetService = `${accessory.displayName} Faucet`;
|
|
217
|
+
(this.Faucet.Service = accessory.getService(this.hap.Service.Faucet)
|
|
218
|
+
|| accessory.addService(this.hap.Service.Faucet)), FaucetService;
|
|
226
219
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Faucet`);
|
|
227
|
-
this.
|
|
228
|
-
|
|
229
|
-
this.faucetService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
230
|
-
}
|
|
231
|
-
this.faucetService.getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this));
|
|
220
|
+
this.Faucet.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
221
|
+
this.Faucet.Service.getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this));
|
|
232
222
|
}
|
|
233
223
|
else if (this.otherDeviceType === 'fan') {
|
|
224
|
+
// Initialize Fan property
|
|
225
|
+
this.Fan = {
|
|
226
|
+
Service: accessory.getService(this.hap.Service.Fanv2),
|
|
227
|
+
On: accessory.context.On || false,
|
|
228
|
+
};
|
|
234
229
|
this.removeLockService(accessory);
|
|
235
230
|
this.removeDoorService(accessory);
|
|
236
231
|
this.removeFaucetService(accessory);
|
|
@@ -240,18 +235,20 @@ export class Others {
|
|
|
240
235
|
this.removeGarageDoorService(accessory);
|
|
241
236
|
this.removeWindowCoveringService(accessory);
|
|
242
237
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
243
|
-
// Add
|
|
244
|
-
const
|
|
245
|
-
(this.
|
|
246
|
-
|| accessory.addService(this.hap.Service.
|
|
238
|
+
// Add Fan Service
|
|
239
|
+
const FanService = `${accessory.displayName} Fan`;
|
|
240
|
+
(this.Fan.Service = accessory.getService(this.hap.Service.Fanv2)
|
|
241
|
+
|| accessory.addService(this.hap.Service.Fanv2)), FanService;
|
|
247
242
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Fan`);
|
|
248
|
-
this.
|
|
249
|
-
|
|
250
|
-
this.fanService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
251
|
-
}
|
|
252
|
-
this.fanService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
243
|
+
this.Fan.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
244
|
+
this.Fan.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
253
245
|
}
|
|
254
246
|
else if (this.otherDeviceType === 'stateful') {
|
|
247
|
+
// Initialize StatefulProgrammableSwitch property
|
|
248
|
+
this.StatefulProgrammableSwitch = {
|
|
249
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch),
|
|
250
|
+
On: accessory.context.On || false,
|
|
251
|
+
};
|
|
255
252
|
this.removeFanService(accessory);
|
|
256
253
|
this.removeLockService(accessory);
|
|
257
254
|
this.removeDoorService(accessory);
|
|
@@ -261,20 +258,22 @@ export class Others {
|
|
|
261
258
|
this.removeWindowService(accessory);
|
|
262
259
|
this.removeGarageDoorService(accessory);
|
|
263
260
|
this.removeWindowCoveringService(accessory);
|
|
264
|
-
// Add
|
|
265
|
-
const
|
|
266
|
-
(this.
|
|
267
|
-
|| accessory.addService(this.hap.Service.StatefulProgrammableSwitch)),
|
|
261
|
+
// Add StatefulProgrammableSwitch.Service
|
|
262
|
+
const StatefulProgrammableSwitchService = `${accessory.displayName} Stateful Programmable Switch`;
|
|
263
|
+
(this.StatefulProgrammableSwitch.Service = accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
264
|
+
|| accessory.addService(this.hap.Service.StatefulProgrammableSwitch)), StatefulProgrammableSwitchService;
|
|
268
265
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
269
|
-
this.
|
|
270
|
-
|
|
271
|
-
this.statefulProgrammableSwitchService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
272
|
-
}
|
|
273
|
-
this.statefulProgrammableSwitchService
|
|
266
|
+
this.StatefulProgrammableSwitch.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
267
|
+
this.StatefulProgrammableSwitch.Service
|
|
274
268
|
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
275
269
|
.onSet(this.OnSet.bind(this));
|
|
276
270
|
}
|
|
277
271
|
else {
|
|
272
|
+
// Initialize Outlet property
|
|
273
|
+
this.Outlet = {
|
|
274
|
+
Service: accessory.getService(this.hap.Service.Outlet),
|
|
275
|
+
On: accessory.context.On || false,
|
|
276
|
+
};
|
|
278
277
|
this.removeFanService(accessory);
|
|
279
278
|
this.removeLockService(accessory);
|
|
280
279
|
this.removeDoorService(accessory);
|
|
@@ -284,79 +283,101 @@ export class Others {
|
|
|
284
283
|
this.removeGarageDoorService(accessory);
|
|
285
284
|
this.removeWindowCoveringService(accessory);
|
|
286
285
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
287
|
-
// Add
|
|
288
|
-
const
|
|
289
|
-
(this.
|
|
290
|
-
|| accessory.addService(this.hap.Service.Outlet)),
|
|
286
|
+
// Add Outlet.Service
|
|
287
|
+
const OutletService = `${accessory.displayName} Outlet`;
|
|
288
|
+
(this.Outlet.Service = accessory.getService(this.hap.Service.Outlet)
|
|
289
|
+
|| accessory.addService(this.hap.Service.Outlet)), OutletService;
|
|
291
290
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Outlet`);
|
|
292
|
-
this.
|
|
293
|
-
|
|
294
|
-
this.outletService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
295
|
-
}
|
|
296
|
-
this.outletService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
291
|
+
this.Outlet.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
292
|
+
this.Outlet.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
297
293
|
}
|
|
298
294
|
}
|
|
299
295
|
/**
|
|
300
296
|
* Handle requests to set the "On" characteristic
|
|
301
297
|
*/
|
|
302
298
|
async OnSet(value) {
|
|
299
|
+
let On;
|
|
303
300
|
if (this.otherDeviceType === 'garagedoor') {
|
|
304
301
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetDoorState: ${value}`);
|
|
305
302
|
if (value === this.hap.Characteristic.TargetDoorState.CLOSED) {
|
|
306
|
-
this.On = false;
|
|
303
|
+
this.GarageDoor.On = false;
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
this.GarageDoor.On = true;
|
|
307
|
+
}
|
|
308
|
+
On = this.GarageDoor.On;
|
|
309
|
+
}
|
|
310
|
+
else if (this.otherDeviceType === 'door') {
|
|
311
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
312
|
+
if (value === 0) {
|
|
313
|
+
this.Door.On = false;
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
this.Door.On = true;
|
|
317
|
+
}
|
|
318
|
+
On = this.Door.On;
|
|
319
|
+
}
|
|
320
|
+
else if (this.otherDeviceType === 'window') {
|
|
321
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
322
|
+
if (value === 0) {
|
|
323
|
+
this.Window.On = false;
|
|
307
324
|
}
|
|
308
325
|
else {
|
|
309
|
-
this.On = true;
|
|
326
|
+
this.Window.On = true;
|
|
310
327
|
}
|
|
328
|
+
On = this.Window.On;
|
|
311
329
|
}
|
|
312
|
-
else if (this.otherDeviceType === '
|
|
313
|
-
this.otherDeviceType === 'window' ||
|
|
314
|
-
this.otherDeviceType === 'windowcovering') {
|
|
330
|
+
else if (this.otherDeviceType === 'windowcovering') {
|
|
315
331
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
316
332
|
if (value === 0) {
|
|
317
|
-
this.On = false;
|
|
333
|
+
this.WindowCovering.On = false;
|
|
318
334
|
}
|
|
319
335
|
else {
|
|
320
|
-
this.On = true;
|
|
336
|
+
this.WindowCovering.On = true;
|
|
321
337
|
}
|
|
338
|
+
On = this.WindowCovering.On;
|
|
322
339
|
}
|
|
323
340
|
else if (this.otherDeviceType === 'lock') {
|
|
324
341
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
|
|
325
342
|
if (value === this.hap.Characteristic.LockTargetState.SECURED) {
|
|
326
|
-
this.On = false;
|
|
343
|
+
this.Lock.On = false;
|
|
327
344
|
}
|
|
328
345
|
else {
|
|
329
|
-
this.On = true;
|
|
346
|
+
this.Lock.On = true;
|
|
330
347
|
}
|
|
348
|
+
On = this.Lock.On;
|
|
331
349
|
}
|
|
332
350
|
else if (this.otherDeviceType === 'faucet') {
|
|
333
351
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
334
352
|
if (value === this.hap.Characteristic.Active.INACTIVE) {
|
|
335
|
-
this.On = false;
|
|
353
|
+
this.Faucet.On = false;
|
|
336
354
|
}
|
|
337
355
|
else {
|
|
338
|
-
this.On = true;
|
|
356
|
+
this.Faucet.On = true;
|
|
339
357
|
}
|
|
358
|
+
On = this.Faucet.On;
|
|
340
359
|
}
|
|
341
360
|
else if (this.otherDeviceType === 'stateful') {
|
|
342
361
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set ProgrammableSwitchOutputState: ${value}`);
|
|
343
362
|
if (value === 0) {
|
|
344
|
-
this.On = false;
|
|
363
|
+
this.StatefulProgrammableSwitch.On = false;
|
|
345
364
|
}
|
|
346
365
|
else {
|
|
347
|
-
this.On = true;
|
|
366
|
+
this.StatefulProgrammableSwitch.On = true;
|
|
348
367
|
}
|
|
368
|
+
On = this.StatefulProgrammableSwitch.On;
|
|
349
369
|
}
|
|
350
370
|
else {
|
|
351
371
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set On: ${value}`);
|
|
352
|
-
this.On = value;
|
|
372
|
+
this.Outlet.On = value;
|
|
373
|
+
On = this.Outlet.On ? true : false;
|
|
353
374
|
}
|
|
354
375
|
//pushChanges
|
|
355
|
-
if (
|
|
356
|
-
await this.pushOnChanges();
|
|
376
|
+
if (On === true) {
|
|
377
|
+
await this.pushOnChanges(On);
|
|
357
378
|
}
|
|
358
379
|
else {
|
|
359
|
-
await this.pushOffChanges();
|
|
380
|
+
await this.pushOffChanges(On);
|
|
360
381
|
}
|
|
361
382
|
}
|
|
362
383
|
/**
|
|
@@ -369,11 +390,11 @@ export class Others {
|
|
|
369
390
|
* Other - "command" "channelAdd" "default" = next channel
|
|
370
391
|
* Other - "command" "channelSub" "default" = previous channel
|
|
371
392
|
*/
|
|
372
|
-
async pushOnChanges() {
|
|
373
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${
|
|
374
|
-
` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`);
|
|
393
|
+
async pushOnChanges(On) {
|
|
394
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${On},`
|
|
395
|
+
+ ` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`);
|
|
375
396
|
if (this.device.customize) {
|
|
376
|
-
if (
|
|
397
|
+
if (On === true && !this.disablePushOn) {
|
|
377
398
|
const commandType = await this.commandType();
|
|
378
399
|
const command = await this.commandOn();
|
|
379
400
|
const bodyChange = JSON.stringify({
|
|
@@ -388,11 +409,11 @@ export class Others {
|
|
|
388
409
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set`);
|
|
389
410
|
}
|
|
390
411
|
}
|
|
391
|
-
async pushOffChanges() {
|
|
392
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${
|
|
393
|
-
` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`);
|
|
412
|
+
async pushOffChanges(On) {
|
|
413
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${On},`
|
|
414
|
+
+ ` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`);
|
|
394
415
|
if (this.device.customize) {
|
|
395
|
-
if (
|
|
416
|
+
if (On === false && !this.disablePushOff) {
|
|
396
417
|
const commandType = await this.commandType();
|
|
397
418
|
const command = await this.commandOff();
|
|
398
419
|
const bodyChange = JSON.stringify({
|
|
@@ -422,8 +443,10 @@ export class Others {
|
|
|
422
443
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
423
444
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
424
445
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
425
|
-
this.
|
|
446
|
+
this.debugSuccessLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
426
447
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
448
|
+
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
449
|
+
+ ` request to SwitchBot API, body: ${JSON.stringify(bodyChange)} sent successfully`);
|
|
427
450
|
this.updateHomeKitCharacteristics();
|
|
428
451
|
}
|
|
429
452
|
else {
|
|
@@ -433,425 +456,316 @@ export class Others {
|
|
|
433
456
|
}
|
|
434
457
|
catch (e) {
|
|
435
458
|
this.apiError(e);
|
|
436
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
|
|
437
|
-
` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
459
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
|
|
460
|
+
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
438
461
|
}
|
|
439
462
|
}
|
|
440
463
|
else {
|
|
441
|
-
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
442
|
-
` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
464
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
465
|
+
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
443
466
|
}
|
|
444
467
|
}
|
|
445
468
|
async updateHomeKitCharacteristics() {
|
|
446
469
|
if (this.otherDeviceType === 'garagedoor') {
|
|
447
|
-
if (this.On === undefined) {
|
|
448
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
470
|
+
if (this.GarageDoor.On === undefined) {
|
|
471
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.GarageDoor.On}`);
|
|
449
472
|
}
|
|
450
473
|
else {
|
|
451
|
-
if (this.On) {
|
|
452
|
-
this.
|
|
453
|
-
this.
|
|
454
|
-
this.debugLog(`${this.device.remoteType}:
|
|
474
|
+
if (this.GarageDoor.On) {
|
|
475
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.OPEN);
|
|
476
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.OPEN);
|
|
477
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
478
|
+
+ ` TargetDoorState: Open, CurrentDoorState: Open (${this.GarageDoor.On})`);
|
|
455
479
|
}
|
|
456
480
|
else {
|
|
457
|
-
this.
|
|
458
|
-
this.
|
|
459
|
-
this.debugLog(`${this.device.remoteType}:
|
|
481
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
|
|
482
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
|
|
483
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
484
|
+
+ ` TargetDoorState: Closed, CurrentDoorState: Closed (${this.GarageDoor.On})`);
|
|
460
485
|
}
|
|
461
486
|
}
|
|
462
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Garage Door On: ${this.On}`);
|
|
487
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Garage Door On: ${this.GarageDoor.On}`);
|
|
463
488
|
}
|
|
464
489
|
else if (this.otherDeviceType === 'door') {
|
|
465
|
-
if (this.On === undefined) {
|
|
466
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
490
|
+
if (this.Door.On === undefined) {
|
|
491
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Door.On}`);
|
|
467
492
|
}
|
|
468
493
|
else {
|
|
469
|
-
if (this.On) {
|
|
470
|
-
this.
|
|
471
|
-
this.
|
|
472
|
-
this.
|
|
473
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
494
|
+
if (this.Door.On) {
|
|
495
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
496
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
497
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
498
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
499
|
+
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Door.On})`);
|
|
474
500
|
}
|
|
475
501
|
else {
|
|
476
|
-
this.
|
|
477
|
-
this.
|
|
478
|
-
this.
|
|
479
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
502
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
503
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
504
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
505
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
506
|
+
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Door.On})`);
|
|
480
507
|
}
|
|
481
508
|
}
|
|
482
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Door On: ${this.On}`);
|
|
509
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Door On: ${this.Door.On}`);
|
|
483
510
|
}
|
|
484
511
|
else if (this.otherDeviceType === 'window') {
|
|
485
|
-
if (this.On === undefined) {
|
|
486
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
512
|
+
if (this.Window.On === undefined) {
|
|
513
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Window.On}`);
|
|
487
514
|
}
|
|
488
515
|
else {
|
|
489
|
-
if (this.On) {
|
|
490
|
-
this.
|
|
491
|
-
this.
|
|
492
|
-
this.
|
|
493
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
516
|
+
if (this.Window.On) {
|
|
517
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
518
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
519
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
520
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
521
|
+
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Window.On})`);
|
|
494
522
|
}
|
|
495
523
|
else {
|
|
496
|
-
this.
|
|
497
|
-
this.
|
|
498
|
-
this.
|
|
499
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
524
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
525
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
526
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
527
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
528
|
+
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Window.On})`);
|
|
500
529
|
}
|
|
501
530
|
}
|
|
502
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window On: ${this.On}`);
|
|
531
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window On: ${this.Window.On}`);
|
|
503
532
|
}
|
|
504
533
|
else if (this.otherDeviceType === 'windowcovering') {
|
|
505
|
-
if (this.On === undefined) {
|
|
506
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
534
|
+
if (this.WindowCovering.On === undefined) {
|
|
535
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.WindowCovering.On}`);
|
|
507
536
|
}
|
|
508
537
|
else {
|
|
509
|
-
if (this.On) {
|
|
510
|
-
this.
|
|
511
|
-
this.
|
|
512
|
-
this.
|
|
513
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
538
|
+
if (this.WindowCovering.On) {
|
|
539
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
540
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
541
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
542
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
543
|
+
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.WindowCovering.On})`);
|
|
514
544
|
}
|
|
515
545
|
else {
|
|
516
|
-
this.
|
|
517
|
-
this.
|
|
518
|
-
this.
|
|
519
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
546
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
547
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
548
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
549
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
550
|
+
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.WindowCovering.On})`);
|
|
520
551
|
}
|
|
521
552
|
}
|
|
522
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window Covering On: ${this.On}`);
|
|
553
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window Covering On: ${this.WindowCovering.On}`);
|
|
523
554
|
}
|
|
524
555
|
else if (this.otherDeviceType === 'lock') {
|
|
525
|
-
if (this.On === undefined) {
|
|
526
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
556
|
+
if (this.Lock.On === undefined) {
|
|
557
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Lock.On}`);
|
|
527
558
|
}
|
|
528
559
|
else {
|
|
529
|
-
if (this.On) {
|
|
530
|
-
this.
|
|
531
|
-
this.
|
|
532
|
-
this.debugLog(`${this.device.remoteType}: `
|
|
533
|
-
|
|
560
|
+
if (this.Lock.On) {
|
|
561
|
+
this.Lock.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
|
|
562
|
+
this.Lock.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
|
|
563
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
564
|
+
+ ` LockTargetState: UNSECURED, LockCurrentState: UNSECURE (${this.Lock.On})`);
|
|
534
565
|
}
|
|
535
566
|
else {
|
|
536
|
-
this.
|
|
537
|
-
this.
|
|
538
|
-
this.debugLog(`${this.device.remoteType}:
|
|
567
|
+
this.Lock.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
|
|
568
|
+
this.Lock.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
|
|
569
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
570
|
+
+ ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.Lock.On})`);
|
|
539
571
|
}
|
|
540
572
|
}
|
|
541
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Lock On: ${this.On}`);
|
|
573
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Lock On: ${this.Lock.On}`);
|
|
542
574
|
}
|
|
543
575
|
else if (this.otherDeviceType === 'faucet') {
|
|
544
|
-
if (this.On === undefined) {
|
|
545
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
576
|
+
if (this.Faucet.On === undefined) {
|
|
577
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Faucet.On}`);
|
|
546
578
|
}
|
|
547
579
|
else {
|
|
548
|
-
if (this.On) {
|
|
549
|
-
this.
|
|
550
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
580
|
+
if (this.Faucet.On) {
|
|
581
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
|
|
582
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Faucet.On}`);
|
|
551
583
|
}
|
|
552
584
|
else {
|
|
553
|
-
this.
|
|
554
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
585
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
586
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Faucet.On}`);
|
|
555
587
|
}
|
|
556
588
|
}
|
|
557
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Faucet On: ${this.On}`);
|
|
589
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Faucet On: ${this.Faucet.On}`);
|
|
558
590
|
}
|
|
559
591
|
else if (this.otherDeviceType === 'fan') {
|
|
560
|
-
if (this.On === undefined) {
|
|
561
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
592
|
+
if (this.Fan.On === undefined) {
|
|
593
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Fan.On}`);
|
|
562
594
|
}
|
|
563
595
|
else {
|
|
564
|
-
if (this.On) {
|
|
565
|
-
this.
|
|
566
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
596
|
+
if (this.Fan.On) {
|
|
597
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, this.Fan.On);
|
|
598
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Fan.On}`);
|
|
567
599
|
}
|
|
568
600
|
else {
|
|
569
|
-
this.
|
|
570
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
601
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, this.Fan.On);
|
|
602
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Fan.On}`);
|
|
571
603
|
}
|
|
572
604
|
}
|
|
573
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Fan On: ${this.On}`);
|
|
605
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Fan On: ${this.Fan.On}`);
|
|
574
606
|
}
|
|
575
607
|
else if (this.otherDeviceType === 'stateful') {
|
|
576
|
-
if (this.On === undefined) {
|
|
577
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
608
|
+
if (this.StatefulProgrammableSwitch.On === undefined) {
|
|
609
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.StatefulProgrammableSwitch.On}`);
|
|
578
610
|
}
|
|
579
611
|
else {
|
|
580
|
-
if (this.On) {
|
|
581
|
-
this.
|
|
582
|
-
this.
|
|
583
|
-
this.debugLog(`${this.device.remoteType}: `
|
|
584
|
-
|
|
612
|
+
if (this.StatefulProgrammableSwitch.On) {
|
|
613
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
614
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
615
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
616
|
+
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1 (${this.StatefulProgrammableSwitch.On})`);
|
|
585
617
|
}
|
|
586
618
|
else {
|
|
587
|
-
this.
|
|
588
|
-
this.
|
|
589
|
-
this.debugLog(`${this.device.remoteType}: `
|
|
590
|
-
|
|
619
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
620
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
621
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
622
|
+
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0 (${this.StatefulProgrammableSwitch.On})`);
|
|
591
623
|
}
|
|
592
624
|
}
|
|
593
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
|
|
625
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.StatefulProgrammableSwitch.On}`);
|
|
594
626
|
}
|
|
595
627
|
else if (this.otherDeviceType === 'switch') {
|
|
596
|
-
if (this.On === undefined) {
|
|
597
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
628
|
+
if (this.Switch.On === undefined) {
|
|
629
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Switch.On}`);
|
|
598
630
|
}
|
|
599
631
|
else {
|
|
600
|
-
this.
|
|
601
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
632
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
|
|
633
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Switch.On}`);
|
|
602
634
|
}
|
|
603
635
|
}
|
|
604
636
|
else {
|
|
605
|
-
if (this.On === undefined) {
|
|
606
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
637
|
+
if (this.Outlet.On === undefined) {
|
|
638
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Outlet.On}`);
|
|
607
639
|
}
|
|
608
640
|
else {
|
|
609
|
-
this.
|
|
610
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
641
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.Outlet.On);
|
|
642
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Outlet.On}`);
|
|
611
643
|
}
|
|
612
644
|
}
|
|
613
645
|
}
|
|
614
|
-
async disablePushOnChanges(device) {
|
|
615
|
-
if (device.disablePushOn === undefined) {
|
|
616
|
-
this.disablePushOn = false;
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
this.disablePushOn = device.disablePushOn;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
async disablePushOffChanges(device) {
|
|
623
|
-
if (device.disablePushOff === undefined) {
|
|
624
|
-
this.disablePushOff = false;
|
|
625
|
-
}
|
|
626
|
-
else {
|
|
627
|
-
this.disablePushOff = device.disablePushOff;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
async commandType() {
|
|
631
|
-
let commandType;
|
|
632
|
-
if (this.device.commandType && this.device.customize) {
|
|
633
|
-
commandType = this.device.commandType;
|
|
634
|
-
}
|
|
635
|
-
else if (this.device.customize) {
|
|
636
|
-
commandType = 'customize';
|
|
637
|
-
}
|
|
638
|
-
else {
|
|
639
|
-
commandType = 'command';
|
|
640
|
-
}
|
|
641
|
-
return commandType;
|
|
642
|
-
}
|
|
643
|
-
async commandOn() {
|
|
644
|
-
let command;
|
|
645
|
-
if (this.device.customize && this.device.customOn) {
|
|
646
|
-
command = this.device.customOn;
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
command = 'turnOn';
|
|
650
|
-
}
|
|
651
|
-
return command;
|
|
652
|
-
}
|
|
653
|
-
async commandOff() {
|
|
654
|
-
let command;
|
|
655
|
-
if (this.device.customize && this.device.customOff) {
|
|
656
|
-
command = this.device.customOff;
|
|
657
|
-
}
|
|
658
|
-
else {
|
|
659
|
-
command = 'turnOff';
|
|
660
|
-
}
|
|
661
|
-
return command;
|
|
662
|
-
}
|
|
663
|
-
async statusCode(statusCode) {
|
|
664
|
-
switch (statusCode) {
|
|
665
|
-
case 151:
|
|
666
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this deviceType, statusCode: ${statusCode}`);
|
|
667
|
-
break;
|
|
668
|
-
case 152:
|
|
669
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found, statusCode: ${statusCode}`);
|
|
670
|
-
break;
|
|
671
|
-
case 160:
|
|
672
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported, statusCode: ${statusCode}`);
|
|
673
|
-
break;
|
|
674
|
-
case 161:
|
|
675
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
676
|
-
break;
|
|
677
|
-
case 171:
|
|
678
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
679
|
-
`Hub: ${this.device.hubDeviceId}`);
|
|
680
|
-
break;
|
|
681
|
-
case 190:
|
|
682
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
|
|
683
|
-
` Or command format is invalid, statusCode: ${statusCode}`);
|
|
684
|
-
break;
|
|
685
|
-
case 100:
|
|
686
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent, statusCode: ${statusCode}`);
|
|
687
|
-
break;
|
|
688
|
-
case 200:
|
|
689
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
690
|
-
break;
|
|
691
|
-
case 400:
|
|
692
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Bad Request, The client has issued an invalid request. `
|
|
693
|
-
+ `This is commonly used to specify validation errors in a request payload, statusCode: ${statusCode}`);
|
|
694
|
-
break;
|
|
695
|
-
case 401:
|
|
696
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unauthorized, Authorization for the API is required, `
|
|
697
|
-
+ `but the request has not been authenticated, statusCode: ${statusCode}`);
|
|
698
|
-
break;
|
|
699
|
-
case 403:
|
|
700
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Forbidden, The request has been authenticated but does not `
|
|
701
|
-
+ `have appropriate permissions, or a requested resource is not found, statusCode: ${statusCode}`);
|
|
702
|
-
break;
|
|
703
|
-
case 404:
|
|
704
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Found, Specifies the requested path does not exist, `
|
|
705
|
-
+ `statusCode: ${statusCode}`);
|
|
706
|
-
break;
|
|
707
|
-
case 406:
|
|
708
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Acceptable, The client has requested a MIME type via `
|
|
709
|
-
+ `the Accept header for a value not supported by the server, statusCode: ${statusCode}`);
|
|
710
|
-
break;
|
|
711
|
-
case 415:
|
|
712
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unsupported Media Type, The client has defined a contentType `
|
|
713
|
-
+ `header that is not supported by the server, statusCode: ${statusCode}`);
|
|
714
|
-
break;
|
|
715
|
-
case 422:
|
|
716
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unprocessable Entity, The client has made a valid request, but `
|
|
717
|
-
+ `the server cannot process it. This is often used for APIs for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
718
|
-
break;
|
|
719
|
-
case 429:
|
|
720
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Too Many Requests, The client has exceeded the number of `
|
|
721
|
-
+ `requests allowed for a given time window, statusCode: ${statusCode}`);
|
|
722
|
-
break;
|
|
723
|
-
case 500:
|
|
724
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Internal Server Error, An unexpected error on the SmartThings `
|
|
725
|
-
+ `servers has occurred. These errors should be rare, statusCode: ${statusCode}`);
|
|
726
|
-
break;
|
|
727
|
-
default:
|
|
728
|
-
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
729
|
-
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
646
|
async apiError(e) {
|
|
733
647
|
if (this.otherDeviceType === 'garagedoor') {
|
|
734
|
-
this.
|
|
735
|
-
this.
|
|
736
|
-
this.
|
|
648
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e);
|
|
649
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e);
|
|
650
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e);
|
|
737
651
|
}
|
|
738
652
|
else if (this.otherDeviceType === 'door') {
|
|
739
|
-
this.
|
|
740
|
-
this.
|
|
741
|
-
this.
|
|
653
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
654
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
655
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
742
656
|
}
|
|
743
657
|
else if (this.otherDeviceType === 'window') {
|
|
744
|
-
this.
|
|
745
|
-
this.
|
|
746
|
-
this.
|
|
658
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
659
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
660
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
747
661
|
}
|
|
748
662
|
else if (this.otherDeviceType === 'windowcovering') {
|
|
749
|
-
this.
|
|
750
|
-
this.
|
|
751
|
-
this.
|
|
663
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
664
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
665
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
752
666
|
}
|
|
753
667
|
else if (this.otherDeviceType === 'lock') {
|
|
754
|
-
this.
|
|
755
|
-
this.
|
|
668
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, e);
|
|
669
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e);
|
|
756
670
|
}
|
|
757
671
|
else if (this.otherDeviceType === 'faucet') {
|
|
758
|
-
this.
|
|
672
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
759
673
|
}
|
|
760
674
|
else if (this.otherDeviceType === 'fan') {
|
|
761
|
-
this.
|
|
675
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
762
676
|
}
|
|
763
677
|
else if (this.otherDeviceType === 'stateful') {
|
|
764
|
-
this.
|
|
765
|
-
this.
|
|
678
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
679
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
766
680
|
}
|
|
767
681
|
else if (this.otherDeviceType === 'switch') {
|
|
768
|
-
this.
|
|
682
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
769
683
|
}
|
|
770
684
|
else {
|
|
771
|
-
this.
|
|
685
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
772
686
|
}
|
|
773
687
|
}
|
|
774
688
|
async removeOutletService(accessory) {
|
|
775
|
-
// If
|
|
776
|
-
|
|
777
|
-
|
|
689
|
+
// If Outlet.Service still present, then remove first
|
|
690
|
+
if (this.Outlet?.Service) {
|
|
691
|
+
this.Outlet.Service = this.accessory.getService(this.hap.Service.Outlet);
|
|
778
692
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
693
|
+
accessory.removeService(this.Outlet.Service);
|
|
779
694
|
}
|
|
780
|
-
accessory.removeService(this.outletService);
|
|
781
695
|
}
|
|
782
696
|
async removeGarageDoorService(accessory) {
|
|
783
|
-
// If
|
|
784
|
-
|
|
785
|
-
|
|
697
|
+
// If GarageDoor.Service still present, then remove first
|
|
698
|
+
if (this.GarageDoor?.Service) {
|
|
699
|
+
this.GarageDoor.Service = this.accessory.getService(this.hap.Service.GarageDoorOpener);
|
|
786
700
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
701
|
+
accessory.removeService(this.GarageDoor.Service);
|
|
787
702
|
}
|
|
788
|
-
accessory.removeService(this.garageDoorService);
|
|
789
703
|
}
|
|
790
704
|
async removeDoorService(accessory) {
|
|
791
|
-
// If
|
|
792
|
-
|
|
793
|
-
|
|
705
|
+
// If Door.Service still present, then remove first
|
|
706
|
+
if (this.Door?.Service) {
|
|
707
|
+
this.Door.Service = this.accessory.getService(this.hap.Service.Door);
|
|
794
708
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
709
|
+
accessory.removeService(this.Door.Service);
|
|
795
710
|
}
|
|
796
|
-
accessory.removeService(this.doorService);
|
|
797
711
|
}
|
|
798
712
|
async removeLockService(accessory) {
|
|
799
|
-
// If
|
|
800
|
-
|
|
801
|
-
|
|
713
|
+
// If Lock.Service still present, then remove first
|
|
714
|
+
if (this.Lock?.Service) {
|
|
715
|
+
this.Lock.Service = this.accessory.getService(this.hap.Service.LockMechanism);
|
|
802
716
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
717
|
+
accessory.removeService(this.Lock.Service);
|
|
803
718
|
}
|
|
804
|
-
accessory.removeService(this.lockService);
|
|
805
719
|
}
|
|
806
720
|
async removeFaucetService(accessory) {
|
|
807
|
-
// If
|
|
808
|
-
|
|
809
|
-
|
|
721
|
+
// If Faucet.Service still present, then remove first
|
|
722
|
+
if (this.Faucet?.Service) {
|
|
723
|
+
this.Faucet.Service = this.accessory.getService(this.hap.Service.Faucet);
|
|
810
724
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
725
|
+
accessory.removeService(this.Faucet.Service);
|
|
811
726
|
}
|
|
812
|
-
accessory.removeService(this.faucetService);
|
|
813
727
|
}
|
|
814
728
|
async removeFanService(accessory) {
|
|
815
|
-
// If
|
|
816
|
-
|
|
817
|
-
|
|
729
|
+
// If Fan Service still present, then remove first
|
|
730
|
+
if (this.Fan?.Service) {
|
|
731
|
+
this.Fan.Service = this.accessory.getService(this.hap.Service.Fan);
|
|
818
732
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
733
|
+
accessory.removeService(this.Fan.Service);
|
|
819
734
|
}
|
|
820
|
-
accessory.removeService(this.fanService);
|
|
821
735
|
}
|
|
822
736
|
async removeWindowService(accessory) {
|
|
823
|
-
// If
|
|
824
|
-
|
|
825
|
-
|
|
737
|
+
// If Window.Service still present, then remove first
|
|
738
|
+
if (this.Window?.Service) {
|
|
739
|
+
this.Window.Service = this.accessory.getService(this.hap.Service.Window);
|
|
826
740
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
741
|
+
accessory.removeService(this.Window.Service);
|
|
827
742
|
}
|
|
828
|
-
accessory.removeService(this.windowService);
|
|
829
743
|
}
|
|
830
744
|
async removeWindowCoveringService(accessory) {
|
|
831
|
-
// If
|
|
832
|
-
|
|
833
|
-
|
|
745
|
+
// If WindowCovering.Service still present, then remove first
|
|
746
|
+
if (this.WindowCovering?.Service) {
|
|
747
|
+
this.WindowCovering.Service = this.accessory.getService(this.hap.Service.WindowCovering);
|
|
834
748
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
749
|
+
accessory.removeService(this.WindowCovering.Service);
|
|
835
750
|
}
|
|
836
|
-
accessory.removeService(this.windowCoveringService);
|
|
837
751
|
}
|
|
838
752
|
async removeStatefulProgrammableSwitchService(accessory) {
|
|
839
|
-
// If
|
|
840
|
-
|
|
841
|
-
|
|
753
|
+
// If StatefulProgrammableSwitch.Service still present, then remove first
|
|
754
|
+
if (this.StatefulProgrammableSwitch?.Service) {
|
|
755
|
+
this.StatefulProgrammableSwitch.Service = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch);
|
|
842
756
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
757
|
+
accessory.removeService(this.StatefulProgrammableSwitch.Service);
|
|
843
758
|
}
|
|
844
|
-
accessory.removeService(this.statefulProgrammableSwitchService);
|
|
845
759
|
}
|
|
846
760
|
async removeSwitchService(accessory) {
|
|
847
|
-
// If
|
|
848
|
-
|
|
849
|
-
|
|
761
|
+
// If Switch.Service still present, then remove first
|
|
762
|
+
if (this.Switch?.Service) {
|
|
763
|
+
this.Switch.Service = this.accessory.getService(this.hap.Service.Switch);
|
|
850
764
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
765
|
+
accessory.removeService(this.Switch.Service);
|
|
851
766
|
}
|
|
852
|
-
accessory.removeService(this.switchService);
|
|
853
767
|
}
|
|
854
|
-
async
|
|
768
|
+
async getOtherConfigSettings(device) {
|
|
855
769
|
if (!device.other?.deviceType && this.accessory.context.deviceType) {
|
|
856
770
|
this.otherDeviceType = this.accessory.context.deviceType;
|
|
857
771
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}, from Accessory Cache.`);
|
|
@@ -867,113 +781,5 @@ export class Others {
|
|
|
867
781
|
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} no deviceType set, using default deviceType: ${this.otherDeviceType}`);
|
|
868
782
|
}
|
|
869
783
|
}
|
|
870
|
-
async deviceContext() {
|
|
871
|
-
if (this.On === undefined) {
|
|
872
|
-
this.On = true;
|
|
873
|
-
}
|
|
874
|
-
else {
|
|
875
|
-
this.On = this.accessory.context.On;
|
|
876
|
-
}
|
|
877
|
-
if (this.FirmwareRevision === undefined) {
|
|
878
|
-
this.FirmwareRevision = this.platform.version;
|
|
879
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
async deviceConfig(device) {
|
|
883
|
-
let config = {};
|
|
884
|
-
if (device.other) {
|
|
885
|
-
config = device.other;
|
|
886
|
-
}
|
|
887
|
-
if (device.logging !== undefined) {
|
|
888
|
-
config['logging'] = device.logging;
|
|
889
|
-
}
|
|
890
|
-
if (device.connectionType !== undefined) {
|
|
891
|
-
config['connectionType'] = device.connectionType;
|
|
892
|
-
}
|
|
893
|
-
if (device.external !== undefined) {
|
|
894
|
-
config['external'] = device.external;
|
|
895
|
-
}
|
|
896
|
-
if (device.customOn !== undefined) {
|
|
897
|
-
config['customOn'] = device.customOn;
|
|
898
|
-
}
|
|
899
|
-
if (device.customOff !== undefined) {
|
|
900
|
-
config['customOff'] = device.customOff;
|
|
901
|
-
}
|
|
902
|
-
if (device.customize !== undefined) {
|
|
903
|
-
config['customize'] = device.customize;
|
|
904
|
-
}
|
|
905
|
-
if (device.disablePushOn !== undefined) {
|
|
906
|
-
config['disablePushOn'] = device.disablePushOn;
|
|
907
|
-
}
|
|
908
|
-
if (device.disablePushOff !== undefined) {
|
|
909
|
-
config['disablePushOff'] = device.disablePushOff;
|
|
910
|
-
}
|
|
911
|
-
if (Object.entries(config).length !== 0) {
|
|
912
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
async deviceLogs(device) {
|
|
916
|
-
if (this.platform.debugMode) {
|
|
917
|
-
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
918
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
919
|
-
}
|
|
920
|
-
else if (device.logging) {
|
|
921
|
-
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
922
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
923
|
-
}
|
|
924
|
-
else if (this.platform.config.options?.logging) {
|
|
925
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
926
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
927
|
-
}
|
|
928
|
-
else {
|
|
929
|
-
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
930
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
/**
|
|
934
|
-
* Logging for Device
|
|
935
|
-
*/
|
|
936
|
-
infoLog(...log) {
|
|
937
|
-
if (this.enablingDeviceLogging()) {
|
|
938
|
-
this.platform.log.info(String(...log));
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
warnLog(...log) {
|
|
942
|
-
if (this.enablingDeviceLogging()) {
|
|
943
|
-
this.platform.log.warn(String(...log));
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
debugWarnLog(...log) {
|
|
947
|
-
if (this.enablingDeviceLogging()) {
|
|
948
|
-
if (this.deviceLogging?.includes('debug')) {
|
|
949
|
-
this.platform.log.warn('[DEBUG]', String(...log));
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
errorLog(...log) {
|
|
954
|
-
if (this.enablingDeviceLogging()) {
|
|
955
|
-
this.platform.log.error(String(...log));
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
debugErrorLog(...log) {
|
|
959
|
-
if (this.enablingDeviceLogging()) {
|
|
960
|
-
if (this.deviceLogging?.includes('debug')) {
|
|
961
|
-
this.platform.log.error('[DEBUG]', String(...log));
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
debugLog(...log) {
|
|
966
|
-
if (this.enablingDeviceLogging()) {
|
|
967
|
-
if (this.deviceLogging === 'debug') {
|
|
968
|
-
this.platform.log.info('[DEBUG]', String(...log));
|
|
969
|
-
}
|
|
970
|
-
else {
|
|
971
|
-
this.platform.log.debug(String(...log));
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
enablingDeviceLogging() {
|
|
976
|
-
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
977
|
-
}
|
|
978
784
|
}
|
|
979
785
|
//# sourceMappingURL=other.js.map
|