@switchbot/homebridge-switchbot 2.14.0 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/npm-version-script.cjs +81 -0
- package/.github/workflows/dependabot.yml +10 -11
- package/CHANGELOG.md +11 -2
- package/LICENSE +1 -1
- package/config.schema.json +1 -0
- package/dist/device/blindtilt.d.ts +9 -5
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +151 -91
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +9 -5
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +234 -184
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +9 -5
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +110 -64
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +9 -5
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +121 -69
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +9 -5
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +111 -66
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +9 -5
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +164 -107
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +9 -5
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +87 -51
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +9 -5
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +133 -90
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +9 -5
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +108 -66
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +9 -5
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +110 -65
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +10 -6
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +125 -84
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +9 -5
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +102 -63
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +9 -5
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +102 -63
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +9 -5
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +95 -54
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -5
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +68 -40
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +9 -5
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +86 -52
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/homebridge-ui/server.d.ts +2 -0
- package/dist/homebridge-ui/server.d.ts.map +1 -0
- package/dist/homebridge-ui/server.js +44 -0
- package/dist/homebridge-ui/server.js.map +1 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +8 -4
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +105 -71
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +8 -4
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +78 -46
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +8 -4
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +41 -25
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +8 -4
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +62 -39
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +8 -4
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +67 -45
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +8 -4
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +176 -150
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +8 -4
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +81 -62
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +8 -4
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +41 -25
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +8 -4
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +48 -32
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +8 -9
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +147 -162
- package/dist/platform.js.map +1 -1
- package/dist/settings.js +7 -14
- package/dist/settings.js.map +1 -1
- package/dist/utils.js +1 -5
- package/dist/utils.js.map +1 -1
- package/package.json +28 -16
- package/src/device/blindtilt.ts +80 -69
- package/src/device/bot.ts +189 -178
- package/src/device/ceilinglight.ts +55 -42
- package/src/device/colorbulb.ts +51 -38
- package/src/device/contact.ts +69 -58
- package/src/device/curtain.ts +94 -83
- package/src/device/hub.ts +54 -43
- package/src/device/humidifier.ts +86 -75
- package/src/device/iosensor.ts +63 -52
- package/src/device/lightstrip.ts +54 -41
- package/src/device/lock.ts +89 -79
- package/src/device/meter.ts +59 -48
- package/src/device/meterplus.ts +63 -52
- package/src/device/motion.ts +56 -45
- package/src/device/plug.ts +36 -25
- package/src/device/robotvacuumcleaner.ts +47 -36
- package/src/homebridge-ui/public/index.html +240 -0
- package/src/homebridge-ui/server.ts +48 -0
- package/src/index.ts +10 -7
- package/src/irdevice/airconditioner.ts +70 -62
- package/src/irdevice/airpurifier.ts +47 -39
- package/src/irdevice/camera.ts +27 -19
- package/src/irdevice/fan.ts +41 -33
- package/src/irdevice/light.ts +47 -39
- package/src/irdevice/other.ts +163 -155
- package/src/irdevice/tv.ts +65 -57
- package/src/irdevice/vacuumcleaner.ts +27 -19
- package/src/irdevice/waterheater.ts +34 -26
- package/src/platform.ts +35 -21
- package/tsconfig.json +11 -13
- package/homebridge-ui/server.js +0 -50
- /package/{homebridge-ui → dist/homebridge-ui}/public/index.html +0 -0
package/dist/irdevice/other.js
CHANGED
|
@@ -1,32 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Others = void 0;
|
|
4
|
-
const undici_1 = require("undici");
|
|
5
|
-
const settings_1 = require("../settings");
|
|
1
|
+
import { request } from 'undici';
|
|
2
|
+
import { Devices } from '../settings';
|
|
6
3
|
/**
|
|
7
4
|
* Platform Accessory
|
|
8
5
|
* An instance of this class is created for each accessory your platform registers
|
|
9
6
|
* Each accessory may expose multiple services of different service types.
|
|
10
7
|
*/
|
|
11
|
-
class Others {
|
|
8
|
+
export class Others {
|
|
9
|
+
platform;
|
|
10
|
+
accessory;
|
|
11
|
+
device;
|
|
12
|
+
api;
|
|
13
|
+
log;
|
|
14
|
+
config;
|
|
15
|
+
hap;
|
|
16
|
+
// Services
|
|
17
|
+
fanService;
|
|
18
|
+
doorService;
|
|
19
|
+
lockService;
|
|
20
|
+
faucetService;
|
|
21
|
+
windowService;
|
|
22
|
+
switchService;
|
|
23
|
+
outletService;
|
|
24
|
+
garageDoorService;
|
|
25
|
+
windowCoveringService;
|
|
26
|
+
statefulProgrammableSwitchService;
|
|
27
|
+
// Characteristic Values
|
|
28
|
+
On;
|
|
29
|
+
FirmwareRevision;
|
|
30
|
+
// Config
|
|
31
|
+
deviceLogging;
|
|
32
|
+
disablePushOn;
|
|
33
|
+
otherDeviceType;
|
|
34
|
+
disablePushOff;
|
|
12
35
|
constructor(platform, accessory, device) {
|
|
13
36
|
this.platform = platform;
|
|
14
37
|
this.accessory = accessory;
|
|
15
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;
|
|
16
43
|
// default placeholders
|
|
17
|
-
this.
|
|
44
|
+
this.deviceLogs(device);
|
|
18
45
|
this.deviceType(device);
|
|
19
46
|
this.context();
|
|
20
47
|
this.disablePushOnChanges(device);
|
|
21
48
|
this.disablePushOffChanges(device);
|
|
22
|
-
this.
|
|
49
|
+
this.deviceConfig(device);
|
|
23
50
|
// set accessory information
|
|
24
51
|
accessory
|
|
25
|
-
.getService(this.
|
|
26
|
-
.setCharacteristic(this.
|
|
27
|
-
.setCharacteristic(this.
|
|
28
|
-
.setCharacteristic(this.
|
|
29
|
-
.setCharacteristic(this.
|
|
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);
|
|
30
57
|
// deviceType
|
|
31
58
|
if (this.otherDeviceType === 'switch') {
|
|
32
59
|
this.removeFanService(accessory);
|
|
@@ -40,14 +67,14 @@ class Others {
|
|
|
40
67
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
41
68
|
// Add switchService
|
|
42
69
|
const switchService = `${accessory.displayName} Switch`;
|
|
43
|
-
(this.switchService = accessory.getService(this.
|
|
44
|
-
|| accessory.addService(this.
|
|
70
|
+
(this.switchService = accessory.getService(this.hap.Service.Switch)
|
|
71
|
+
|| accessory.addService(this.hap.Service.Switch)), switchService;
|
|
45
72
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Switch`);
|
|
46
|
-
this.switchService.setCharacteristic(this.
|
|
47
|
-
if (!this.switchService.testCharacteristic(this.
|
|
48
|
-
this.switchService.addCharacteristic(this.
|
|
73
|
+
this.switchService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
74
|
+
if (!this.switchService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
75
|
+
this.switchService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
49
76
|
}
|
|
50
|
-
this.switchService.getCharacteristic(this.
|
|
77
|
+
this.switchService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
51
78
|
}
|
|
52
79
|
else if (this.otherDeviceType === 'garagedoor') {
|
|
53
80
|
this.removeFanService(accessory);
|
|
@@ -61,15 +88,15 @@ class Others {
|
|
|
61
88
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
62
89
|
// Add garageDoorService
|
|
63
90
|
const garageDoorService = `${accessory.displayName} Garage Door Opener`;
|
|
64
|
-
(this.garageDoorService = accessory.getService(this.
|
|
65
|
-
|| accessory.addService(this.
|
|
91
|
+
(this.garageDoorService = accessory.getService(this.hap.Service.GarageDoorOpener)
|
|
92
|
+
|| accessory.addService(this.hap.Service.GarageDoorOpener)), garageDoorService;
|
|
66
93
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
67
|
-
this.garageDoorService.setCharacteristic(this.
|
|
68
|
-
if (!this.garageDoorService.testCharacteristic(this.
|
|
69
|
-
this.garageDoorService.addCharacteristic(this.
|
|
94
|
+
this.garageDoorService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
95
|
+
if (!this.garageDoorService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
96
|
+
this.garageDoorService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
70
97
|
}
|
|
71
|
-
this.garageDoorService.getCharacteristic(this.
|
|
72
|
-
this.garageDoorService.setCharacteristic(this.
|
|
98
|
+
this.garageDoorService.getCharacteristic(this.hap.Characteristic.TargetDoorState).onSet(this.OnSet.bind(this));
|
|
99
|
+
this.garageDoorService.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false);
|
|
73
100
|
}
|
|
74
101
|
else if (this.otherDeviceType === 'door') {
|
|
75
102
|
this.removeFanService(accessory);
|
|
@@ -83,15 +110,15 @@ class Others {
|
|
|
83
110
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
84
111
|
// Add doorService
|
|
85
112
|
const doorService = `${accessory.displayName} Door`;
|
|
86
|
-
(this.doorService = accessory.getService(this.
|
|
87
|
-
|| accessory.addService(this.
|
|
113
|
+
(this.doorService = accessory.getService(this.hap.Service.Door)
|
|
114
|
+
|| accessory.addService(this.hap.Service.Door)), doorService;
|
|
88
115
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Door`);
|
|
89
|
-
this.doorService.setCharacteristic(this.
|
|
90
|
-
if (!this.doorService.testCharacteristic(this.
|
|
91
|
-
this.doorService.addCharacteristic(this.
|
|
116
|
+
this.doorService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
117
|
+
if (!this.doorService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
118
|
+
this.doorService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
92
119
|
}
|
|
93
120
|
this.doorService
|
|
94
|
-
.getCharacteristic(this.
|
|
121
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
95
122
|
.setProps({
|
|
96
123
|
validValues: [0, 100],
|
|
97
124
|
minValue: 0,
|
|
@@ -99,7 +126,7 @@ class Others {
|
|
|
99
126
|
minStep: 100,
|
|
100
127
|
})
|
|
101
128
|
.onSet(this.OnSet.bind(this));
|
|
102
|
-
this.doorService.setCharacteristic(this.
|
|
129
|
+
this.doorService.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
103
130
|
}
|
|
104
131
|
else if (this.otherDeviceType === 'window') {
|
|
105
132
|
this.removeFanService(accessory);
|
|
@@ -113,15 +140,15 @@ class Others {
|
|
|
113
140
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
114
141
|
// Add windowService
|
|
115
142
|
const windowService = `${accessory.displayName} Window`;
|
|
116
|
-
(this.windowService = accessory.getService(this.
|
|
117
|
-
|| accessory.addService(this.
|
|
143
|
+
(this.windowService = accessory.getService(this.hap.Service.Window)
|
|
144
|
+
|| accessory.addService(this.hap.Service.Window)), windowService;
|
|
118
145
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window`);
|
|
119
|
-
this.windowService.setCharacteristic(this.
|
|
120
|
-
if (!this.windowService.testCharacteristic(this.
|
|
121
|
-
this.windowService.addCharacteristic(this.
|
|
146
|
+
this.windowService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
147
|
+
if (!this.windowService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
148
|
+
this.windowService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
122
149
|
}
|
|
123
150
|
this.windowService
|
|
124
|
-
.getCharacteristic(this.
|
|
151
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
125
152
|
.setProps({
|
|
126
153
|
validValues: [0, 100],
|
|
127
154
|
minValue: 0,
|
|
@@ -129,7 +156,7 @@ class Others {
|
|
|
129
156
|
minStep: 100,
|
|
130
157
|
})
|
|
131
158
|
.onSet(this.OnSet.bind(this));
|
|
132
|
-
this.windowService.setCharacteristic(this.
|
|
159
|
+
this.windowService.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
133
160
|
}
|
|
134
161
|
else if (this.otherDeviceType === 'windowcovering') {
|
|
135
162
|
this.removeFanService(accessory);
|
|
@@ -143,15 +170,15 @@ class Others {
|
|
|
143
170
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
144
171
|
// Add windowCoveringService
|
|
145
172
|
const windowCoveringService = `${accessory.displayName} Window Covering`;
|
|
146
|
-
(this.windowCoveringService = accessory.getService(this.
|
|
147
|
-
|| accessory.addService(this.
|
|
173
|
+
(this.windowCoveringService = accessory.getService(this.hap.Service.WindowCovering)
|
|
174
|
+
|| accessory.addService(this.hap.Service.WindowCovering)), windowCoveringService;
|
|
148
175
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
149
|
-
this.windowCoveringService.setCharacteristic(this.
|
|
150
|
-
if (!this.windowCoveringService.testCharacteristic(this.
|
|
151
|
-
this.windowCoveringService.addCharacteristic(this.
|
|
176
|
+
this.windowCoveringService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
177
|
+
if (!this.windowCoveringService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
178
|
+
this.windowCoveringService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
152
179
|
}
|
|
153
180
|
this.windowCoveringService
|
|
154
|
-
.getCharacteristic(this.
|
|
181
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
155
182
|
.setProps({
|
|
156
183
|
validValues: [0, 100],
|
|
157
184
|
minValue: 0,
|
|
@@ -159,7 +186,7 @@ class Others {
|
|
|
159
186
|
minStep: 100,
|
|
160
187
|
})
|
|
161
188
|
.onSet(this.OnSet.bind(this));
|
|
162
|
-
this.windowCoveringService.setCharacteristic(this.
|
|
189
|
+
this.windowCoveringService.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
163
190
|
}
|
|
164
191
|
else if (this.otherDeviceType === 'lock') {
|
|
165
192
|
this.removeFanService(accessory);
|
|
@@ -173,14 +200,14 @@ class Others {
|
|
|
173
200
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
174
201
|
// Add lockService
|
|
175
202
|
const lockService = `${accessory.displayName} Lock`;
|
|
176
|
-
(this.lockService = accessory.getService(this.
|
|
177
|
-
|| accessory.addService(this.
|
|
203
|
+
(this.lockService = accessory.getService(this.hap.Service.LockMechanism)
|
|
204
|
+
|| accessory.addService(this.hap.Service.LockMechanism)), lockService;
|
|
178
205
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Lock`);
|
|
179
|
-
this.lockService.setCharacteristic(this.
|
|
180
|
-
if (!this.lockService.testCharacteristic(this.
|
|
181
|
-
this.lockService.addCharacteristic(this.
|
|
206
|
+
this.lockService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
207
|
+
if (!this.lockService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
208
|
+
this.lockService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
182
209
|
}
|
|
183
|
-
this.lockService.getCharacteristic(this.
|
|
210
|
+
this.lockService.getCharacteristic(this.hap.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
|
|
184
211
|
}
|
|
185
212
|
else if (this.otherDeviceType === 'faucet') {
|
|
186
213
|
this.removeFanService(accessory);
|
|
@@ -194,14 +221,14 @@ class Others {
|
|
|
194
221
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
195
222
|
// Add faucetService
|
|
196
223
|
const faucetService = `${accessory.displayName} Faucet`;
|
|
197
|
-
(this.faucetService = accessory.getService(this.
|
|
198
|
-
|| accessory.addService(this.
|
|
224
|
+
(this.faucetService = accessory.getService(this.hap.Service.Faucet)
|
|
225
|
+
|| accessory.addService(this.hap.Service.Faucet)), faucetService;
|
|
199
226
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Faucet`);
|
|
200
|
-
this.faucetService.setCharacteristic(this.
|
|
201
|
-
if (!this.faucetService.testCharacteristic(this.
|
|
202
|
-
this.faucetService.addCharacteristic(this.
|
|
227
|
+
this.faucetService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
228
|
+
if (!this.faucetService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
229
|
+
this.faucetService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
203
230
|
}
|
|
204
|
-
this.faucetService.getCharacteristic(this.
|
|
231
|
+
this.faucetService.getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this));
|
|
205
232
|
}
|
|
206
233
|
else if (this.otherDeviceType === 'fan') {
|
|
207
234
|
this.removeLockService(accessory);
|
|
@@ -215,14 +242,14 @@ class Others {
|
|
|
215
242
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
216
243
|
// Add fanService
|
|
217
244
|
const fanService = `${accessory.displayName} Fan`;
|
|
218
|
-
(this.fanService = accessory.getService(this.
|
|
219
|
-
|| accessory.addService(this.
|
|
245
|
+
(this.fanService = accessory.getService(this.hap.Service.Fan)
|
|
246
|
+
|| accessory.addService(this.hap.Service.Fan)), fanService;
|
|
220
247
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Fan`);
|
|
221
|
-
this.fanService.setCharacteristic(this.
|
|
222
|
-
if (!this.fanService.testCharacteristic(this.
|
|
223
|
-
this.fanService.addCharacteristic(this.
|
|
248
|
+
this.fanService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
249
|
+
if (!this.fanService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
250
|
+
this.fanService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
224
251
|
}
|
|
225
|
-
this.fanService.getCharacteristic(this.
|
|
252
|
+
this.fanService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
226
253
|
}
|
|
227
254
|
else if (this.otherDeviceType === 'stateful') {
|
|
228
255
|
this.removeFanService(accessory);
|
|
@@ -236,15 +263,15 @@ class Others {
|
|
|
236
263
|
this.removeWindowCoveringService(accessory);
|
|
237
264
|
// Add statefulProgrammableSwitchService
|
|
238
265
|
const statefulProgrammableSwitchService = `${accessory.displayName} Stateful Programmable Switch`;
|
|
239
|
-
(this.statefulProgrammableSwitchService = accessory.getService(this.
|
|
240
|
-
|| accessory.addService(this.
|
|
266
|
+
(this.statefulProgrammableSwitchService = accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
267
|
+
|| accessory.addService(this.hap.Service.StatefulProgrammableSwitch)), statefulProgrammableSwitchService;
|
|
241
268
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
242
|
-
this.statefulProgrammableSwitchService.setCharacteristic(this.
|
|
243
|
-
if (!this.statefulProgrammableSwitchService.testCharacteristic(this.
|
|
244
|
-
this.statefulProgrammableSwitchService.addCharacteristic(this.
|
|
269
|
+
this.statefulProgrammableSwitchService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
270
|
+
if (!this.statefulProgrammableSwitchService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
271
|
+
this.statefulProgrammableSwitchService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
245
272
|
}
|
|
246
273
|
this.statefulProgrammableSwitchService
|
|
247
|
-
.getCharacteristic(this.
|
|
274
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
248
275
|
.onSet(this.OnSet.bind(this));
|
|
249
276
|
}
|
|
250
277
|
else {
|
|
@@ -259,14 +286,14 @@ class Others {
|
|
|
259
286
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
260
287
|
// Add outletService
|
|
261
288
|
const outletService = `${accessory.displayName} Outlet`;
|
|
262
|
-
(this.outletService = accessory.getService(this.
|
|
263
|
-
|| accessory.addService(this.
|
|
289
|
+
(this.outletService = accessory.getService(this.hap.Service.Outlet)
|
|
290
|
+
|| accessory.addService(this.hap.Service.Outlet)), outletService;
|
|
264
291
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Outlet`);
|
|
265
|
-
this.outletService.setCharacteristic(this.
|
|
266
|
-
if (!this.outletService.testCharacteristic(this.
|
|
267
|
-
this.outletService.addCharacteristic(this.
|
|
292
|
+
this.outletService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
293
|
+
if (!this.outletService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
294
|
+
this.outletService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
268
295
|
}
|
|
269
|
-
this.outletService.getCharacteristic(this.
|
|
296
|
+
this.outletService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
270
297
|
}
|
|
271
298
|
}
|
|
272
299
|
/**
|
|
@@ -275,7 +302,7 @@ class Others {
|
|
|
275
302
|
async OnSet(value) {
|
|
276
303
|
if (this.otherDeviceType === 'garagedoor') {
|
|
277
304
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetDoorState: ${value}`);
|
|
278
|
-
if (value === this.
|
|
305
|
+
if (value === this.hap.Characteristic.TargetDoorState.CLOSED) {
|
|
279
306
|
this.On = false;
|
|
280
307
|
}
|
|
281
308
|
else {
|
|
@@ -295,7 +322,7 @@ class Others {
|
|
|
295
322
|
}
|
|
296
323
|
else if (this.otherDeviceType === 'lock') {
|
|
297
324
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
|
|
298
|
-
if (value === this.
|
|
325
|
+
if (value === this.hap.Characteristic.LockTargetState.SECURED) {
|
|
299
326
|
this.On = false;
|
|
300
327
|
}
|
|
301
328
|
else {
|
|
@@ -304,7 +331,7 @@ class Others {
|
|
|
304
331
|
}
|
|
305
332
|
else if (this.otherDeviceType === 'faucet') {
|
|
306
333
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
307
|
-
if (value === this.
|
|
334
|
+
if (value === this.hap.Characteristic.Active.INACTIVE) {
|
|
308
335
|
this.On = false;
|
|
309
336
|
}
|
|
310
337
|
else {
|
|
@@ -385,7 +412,7 @@ class Others {
|
|
|
385
412
|
if (this.device.connectionType === 'OpenAPI') {
|
|
386
413
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
387
414
|
try {
|
|
388
|
-
const { body, statusCode, headers } = await
|
|
415
|
+
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
389
416
|
body: bodyChange,
|
|
390
417
|
method: 'POST',
|
|
391
418
|
headers: this.platform.generateHeaders(),
|
|
@@ -425,13 +452,13 @@ class Others {
|
|
|
425
452
|
}
|
|
426
453
|
else {
|
|
427
454
|
if (this.On) {
|
|
428
|
-
this.garageDoorService?.updateCharacteristic(this.
|
|
429
|
-
this.garageDoorService?.updateCharacteristic(this.
|
|
455
|
+
this.garageDoorService?.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.OPEN);
|
|
456
|
+
this.garageDoorService?.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.OPEN);
|
|
430
457
|
this.debugLog(`${this.device.remoteType}: ` + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
|
|
431
458
|
}
|
|
432
459
|
else {
|
|
433
|
-
this.garageDoorService?.updateCharacteristic(this.
|
|
434
|
-
this.garageDoorService?.updateCharacteristic(this.
|
|
460
|
+
this.garageDoorService?.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
|
|
461
|
+
this.garageDoorService?.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
|
|
435
462
|
this.debugLog(`${this.device.remoteType}: ` + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
|
|
436
463
|
}
|
|
437
464
|
}
|
|
@@ -443,15 +470,15 @@ class Others {
|
|
|
443
470
|
}
|
|
444
471
|
else {
|
|
445
472
|
if (this.On) {
|
|
446
|
-
this.doorService?.updateCharacteristic(this.
|
|
447
|
-
this.doorService?.updateCharacteristic(this.
|
|
448
|
-
this.doorService?.updateCharacteristic(this.
|
|
473
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
474
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
475
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
449
476
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
450
477
|
}
|
|
451
478
|
else {
|
|
452
|
-
this.doorService?.updateCharacteristic(this.
|
|
453
|
-
this.doorService?.updateCharacteristic(this.
|
|
454
|
-
this.doorService?.updateCharacteristic(this.
|
|
479
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
480
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
481
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
455
482
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
456
483
|
}
|
|
457
484
|
}
|
|
@@ -463,15 +490,15 @@ class Others {
|
|
|
463
490
|
}
|
|
464
491
|
else {
|
|
465
492
|
if (this.On) {
|
|
466
|
-
this.windowService?.updateCharacteristic(this.
|
|
467
|
-
this.windowService?.updateCharacteristic(this.
|
|
468
|
-
this.windowService?.updateCharacteristic(this.
|
|
493
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
494
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
495
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
469
496
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
470
497
|
}
|
|
471
498
|
else {
|
|
472
|
-
this.windowService?.updateCharacteristic(this.
|
|
473
|
-
this.windowService?.updateCharacteristic(this.
|
|
474
|
-
this.windowService?.updateCharacteristic(this.
|
|
499
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
500
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
501
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
475
502
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
476
503
|
}
|
|
477
504
|
}
|
|
@@ -483,15 +510,15 @@ class Others {
|
|
|
483
510
|
}
|
|
484
511
|
else {
|
|
485
512
|
if (this.On) {
|
|
486
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
487
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
488
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
513
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
514
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
515
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
489
516
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
490
517
|
}
|
|
491
518
|
else {
|
|
492
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
493
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
494
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
519
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
520
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
521
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
495
522
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
496
523
|
}
|
|
497
524
|
}
|
|
@@ -503,14 +530,14 @@ class Others {
|
|
|
503
530
|
}
|
|
504
531
|
else {
|
|
505
532
|
if (this.On) {
|
|
506
|
-
this.lockService?.updateCharacteristic(this.
|
|
507
|
-
this.lockService?.updateCharacteristic(this.
|
|
533
|
+
this.lockService?.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
|
|
534
|
+
this.lockService?.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
|
|
508
535
|
this.debugLog(`${this.device.remoteType}: ` +
|
|
509
536
|
`${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`);
|
|
510
537
|
}
|
|
511
538
|
else {
|
|
512
|
-
this.lockService?.updateCharacteristic(this.
|
|
513
|
-
this.lockService?.updateCharacteristic(this.
|
|
539
|
+
this.lockService?.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
|
|
540
|
+
this.lockService?.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
|
|
514
541
|
this.debugLog(`${this.device.remoteType}: ` + `${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`);
|
|
515
542
|
}
|
|
516
543
|
}
|
|
@@ -522,11 +549,11 @@ class Others {
|
|
|
522
549
|
}
|
|
523
550
|
else {
|
|
524
551
|
if (this.On) {
|
|
525
|
-
this.faucetService?.updateCharacteristic(this.
|
|
552
|
+
this.faucetService?.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
|
|
526
553
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
527
554
|
}
|
|
528
555
|
else {
|
|
529
|
-
this.faucetService?.updateCharacteristic(this.
|
|
556
|
+
this.faucetService?.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
530
557
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
531
558
|
}
|
|
532
559
|
}
|
|
@@ -538,11 +565,11 @@ class Others {
|
|
|
538
565
|
}
|
|
539
566
|
else {
|
|
540
567
|
if (this.On) {
|
|
541
|
-
this.fanService?.updateCharacteristic(this.
|
|
568
|
+
this.fanService?.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
542
569
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
543
570
|
}
|
|
544
571
|
else {
|
|
545
|
-
this.fanService?.updateCharacteristic(this.
|
|
572
|
+
this.fanService?.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
546
573
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
547
574
|
}
|
|
548
575
|
}
|
|
@@ -554,14 +581,14 @@ class Others {
|
|
|
554
581
|
}
|
|
555
582
|
else {
|
|
556
583
|
if (this.On) {
|
|
557
|
-
this.statefulProgrammableSwitchService?.updateCharacteristic(this.
|
|
558
|
-
this.statefulProgrammableSwitchService?.updateCharacteristic(this.
|
|
584
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
585
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
559
586
|
this.debugLog(`${this.device.remoteType}: ` +
|
|
560
587
|
`${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`);
|
|
561
588
|
}
|
|
562
589
|
else {
|
|
563
|
-
this.statefulProgrammableSwitchService?.updateCharacteristic(this.
|
|
564
|
-
this.statefulProgrammableSwitchService?.updateCharacteristic(this.
|
|
590
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
591
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
565
592
|
this.debugLog(`${this.device.remoteType}: ` +
|
|
566
593
|
`${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`);
|
|
567
594
|
}
|
|
@@ -573,7 +600,7 @@ class Others {
|
|
|
573
600
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
574
601
|
}
|
|
575
602
|
else {
|
|
576
|
-
this.switchService?.updateCharacteristic(this.
|
|
603
|
+
this.switchService?.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
577
604
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
578
605
|
}
|
|
579
606
|
}
|
|
@@ -582,7 +609,7 @@ class Others {
|
|
|
582
609
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
583
610
|
}
|
|
584
611
|
else {
|
|
585
|
-
this.outletService?.updateCharacteristic(this.
|
|
612
|
+
this.outletService?.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
586
613
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
587
614
|
}
|
|
588
615
|
}
|
|
@@ -671,49 +698,49 @@ class Others {
|
|
|
671
698
|
}
|
|
672
699
|
async apiError(e) {
|
|
673
700
|
if (this.otherDeviceType === 'garagedoor') {
|
|
674
|
-
this.garageDoorService?.updateCharacteristic(this.
|
|
675
|
-
this.garageDoorService?.updateCharacteristic(this.
|
|
676
|
-
this.garageDoorService?.updateCharacteristic(this.
|
|
701
|
+
this.garageDoorService?.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e);
|
|
702
|
+
this.garageDoorService?.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e);
|
|
703
|
+
this.garageDoorService?.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e);
|
|
677
704
|
}
|
|
678
705
|
else if (this.otherDeviceType === 'door') {
|
|
679
|
-
this.doorService?.updateCharacteristic(this.
|
|
680
|
-
this.doorService?.updateCharacteristic(this.
|
|
681
|
-
this.doorService?.updateCharacteristic(this.
|
|
706
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
707
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
708
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
682
709
|
}
|
|
683
710
|
else if (this.otherDeviceType === 'window') {
|
|
684
|
-
this.windowService?.updateCharacteristic(this.
|
|
685
|
-
this.windowService?.updateCharacteristic(this.
|
|
686
|
-
this.windowService?.updateCharacteristic(this.
|
|
711
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
712
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
713
|
+
this.windowService?.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
687
714
|
}
|
|
688
715
|
else if (this.otherDeviceType === 'windowcovering') {
|
|
689
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
690
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
691
|
-
this.windowCoveringService?.updateCharacteristic(this.
|
|
716
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
|
|
717
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
|
|
718
|
+
this.windowCoveringService?.updateCharacteristic(this.hap.Characteristic.PositionState, e);
|
|
692
719
|
}
|
|
693
720
|
else if (this.otherDeviceType === 'lock') {
|
|
694
|
-
this.doorService?.updateCharacteristic(this.
|
|
695
|
-
this.doorService?.updateCharacteristic(this.
|
|
721
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.LockTargetState, e);
|
|
722
|
+
this.doorService?.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e);
|
|
696
723
|
}
|
|
697
724
|
else if (this.otherDeviceType === 'faucet') {
|
|
698
|
-
this.faucetService?.updateCharacteristic(this.
|
|
725
|
+
this.faucetService?.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
699
726
|
}
|
|
700
727
|
else if (this.otherDeviceType === 'fan') {
|
|
701
|
-
this.fanService?.updateCharacteristic(this.
|
|
728
|
+
this.fanService?.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
702
729
|
}
|
|
703
730
|
else if (this.otherDeviceType === 'stateful') {
|
|
704
|
-
this.statefulProgrammableSwitchService?.updateCharacteristic(this.
|
|
705
|
-
this.statefulProgrammableSwitchService?.updateCharacteristic(this.
|
|
731
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
732
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
706
733
|
}
|
|
707
734
|
else if (this.otherDeviceType === 'switch') {
|
|
708
|
-
this.switchService?.updateCharacteristic(this.
|
|
735
|
+
this.switchService?.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
709
736
|
}
|
|
710
737
|
else {
|
|
711
|
-
this.outletService?.updateCharacteristic(this.
|
|
738
|
+
this.outletService?.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
712
739
|
}
|
|
713
740
|
}
|
|
714
741
|
async removeOutletService(accessory) {
|
|
715
742
|
// If outletService still pressent, then remove first
|
|
716
|
-
this.outletService = this.accessory.getService(this.
|
|
743
|
+
this.outletService = this.accessory.getService(this.hap.Service.Outlet);
|
|
717
744
|
if (this.outletService) {
|
|
718
745
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
719
746
|
}
|
|
@@ -721,7 +748,7 @@ class Others {
|
|
|
721
748
|
}
|
|
722
749
|
async removeGarageDoorService(accessory) {
|
|
723
750
|
// If garageDoorService still pressent, then remove first
|
|
724
|
-
this.garageDoorService = this.accessory.getService(this.
|
|
751
|
+
this.garageDoorService = this.accessory.getService(this.hap.Service.GarageDoorOpener);
|
|
725
752
|
if (this.garageDoorService) {
|
|
726
753
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
727
754
|
}
|
|
@@ -729,7 +756,7 @@ class Others {
|
|
|
729
756
|
}
|
|
730
757
|
async removeDoorService(accessory) {
|
|
731
758
|
// If doorService still pressent, then remove first
|
|
732
|
-
this.doorService = this.accessory.getService(this.
|
|
759
|
+
this.doorService = this.accessory.getService(this.hap.Service.Door);
|
|
733
760
|
if (this.doorService) {
|
|
734
761
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
735
762
|
}
|
|
@@ -737,7 +764,7 @@ class Others {
|
|
|
737
764
|
}
|
|
738
765
|
async removeLockService(accessory) {
|
|
739
766
|
// If lockService still pressent, then remove first
|
|
740
|
-
this.lockService = this.accessory.getService(this.
|
|
767
|
+
this.lockService = this.accessory.getService(this.hap.Service.LockMechanism);
|
|
741
768
|
if (this.lockService) {
|
|
742
769
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
743
770
|
}
|
|
@@ -745,7 +772,7 @@ class Others {
|
|
|
745
772
|
}
|
|
746
773
|
async removeFaucetService(accessory) {
|
|
747
774
|
// If faucetService still pressent, then remove first
|
|
748
|
-
this.faucetService = this.accessory.getService(this.
|
|
775
|
+
this.faucetService = this.accessory.getService(this.hap.Service.Faucet);
|
|
749
776
|
if (this.faucetService) {
|
|
750
777
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
751
778
|
}
|
|
@@ -753,7 +780,7 @@ class Others {
|
|
|
753
780
|
}
|
|
754
781
|
async removeFanService(accessory) {
|
|
755
782
|
// If fanService still pressent, then remove first
|
|
756
|
-
this.fanService = this.accessory.getService(this.
|
|
783
|
+
this.fanService = this.accessory.getService(this.hap.Service.Fan);
|
|
757
784
|
if (this.fanService) {
|
|
758
785
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
759
786
|
}
|
|
@@ -761,7 +788,7 @@ class Others {
|
|
|
761
788
|
}
|
|
762
789
|
async removeWindowService(accessory) {
|
|
763
790
|
// If windowService still pressent, then remove first
|
|
764
|
-
this.windowService = this.accessory.getService(this.
|
|
791
|
+
this.windowService = this.accessory.getService(this.hap.Service.Window);
|
|
765
792
|
if (this.windowService) {
|
|
766
793
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
767
794
|
}
|
|
@@ -769,7 +796,7 @@ class Others {
|
|
|
769
796
|
}
|
|
770
797
|
async removeWindowCoveringService(accessory) {
|
|
771
798
|
// If windowCoveringService still pressent, then remove first
|
|
772
|
-
this.windowCoveringService = this.accessory.getService(this.
|
|
799
|
+
this.windowCoveringService = this.accessory.getService(this.hap.Service.WindowCovering);
|
|
773
800
|
if (this.windowCoveringService) {
|
|
774
801
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
775
802
|
}
|
|
@@ -777,7 +804,7 @@ class Others {
|
|
|
777
804
|
}
|
|
778
805
|
async removeStatefulProgrammableSwitchService(accessory) {
|
|
779
806
|
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
780
|
-
this.statefulProgrammableSwitchService = this.accessory.getService(this.
|
|
807
|
+
this.statefulProgrammableSwitchService = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch);
|
|
781
808
|
if (this.statefulProgrammableSwitchService) {
|
|
782
809
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
783
810
|
}
|
|
@@ -785,7 +812,7 @@ class Others {
|
|
|
785
812
|
}
|
|
786
813
|
async removeSwitchService(accessory) {
|
|
787
814
|
// If switchService still pressent, then remove first
|
|
788
|
-
this.switchService = this.accessory.getService(this.
|
|
815
|
+
this.switchService = this.accessory.getService(this.hap.Service.Switch);
|
|
789
816
|
if (this.switchService) {
|
|
790
817
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
791
818
|
}
|
|
@@ -819,7 +846,7 @@ class Others {
|
|
|
819
846
|
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
820
847
|
}
|
|
821
848
|
}
|
|
822
|
-
async
|
|
849
|
+
async deviceConfig(device) {
|
|
823
850
|
let config = {};
|
|
824
851
|
if (device.other) {
|
|
825
852
|
config = device.other;
|
|
@@ -852,7 +879,7 @@ class Others {
|
|
|
852
879
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
853
880
|
}
|
|
854
881
|
}
|
|
855
|
-
async
|
|
882
|
+
async deviceLogs(device) {
|
|
856
883
|
if (this.platform.debugMode) {
|
|
857
884
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
858
885
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
@@ -916,5 +943,4 @@ class Others {
|
|
|
916
943
|
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
917
944
|
}
|
|
918
945
|
}
|
|
919
|
-
exports.Others = Others;
|
|
920
946
|
//# sourceMappingURL=other.js.map
|