@switchbot/homebridge-switchbot 3.6.1-beta.1 → 3.6.1-beta.2
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 +11 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +35 -17
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -2
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +186 -396
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +35 -18
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +35 -18
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +35 -18
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +7 -5
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +35 -18
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +35 -16
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +35 -16
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +35 -16
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +35 -16
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +36 -17
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +35 -16
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +35 -16
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +35 -16
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +36 -17
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +35 -16
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +35 -16
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -0
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +186 -228
- package/dist/irdevice/other.js.map +1 -1
- package/dist/platform.js +2 -2
- package/dist/platform.js.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +32 -17
- package/src/device/bot.ts +179 -406
- package/src/device/ceilinglight.ts +32 -19
- package/src/device/colorbulb.ts +32 -19
- package/src/device/contact.ts +32 -19
- package/src/device/curtain.ts +7 -6
- package/src/device/fan.ts +32 -19
- package/src/device/hub.ts +32 -16
- package/src/device/humidifier.ts +32 -16
- package/src/device/iosensor.ts +32 -16
- package/src/device/lightstrip.ts +32 -16
- package/src/device/lock.ts +33 -17
- package/src/device/meter.ts +32 -16
- package/src/device/meterplus.ts +32 -16
- package/src/device/motion.ts +32 -16
- package/src/device/plug.ts +33 -17
- package/src/device/robotvacuumcleaner.ts +32 -16
- package/src/device/waterdetector.ts +32 -16
- package/src/irdevice/other.ts +214 -283
- package/src/platform.ts +2 -2
package/src/irdevice/other.ts
CHANGED
|
@@ -19,63 +19,55 @@ export class Others extends irdeviceBase {
|
|
|
19
19
|
private Switch?: {
|
|
20
20
|
Name: CharacteristicValue;
|
|
21
21
|
Service: Service;
|
|
22
|
-
On: CharacteristicValue;
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
private GarageDoor?: {
|
|
26
25
|
Name: CharacteristicValue;
|
|
27
26
|
Service: Service;
|
|
28
|
-
On: CharacteristicValue;
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
private Door?: {
|
|
32
30
|
Name: CharacteristicValue;
|
|
33
31
|
Service: Service;
|
|
34
|
-
On: CharacteristicValue;
|
|
35
32
|
};
|
|
36
33
|
|
|
37
34
|
private Window?: {
|
|
38
35
|
Name: CharacteristicValue;
|
|
39
36
|
Service: Service;
|
|
40
|
-
On: CharacteristicValue;
|
|
41
37
|
};
|
|
42
38
|
|
|
43
39
|
private WindowCovering?: {
|
|
44
40
|
Name: CharacteristicValue;
|
|
45
41
|
Service: Service;
|
|
46
|
-
On: CharacteristicValue;
|
|
47
42
|
};
|
|
48
43
|
|
|
49
44
|
private LockMechanism?: {
|
|
50
45
|
Name: CharacteristicValue;
|
|
51
46
|
Service: Service;
|
|
52
|
-
On: CharacteristicValue;
|
|
53
47
|
};
|
|
54
48
|
|
|
55
49
|
private Faucet?: {
|
|
56
50
|
Name: CharacteristicValue;
|
|
57
51
|
Service: Service;
|
|
58
|
-
On: CharacteristicValue;
|
|
59
52
|
};
|
|
60
53
|
|
|
61
54
|
private Fan?: {
|
|
62
55
|
Name: CharacteristicValue;
|
|
63
56
|
Service: Service;
|
|
64
|
-
On: CharacteristicValue;
|
|
65
57
|
};
|
|
66
58
|
|
|
67
59
|
private StatefulProgrammableSwitch?: {
|
|
68
60
|
Name: CharacteristicValue;
|
|
69
61
|
Service: Service;
|
|
70
|
-
On: CharacteristicValue;
|
|
71
62
|
};
|
|
72
63
|
|
|
73
64
|
private Outlet?: {
|
|
74
65
|
Name: CharacteristicValue;
|
|
75
66
|
Service: Service;
|
|
76
|
-
On: CharacteristicValue;
|
|
77
67
|
};
|
|
78
68
|
|
|
69
|
+
On!: boolean;
|
|
70
|
+
|
|
79
71
|
// Config
|
|
80
72
|
otherDeviceType?: string;
|
|
81
73
|
|
|
@@ -85,32 +77,27 @@ export class Others extends irdeviceBase {
|
|
|
85
77
|
device: irdevice & irDevicesConfig,
|
|
86
78
|
) {
|
|
87
79
|
super(platform, accessory, device);
|
|
88
|
-
// Set category
|
|
89
|
-
accessory.category = this.hap.Categories.OTHER;
|
|
90
80
|
|
|
91
81
|
// default placeholders
|
|
92
82
|
this.getOtherConfigSettings(device);
|
|
93
83
|
|
|
94
84
|
// deviceType
|
|
95
85
|
if (this.otherDeviceType === 'switch') {
|
|
86
|
+
// Set category
|
|
87
|
+
accessory.category = this.hap.Categories.SWITCH;
|
|
96
88
|
// Initialize Switch Service
|
|
97
89
|
accessory.context.Switch = accessory.context.Switch ?? {};
|
|
98
90
|
this.Switch = {
|
|
99
|
-
Name: accessory.context.Switch.Name ??
|
|
91
|
+
Name: accessory.context.Switch.Name ?? accessory.displayName,
|
|
100
92
|
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
|
|
101
|
-
On: accessory.context.On ?? false,
|
|
102
93
|
};
|
|
103
94
|
accessory.context.Switch = this.Switch as object;
|
|
104
|
-
this.
|
|
105
|
-
|
|
95
|
+
this.debugLog('Displaying as Switch');
|
|
96
|
+
// Initialize Switch Characteristics
|
|
106
97
|
this.Switch.Service
|
|
107
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
98
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name)
|
|
108
99
|
.getCharacteristic(this.hap.Characteristic.On)
|
|
109
|
-
.onGet(() => {
|
|
110
|
-
return this.Switch!.On;
|
|
111
|
-
})
|
|
112
100
|
.onSet(this.OnSet.bind(this));
|
|
113
|
-
|
|
114
101
|
// Remove other services
|
|
115
102
|
this.removeFanService(accessory);
|
|
116
103
|
this.removeLockService(accessory);
|
|
@@ -122,25 +109,28 @@ export class Others extends irdeviceBase {
|
|
|
122
109
|
this.removeWindowCoveringService(accessory);
|
|
123
110
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
124
111
|
} else if (this.otherDeviceType === 'garagedoor') {
|
|
125
|
-
//
|
|
112
|
+
// Set category
|
|
113
|
+
accessory.category = this.hap.Categories.GARAGE_DOOR_OPENER;
|
|
114
|
+
// Initialize GarageDoor Service
|
|
126
115
|
accessory.context.GarageDoor = accessory.context.GarageDoor ?? {};
|
|
127
116
|
this.GarageDoor = {
|
|
128
|
-
Name: accessory.context.GarageDoor.Name ??
|
|
117
|
+
Name: accessory.context.GarageDoor.Name ?? accessory.displayName,
|
|
129
118
|
Service: accessory.getService(this.hap.Service.GarageDoorOpener) ?? accessory.addService(this.hap.Service.GarageDoorOpener) as Service,
|
|
130
|
-
On: accessory.context.On ?? false,
|
|
131
119
|
};
|
|
132
120
|
accessory.context.GarageDoor = this.GarageDoor as object;
|
|
133
|
-
this.
|
|
134
|
-
|
|
121
|
+
this.debugLog('Displaying as Garage Door Opener');
|
|
122
|
+
// Initialize GarageDoor Characteristics
|
|
135
123
|
this.GarageDoor.Service
|
|
136
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
124
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.GarageDoor.Name)
|
|
137
125
|
.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false)
|
|
138
126
|
.getCharacteristic(this.hap.Characteristic.TargetDoorState)
|
|
139
|
-
.
|
|
140
|
-
|
|
127
|
+
.setProps({
|
|
128
|
+
validValues: [0, 100],
|
|
129
|
+
minValue: 0,
|
|
130
|
+
maxValue: 100,
|
|
131
|
+
minStep: 100,
|
|
141
132
|
})
|
|
142
133
|
.onSet(this.OnSet.bind(this));
|
|
143
|
-
|
|
144
134
|
// Remove other services
|
|
145
135
|
this.removeFanService(accessory);
|
|
146
136
|
this.removeLockService(accessory);
|
|
@@ -152,31 +142,27 @@ export class Others extends irdeviceBase {
|
|
|
152
142
|
this.removeWindowCoveringService(accessory);
|
|
153
143
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
154
144
|
} else if (this.otherDeviceType === 'door') {
|
|
145
|
+
// Set category
|
|
146
|
+
accessory.category = this.hap.Categories.DOOR;
|
|
155
147
|
// Initialize Door Service
|
|
156
148
|
accessory.context.Door = accessory.context.Door ?? {};
|
|
157
149
|
this.Door = {
|
|
158
|
-
Name: accessory.context.Door.Name ??
|
|
150
|
+
Name: accessory.context.Door.Name ?? accessory.displayName,
|
|
159
151
|
Service: accessory.getService(this.hap.Service.Door) ?? accessory.addService(this.hap.Service.Door) as Service,
|
|
160
|
-
On: accessory.context.On ?? false,
|
|
161
152
|
};
|
|
162
153
|
accessory.context.Door = this.Door as object;
|
|
163
|
-
this.
|
|
164
|
-
|
|
165
|
-
this.Door
|
|
166
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
154
|
+
this.debugLog('Displaying as Door');
|
|
155
|
+
// Initialize Door Characteristics
|
|
156
|
+
this.Door.Service
|
|
157
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Door.Name)
|
|
167
158
|
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
168
|
-
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
169
|
-
.setProps({
|
|
159
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
|
|
170
160
|
validValues: [0, 100],
|
|
171
161
|
minValue: 0,
|
|
172
162
|
maxValue: 100,
|
|
173
163
|
minStep: 100,
|
|
174
164
|
})
|
|
175
|
-
.onGet(() => {
|
|
176
|
-
return this.GarageDoor!.On;
|
|
177
|
-
})
|
|
178
165
|
.onSet(this.OnSet.bind(this));
|
|
179
|
-
|
|
180
166
|
// Remove other services
|
|
181
167
|
this.removeFanService(accessory);
|
|
182
168
|
this.removeLockService(accessory);
|
|
@@ -188,30 +174,27 @@ export class Others extends irdeviceBase {
|
|
|
188
174
|
this.removeWindowCoveringService(accessory);
|
|
189
175
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
190
176
|
} else if (this.otherDeviceType === 'window') {
|
|
177
|
+
// Set category
|
|
178
|
+
accessory.category = this.hap.Categories.WINDOW;
|
|
191
179
|
// Initialize Window Service
|
|
192
180
|
accessory.context.Window = accessory.context.Window ?? {};
|
|
193
181
|
this.Window = {
|
|
194
|
-
Name: accessory.context.Window.Name ??
|
|
182
|
+
Name: accessory.context.Window.Name ?? accessory.displayName,
|
|
195
183
|
Service: accessory.getService(this.hap.Service.Window) ?? accessory.addService(this.hap.Service.Window) as Service,
|
|
196
|
-
On: accessory.context.On ?? false,
|
|
197
184
|
};
|
|
198
185
|
accessory.context.Window = this.Window as object;
|
|
199
|
-
this.
|
|
200
|
-
|
|
201
|
-
this.Window
|
|
186
|
+
this.debugLog('Displaying as Window');
|
|
187
|
+
// Initialize Window Characteristics
|
|
188
|
+
this.Window.Service
|
|
189
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Window.Name)
|
|
202
190
|
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
203
|
-
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
204
|
-
.setProps({
|
|
191
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
|
|
205
192
|
validValues: [0, 100],
|
|
206
193
|
minValue: 0,
|
|
207
194
|
maxValue: 100,
|
|
208
195
|
minStep: 100,
|
|
209
196
|
})
|
|
210
|
-
.onGet(() => {
|
|
211
|
-
return this.GarageDoor!.On;
|
|
212
|
-
})
|
|
213
197
|
.onSet(this.OnSet.bind(this));
|
|
214
|
-
|
|
215
198
|
// Remove other services
|
|
216
199
|
this.removeFanService(accessory);
|
|
217
200
|
this.removeLockService(accessory);
|
|
@@ -223,18 +206,19 @@ export class Others extends irdeviceBase {
|
|
|
223
206
|
this.removeWindowCoveringService(accessory);
|
|
224
207
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
225
208
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
209
|
+
// Set category
|
|
210
|
+
accessory.category = this.hap.Categories.WINDOW_COVERING;
|
|
226
211
|
// Initialize WindowCovering Service
|
|
227
212
|
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {};
|
|
228
213
|
this.WindowCovering = {
|
|
229
|
-
Name: accessory.context.WindowCovering.Name ??
|
|
214
|
+
Name: accessory.context.WindowCovering.Name ?? accessory.displayName,
|
|
230
215
|
Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering) as Service,
|
|
231
|
-
On: accessory.context.On ?? false,
|
|
232
216
|
};
|
|
233
217
|
accessory.context.WindowCovering = this.WindowCovering as object;
|
|
234
|
-
this.
|
|
235
|
-
|
|
218
|
+
this.debugLog('Displaying as Window Covering');
|
|
219
|
+
// Initialize WindowCovering Characteristics
|
|
236
220
|
this.WindowCovering.Service
|
|
237
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
221
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.WindowCovering.Name)
|
|
238
222
|
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
239
223
|
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
240
224
|
.setProps({
|
|
@@ -243,11 +227,7 @@ export class Others extends irdeviceBase {
|
|
|
243
227
|
maxValue: 100,
|
|
244
228
|
minStep: 100,
|
|
245
229
|
})
|
|
246
|
-
.onGet(() => {
|
|
247
|
-
return this.WindowCovering!.On;
|
|
248
|
-
})
|
|
249
230
|
.onSet(this.OnSet.bind(this));
|
|
250
|
-
|
|
251
231
|
// Remove other services
|
|
252
232
|
this.removeFanService(accessory);
|
|
253
233
|
this.removeLockService(accessory);
|
|
@@ -259,24 +239,22 @@ export class Others extends irdeviceBase {
|
|
|
259
239
|
this.removeGarageDoorService(accessory);
|
|
260
240
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
261
241
|
} else if (this.otherDeviceType === 'lock') {
|
|
262
|
-
//
|
|
242
|
+
// Set category
|
|
243
|
+
accessory.category = this.hap.Categories.DOOR_LOCK;
|
|
244
|
+
// Initialize Lock Service
|
|
263
245
|
accessory.context.LockMechanism = accessory.context.LockMechanism ?? {};
|
|
264
246
|
this.LockMechanism = {
|
|
265
|
-
Name: accessory.context.LockMechanism.Name ??
|
|
247
|
+
Name: accessory.context.LockMechanism.Name ?? accessory.displayName,
|
|
266
248
|
Service: accessory.getService(this.hap.Service.LockMechanism) ?? accessory.addService(this.hap.Service.LockMechanism) as Service,
|
|
267
|
-
On: accessory.context.On ?? false,
|
|
268
249
|
};
|
|
269
250
|
accessory.context.LockMechanism = this.LockMechanism as object;
|
|
270
|
-
this.
|
|
271
|
-
|
|
251
|
+
this.debugLog('Displaying as Lock');
|
|
252
|
+
// Initialize Lock Characteristics
|
|
272
253
|
this.LockMechanism.Service
|
|
273
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
254
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.LockMechanism.Name)
|
|
255
|
+
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
274
256
|
.getCharacteristic(this.hap.Characteristic.LockTargetState)
|
|
275
|
-
.onGet(() => {
|
|
276
|
-
return this.LockMechanism!.On;
|
|
277
|
-
})
|
|
278
257
|
.onSet(this.OnSet.bind(this));
|
|
279
|
-
|
|
280
258
|
// Remove other services
|
|
281
259
|
this.removeFanService(accessory);
|
|
282
260
|
this.removeDoorService(accessory);
|
|
@@ -288,24 +266,21 @@ export class Others extends irdeviceBase {
|
|
|
288
266
|
this.removeWindowCoveringService(accessory);
|
|
289
267
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
290
268
|
} else if (this.otherDeviceType === 'faucet') {
|
|
269
|
+
// Set category
|
|
270
|
+
accessory.category = this.hap.Categories.FAUCET;
|
|
291
271
|
// Initialize Faucet Service
|
|
292
272
|
accessory.context.Faucet = accessory.context.Faucet ?? {};
|
|
293
273
|
this.Faucet = {
|
|
294
|
-
Name: accessory.context.Faucet.Name ??
|
|
274
|
+
Name: accessory.context.Faucet.Name ?? accessory.displayName,
|
|
295
275
|
Service: accessory.getService(this.hap.Service.Faucet) ?? accessory.addService(this.hap.Service.Faucet) as Service,
|
|
296
|
-
On: accessory.context.On ?? false,
|
|
297
276
|
};
|
|
298
277
|
accessory.context.Faucet = this.Faucet as object;
|
|
299
|
-
this.
|
|
300
|
-
|
|
278
|
+
this.debugLog('Displaying as Faucet');
|
|
279
|
+
// Initialize Faucet Characteristics
|
|
301
280
|
this.Faucet.Service
|
|
302
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
281
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Faucet.Name)
|
|
303
282
|
.getCharacteristic(this.hap.Characteristic.Active)
|
|
304
|
-
.onGet(() => {
|
|
305
|
-
return this.Faucet!.On;
|
|
306
|
-
})
|
|
307
283
|
.onSet(this.OnSet.bind(this));
|
|
308
|
-
|
|
309
284
|
// Remove other services
|
|
310
285
|
this.removeFanService(accessory);
|
|
311
286
|
this.removeLockService(accessory);
|
|
@@ -317,24 +292,21 @@ export class Others extends irdeviceBase {
|
|
|
317
292
|
this.removeWindowCoveringService(accessory);
|
|
318
293
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
319
294
|
} else if (this.otherDeviceType === 'fan') {
|
|
295
|
+
// Set category
|
|
296
|
+
accessory.category = this.hap.Categories.FAN;
|
|
320
297
|
// Initialize Fan Service
|
|
321
298
|
accessory.context.Fan = accessory.context.Fan ?? {};
|
|
322
299
|
this.Fan = {
|
|
323
|
-
Name: accessory.context.Fan.Name ??
|
|
300
|
+
Name: accessory.context.Fan.Name ?? accessory.displayName,
|
|
324
301
|
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2) as Service,
|
|
325
|
-
On: accessory.context.On ?? false,
|
|
326
302
|
};
|
|
327
303
|
accessory.context.Fan = this.Fan as object;
|
|
328
|
-
this.
|
|
329
|
-
|
|
304
|
+
this.debugLog('Displaying as Fan');
|
|
305
|
+
// Initialize Fan Characteristics
|
|
330
306
|
this.Fan.Service
|
|
331
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
332
|
-
.getCharacteristic(this.hap.Characteristic.
|
|
333
|
-
.onGet(() => {
|
|
334
|
-
return this.Fan!.On;
|
|
335
|
-
})
|
|
307
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name)
|
|
308
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
336
309
|
.onSet(this.OnSet.bind(this));
|
|
337
|
-
|
|
338
310
|
// Remove other services
|
|
339
311
|
this.removeLockService(accessory);
|
|
340
312
|
this.removeDoorService(accessory);
|
|
@@ -346,25 +318,22 @@ export class Others extends irdeviceBase {
|
|
|
346
318
|
this.removeWindowCoveringService(accessory);
|
|
347
319
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
348
320
|
} else if (this.otherDeviceType === 'stateful') {
|
|
321
|
+
// Set category
|
|
322
|
+
accessory.category = this.hap.Categories.PROGRAMMABLE_SWITCH;
|
|
349
323
|
// Initialize StatefulProgrammableSwitch Service
|
|
350
324
|
accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {};
|
|
351
325
|
this.StatefulProgrammableSwitch = {
|
|
352
|
-
Name: accessory.context.StatefulProgrammableSwitch.Name ??
|
|
326
|
+
Name: accessory.context.StatefulProgrammableSwitch.Name ?? accessory.displayName,
|
|
353
327
|
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
354
|
-
|
|
355
|
-
On: accessory.context.On ?? false,
|
|
328
|
+
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
356
329
|
};
|
|
357
330
|
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch as object;
|
|
358
|
-
this.
|
|
359
|
-
|
|
331
|
+
this.debugLog('Displaying as Stateful Programmable Switch');
|
|
332
|
+
// Initialize StatefulProgrammableSwitch Characteristics
|
|
360
333
|
this.StatefulProgrammableSwitch.Service
|
|
361
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
334
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.StatefulProgrammableSwitch.Name)
|
|
362
335
|
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
363
|
-
.onGet(() => {
|
|
364
|
-
return this.StatefulProgrammableSwitch!.On;
|
|
365
|
-
})
|
|
366
336
|
.onSet(this.OnSet.bind(this));
|
|
367
|
-
|
|
368
337
|
// Remove other services
|
|
369
338
|
this.removeFanService(accessory);
|
|
370
339
|
this.removeLockService(accessory);
|
|
@@ -375,25 +344,22 @@ export class Others extends irdeviceBase {
|
|
|
375
344
|
this.removeWindowService(accessory);
|
|
376
345
|
this.removeGarageDoorService(accessory);
|
|
377
346
|
this.removeWindowCoveringService(accessory);
|
|
378
|
-
} else {
|
|
379
|
-
//
|
|
347
|
+
} else if (this.otherDeviceType === 'outlet') {
|
|
348
|
+
// Set category
|
|
349
|
+
accessory.category = this.hap.Categories.OUTLET;
|
|
350
|
+
// Initialize Switch property
|
|
380
351
|
accessory.context.Outlet = accessory.context.Outlet ?? {};
|
|
381
352
|
this.Outlet = {
|
|
382
|
-
Name: accessory.context.Outlet.Name ??
|
|
353
|
+
Name: accessory.context.Outlet.Name ?? accessory.displayName,
|
|
383
354
|
Service: accessory.getService(this.hap.Service.Outlet) ?? accessory.addService(this.hap.Service.Outlet) as Service,
|
|
384
|
-
On: accessory.context.On ?? false,
|
|
385
355
|
};
|
|
386
356
|
accessory.context.Outlet = this.Outlet as object;
|
|
387
|
-
this.
|
|
388
|
-
|
|
357
|
+
this.debugLog('Displaying as Outlet');
|
|
358
|
+
// Initialize Outlet Characteristics
|
|
389
359
|
this.Outlet.Service
|
|
390
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
360
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Outlet.Name)
|
|
391
361
|
.getCharacteristic(this.hap.Characteristic.On)
|
|
392
|
-
.onGet(() => {
|
|
393
|
-
return this.Outlet!.On;
|
|
394
|
-
})
|
|
395
362
|
.onSet(this.OnSet.bind(this));
|
|
396
|
-
|
|
397
363
|
// Remove other services
|
|
398
364
|
this.removeFanService(accessory);
|
|
399
365
|
this.removeLockService(accessory);
|
|
@@ -404,6 +370,8 @@ export class Others extends irdeviceBase {
|
|
|
404
370
|
this.removeGarageDoorService(accessory);
|
|
405
371
|
this.removeWindowCoveringService(accessory);
|
|
406
372
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
373
|
+
} else {
|
|
374
|
+
this.errorLog('Device Type not set');
|
|
407
375
|
}
|
|
408
376
|
}
|
|
409
377
|
|
|
@@ -411,75 +379,57 @@ export class Others extends irdeviceBase {
|
|
|
411
379
|
* Handle requests to set the "On" characteristic
|
|
412
380
|
*/
|
|
413
381
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
382
|
+
if (this.otherDeviceType === 'switch') {
|
|
383
|
+
if (this.Switch) {
|
|
384
|
+
await this.debugLog(`Set On: ${value}`);
|
|
385
|
+
this.On = value === false ? false : true;
|
|
386
|
+
}
|
|
387
|
+
} else if (this.otherDeviceType === 'garagedoor') {
|
|
388
|
+
if (this.GarageDoor) {
|
|
389
|
+
await this.debugLog(`Set TargetDoorState: ${value}`);
|
|
390
|
+
this.On = value === this.hap.Characteristic.TargetDoorState.CLOSED ? false : true;
|
|
421
391
|
}
|
|
422
|
-
On = this.GarageDoor!.On;
|
|
423
392
|
} else if (this.otherDeviceType === 'door') {
|
|
424
|
-
this.
|
|
425
|
-
|
|
426
|
-
this.
|
|
427
|
-
} else {
|
|
428
|
-
this.Door!.On = true;
|
|
393
|
+
if (this.Door) {
|
|
394
|
+
await this.debugLog(`Set TargetPosition: ${value}`);
|
|
395
|
+
this.On = value === 0 ? false : true;
|
|
429
396
|
}
|
|
430
|
-
On = this.Door!.On;
|
|
431
397
|
} else if (this.otherDeviceType === 'window') {
|
|
432
|
-
this.
|
|
433
|
-
|
|
434
|
-
this.
|
|
435
|
-
} else {
|
|
436
|
-
this.Window!.On = true;
|
|
398
|
+
if (this.Window) {
|
|
399
|
+
await this.debugLog(`Set TargetPosition: ${value}`);
|
|
400
|
+
this.On = value === 0 ? false : true;
|
|
437
401
|
}
|
|
438
|
-
On = this.Window!.On;
|
|
439
402
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
440
|
-
this.
|
|
441
|
-
|
|
442
|
-
this.
|
|
443
|
-
} else {
|
|
444
|
-
this.WindowCovering!.On = true;
|
|
403
|
+
if (this.WindowCovering) {
|
|
404
|
+
await this.debugLog(`Set TargetPosition: ${value}`);
|
|
405
|
+
this.On = value === 0 ? false : true;
|
|
445
406
|
}
|
|
446
|
-
On = this.WindowCovering!.On;
|
|
447
407
|
} else if (this.otherDeviceType === 'lock') {
|
|
448
|
-
this.
|
|
449
|
-
|
|
450
|
-
this.
|
|
451
|
-
} else {
|
|
452
|
-
this.LockMechanism!.On = true;
|
|
408
|
+
if (this.LockMechanism) {
|
|
409
|
+
await this.debugLog(`Set LockTargetState: ${value}`);
|
|
410
|
+
this.On = value === this.hap.Characteristic.LockTargetState.SECURED ? false : true;
|
|
453
411
|
}
|
|
454
|
-
On = this.LockMechanism!.On;
|
|
455
412
|
} else if (this.otherDeviceType === 'faucet') {
|
|
456
|
-
this.
|
|
457
|
-
|
|
458
|
-
this.
|
|
459
|
-
} else {
|
|
460
|
-
this.Faucet!.On = true;
|
|
413
|
+
if (this.Faucet) {
|
|
414
|
+
await this.debugLog(`Set Active: ${value}`);
|
|
415
|
+
this.On = value === this.hap.Characteristic.Active.INACTIVE ? false : true;
|
|
461
416
|
}
|
|
462
|
-
On = this.Faucet!.On;
|
|
463
417
|
} else if (this.otherDeviceType === 'stateful') {
|
|
464
|
-
this.
|
|
465
|
-
|
|
466
|
-
this.
|
|
467
|
-
} else {
|
|
468
|
-
this.StatefulProgrammableSwitch!.On = true;
|
|
418
|
+
if (this.StatefulProgrammableSwitch) {
|
|
419
|
+
await this.debugLog(`Set ProgrammableSwitchOutputState: ${value}`);
|
|
420
|
+
this.On = value === 0 ? false : true;
|
|
469
421
|
}
|
|
470
|
-
|
|
471
|
-
On = this.StatefulProgrammableSwitch!.On;
|
|
472
422
|
} else {
|
|
473
|
-
this.
|
|
474
|
-
|
|
475
|
-
|
|
423
|
+
if (this.Outlet) {
|
|
424
|
+
await this.debugLog(`Set On: ${value}`);
|
|
425
|
+
this.On = value === false ? false : true;
|
|
426
|
+
}
|
|
476
427
|
}
|
|
477
|
-
|
|
478
428
|
//pushChanges
|
|
479
|
-
if (On === true) {
|
|
480
|
-
await this.pushOnChanges(On);
|
|
429
|
+
if (this.On === true) {
|
|
430
|
+
await this.pushOnChanges(this.On);
|
|
481
431
|
} else {
|
|
482
|
-
await this.pushOffChanges(On);
|
|
432
|
+
await this.pushOffChanges(this.On);
|
|
483
433
|
}
|
|
484
434
|
}
|
|
485
435
|
|
|
@@ -557,160 +507,151 @@ export class Others extends irdeviceBase {
|
|
|
557
507
|
|
|
558
508
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
559
509
|
await this.debugLog('updateHomeKitCharacteristics');
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
510
|
+
// State
|
|
511
|
+
if (this.otherDeviceType === 'switch' && this.Switch) {
|
|
512
|
+
if (this.On === undefined) {
|
|
513
|
+
await this.debugLog(`On: ${this.On}`);
|
|
514
|
+
} else {
|
|
515
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
516
|
+
await this.debugLog(`updateCharacteristic On: ${this.On}`);
|
|
517
|
+
}
|
|
518
|
+
} else if (this.otherDeviceType === 'garagedoor' && this.GarageDoor) {
|
|
519
|
+
if (this.On === undefined) {
|
|
520
|
+
await this.debugLog(`On: ${this.On}`);
|
|
563
521
|
} else {
|
|
564
|
-
if (this.
|
|
565
|
-
this.GarageDoor
|
|
566
|
-
this.GarageDoor
|
|
567
|
-
await this.debugLog(
|
|
568
|
-
+ ` TargetDoorState: Open, CurrentDoorState: Open (${this.GarageDoor!.On})`);
|
|
522
|
+
if (this.On) {
|
|
523
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.OPEN);
|
|
524
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.OPEN);
|
|
525
|
+
await this.debugLog(`updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open (${this.On})`);
|
|
569
526
|
} else {
|
|
570
|
-
this.GarageDoor
|
|
571
|
-
this.GarageDoor
|
|
572
|
-
await this.debugLog(
|
|
573
|
-
+ ` TargetDoorState: Closed, CurrentDoorState: Closed (${this.GarageDoor!.On})`);
|
|
527
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
|
|
528
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
|
|
529
|
+
await this.debugLog(`updateCharacteristicc TargetDoorState: Closed, CurrentDoorState: Closed (${this.On})`);
|
|
574
530
|
}
|
|
575
531
|
}
|
|
576
|
-
await this.debugLog(`Garage Door On: ${this.
|
|
577
|
-
} else if (this.otherDeviceType === 'door') {
|
|
578
|
-
if (this.
|
|
579
|
-
await this.debugLog(`On: ${this.
|
|
532
|
+
await this.debugLog(`Garage Door On: ${this.On}`);
|
|
533
|
+
} else if (this.otherDeviceType === 'door' && this.Door) {
|
|
534
|
+
if (this.On === undefined) {
|
|
535
|
+
await this.debugLog(`On: ${this.On}`);
|
|
580
536
|
} else {
|
|
581
|
-
if (this.
|
|
582
|
-
this.Door
|
|
583
|
-
this.Door
|
|
584
|
-
this.Door
|
|
585
|
-
await this.debugLog(
|
|
586
|
-
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Door!.On})`);
|
|
537
|
+
if (this.On) {
|
|
538
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
539
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
540
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
541
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`);
|
|
587
542
|
} else {
|
|
588
|
-
this.Door
|
|
589
|
-
this.Door
|
|
590
|
-
this.Door
|
|
591
|
-
await this.debugLog(
|
|
592
|
-
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Door!.On})`);
|
|
543
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
544
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
545
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
546
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`);
|
|
593
547
|
}
|
|
594
548
|
}
|
|
595
|
-
await this.debugLog(`Door On: ${this.
|
|
596
|
-
} else if (this.otherDeviceType === 'window') {
|
|
597
|
-
if (this.
|
|
598
|
-
await this.debugLog(`On: ${this.
|
|
549
|
+
await this.debugLog(`Door On: ${this.On}`);
|
|
550
|
+
} else if (this.otherDeviceType === 'window' && this.Window) {
|
|
551
|
+
if (this.On === undefined) {
|
|
552
|
+
await this.debugLog(`On: ${this.On}`);
|
|
599
553
|
} else {
|
|
600
|
-
if (this.
|
|
601
|
-
this.Window
|
|
602
|
-
this.Window
|
|
603
|
-
this.Window
|
|
604
|
-
await this.debugLog(
|
|
605
|
-
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.Window!.On})`);
|
|
554
|
+
if (this.On) {
|
|
555
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
556
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
557
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
558
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`);
|
|
606
559
|
} else {
|
|
607
|
-
this.Window
|
|
608
|
-
this.Window
|
|
609
|
-
this.Window
|
|
610
|
-
await this.debugLog(
|
|
611
|
-
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.Window!.On})`);
|
|
560
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
561
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
562
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
563
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`);
|
|
612
564
|
}
|
|
613
565
|
}
|
|
614
|
-
await this.debugLog(`Window On: ${this.
|
|
615
|
-
} else if (this.otherDeviceType === 'windowcovering') {
|
|
616
|
-
if (this.
|
|
617
|
-
await this.debugLog(`On: ${this.
|
|
566
|
+
await this.debugLog(`Window On: ${this.On}`);
|
|
567
|
+
} else if (this.otherDeviceType === 'windowcovering' && this.WindowCovering) {
|
|
568
|
+
if (this.On === undefined) {
|
|
569
|
+
await this.debugLog(`On: ${this.On}`);
|
|
618
570
|
} else {
|
|
619
|
-
if (this.
|
|
620
|
-
this.WindowCovering
|
|
621
|
-
this.WindowCovering
|
|
622
|
-
this.WindowCovering
|
|
623
|
-
await this.debugLog(
|
|
624
|
-
+ ` TargetPosition: 100, CurrentPosition: 100 (${this.WindowCovering!.On})`);
|
|
571
|
+
if (this.On) {
|
|
572
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
573
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
574
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
575
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`);
|
|
625
576
|
} else {
|
|
626
|
-
this.WindowCovering
|
|
627
|
-
this.WindowCovering
|
|
628
|
-
this.WindowCovering
|
|
629
|
-
await this.debugLog(
|
|
630
|
-
+ ` TargetPosition: 0, CurrentPosition: 0 (${this.WindowCovering!.On})`);
|
|
577
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
578
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
579
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
580
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`);
|
|
631
581
|
}
|
|
632
582
|
}
|
|
633
|
-
await this.debugLog(`Window Covering On: ${this.
|
|
634
|
-
} else if (this.otherDeviceType === 'lock') {
|
|
635
|
-
if (this.
|
|
636
|
-
await this.debugLog(`On: ${this.
|
|
583
|
+
await this.debugLog(`Window Covering On: ${this.On}`);
|
|
584
|
+
} else if (this.otherDeviceType === 'lock' && this.LockMechanism) {
|
|
585
|
+
if (this.On === undefined) {
|
|
586
|
+
await this.debugLog(`On: ${this.On}`);
|
|
637
587
|
} else {
|
|
638
|
-
if (this.
|
|
588
|
+
if (this.On) {
|
|
639
589
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState,
|
|
640
590
|
this.hap.Characteristic.LockTargetState.UNSECURED);
|
|
641
591
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState,
|
|
642
592
|
this.hap.Characteristic.LockCurrentState.UNSECURED);
|
|
643
|
-
await this.debugLog(
|
|
644
|
-
+ ` LockTargetState: UNSECURED, LockCurrentState: UNSECURE (${this.LockMechanism.On})`);
|
|
593
|
+
await this.debugLog(`updateCharacteristicc LockTargetState: UNSECURED, LockCurrentState: UNSECURED (${this.On})`);
|
|
645
594
|
} else {
|
|
646
595
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState,
|
|
647
596
|
this.hap.Characteristic.LockTargetState.SECURED);
|
|
648
597
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState,
|
|
649
598
|
this.hap.Characteristic.LockCurrentState.SECURED);
|
|
650
|
-
await this.debugLog(
|
|
651
|
-
+ ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.LockMechanism.On})`);
|
|
599
|
+
await this.debugLog(`updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED (${this.On})`);
|
|
652
600
|
}
|
|
653
601
|
}
|
|
654
|
-
await this.debugLog(`Lock On: ${this.
|
|
655
|
-
} else if (this.otherDeviceType === 'faucet') {
|
|
656
|
-
if (this.
|
|
657
|
-
await this.debugLog(`On: ${this.
|
|
602
|
+
await this.debugLog(`Lock On: ${this.On}`);
|
|
603
|
+
} else if (this.otherDeviceType === 'faucet' && this.Faucet) {
|
|
604
|
+
if (this.On === undefined) {
|
|
605
|
+
await this.debugLog(`On: ${this.On}`);
|
|
658
606
|
} else {
|
|
659
|
-
if (this.
|
|
660
|
-
this.Faucet
|
|
661
|
-
await this.debugLog(`updateCharacteristic Active: ${this.
|
|
607
|
+
if (this.On) {
|
|
608
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
|
|
609
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`);
|
|
662
610
|
} else {
|
|
663
|
-
this.Faucet
|
|
664
|
-
await this.debugLog(`updateCharacteristic Active: ${this.
|
|
611
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
612
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`);
|
|
665
613
|
}
|
|
666
614
|
}
|
|
667
|
-
await this.debugLog(`Faucet On: ${this.
|
|
668
|
-
} else if (this.otherDeviceType === 'fan') {
|
|
669
|
-
if (this.
|
|
670
|
-
await this.debugLog(`On: ${this.
|
|
615
|
+
await this.debugLog(`Faucet On: ${this.On}`);
|
|
616
|
+
} else if (this.otherDeviceType === 'fan' && this.Fan) {
|
|
617
|
+
if (this.On === undefined) {
|
|
618
|
+
await this.debugLog(`On: ${this.On}`);
|
|
671
619
|
} else {
|
|
672
|
-
if (this.
|
|
673
|
-
this.Fan
|
|
674
|
-
await this.debugLog(`updateCharacteristic
|
|
620
|
+
if (this.On) {
|
|
621
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
|
|
622
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`);
|
|
675
623
|
} else {
|
|
676
|
-
this.Fan
|
|
677
|
-
await this.debugLog(`updateCharacteristic
|
|
624
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
625
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`);
|
|
678
626
|
}
|
|
679
627
|
}
|
|
680
|
-
await this.debugLog(`Fan On: ${this.
|
|
681
|
-
} else if (this.otherDeviceType === 'stateful') {
|
|
682
|
-
if (this.
|
|
683
|
-
await this.debugLog(`On: ${this.
|
|
628
|
+
await this.debugLog(`Fan On: ${this.On}`);
|
|
629
|
+
} else if (this.otherDeviceType === 'stateful' && this.StatefulProgrammableSwitch) {
|
|
630
|
+
if (this.On === undefined) {
|
|
631
|
+
await this.debugLog(`On: ${this.On}`);
|
|
684
632
|
} else {
|
|
685
|
-
if (this.
|
|
686
|
-
this.StatefulProgrammableSwitch
|
|
633
|
+
if (this.On) {
|
|
634
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
687
635
|
this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
688
|
-
this.StatefulProgrammableSwitch
|
|
689
|
-
await this.debugLog(
|
|
690
|
-
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1 (${this.StatefulProgrammableSwitch!.On})`);
|
|
636
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
637
|
+
await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.On})`);
|
|
691
638
|
} else {
|
|
692
|
-
this.StatefulProgrammableSwitch
|
|
639
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
693
640
|
this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
694
|
-
this.StatefulProgrammableSwitch
|
|
695
|
-
await this.debugLog(
|
|
696
|
-
+ ` ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0 (${this.StatefulProgrammableSwitch!.On})`);
|
|
641
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
642
|
+
await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.On})`);
|
|
697
643
|
}
|
|
698
644
|
}
|
|
699
|
-
await this.debugLog(`StatefulProgrammableSwitch On: ${this.
|
|
700
|
-
} else if (this.otherDeviceType === '
|
|
701
|
-
if (this.
|
|
702
|
-
await this.debugLog(`On: ${this.
|
|
645
|
+
await this.debugLog(`StatefulProgrammableSwitch On: ${this.On}`);
|
|
646
|
+
} else if (this.otherDeviceType === 'outlet' && this.Outlet) {
|
|
647
|
+
if (this.On === undefined) {
|
|
648
|
+
await this.debugLog(`On: ${this.On}`);
|
|
703
649
|
} else {
|
|
704
|
-
this.
|
|
705
|
-
await this.debugLog(`updateCharacteristic On: ${this.
|
|
650
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
651
|
+
await this.debugLog(`updateCharacteristic On: ${this.On}`);
|
|
706
652
|
}
|
|
707
653
|
} else {
|
|
708
|
-
|
|
709
|
-
await this.debugLog(`On: ${this.Outlet!.On}`);
|
|
710
|
-
} else {
|
|
711
|
-
this.Outlet!.Service.updateCharacteristic(this.hap.Characteristic.On, this.Outlet!.On);
|
|
712
|
-
await this.debugLog(`updateCharacteristic On: ${this.Outlet!.On}`);
|
|
713
|
-
}
|
|
654
|
+
await this.errorLog(`otherDeviceType: ${this.otherDeviceType}, On: ${this.On}`);
|
|
714
655
|
}
|
|
715
656
|
}
|
|
716
657
|
|
|
@@ -774,7 +715,6 @@ export class Others extends irdeviceBase {
|
|
|
774
715
|
this.Outlet = {
|
|
775
716
|
Name: accessory.context.Outlet.Name ?? `${accessory.displayName} Outlet`,
|
|
776
717
|
Service: accessory.getService(this.hap.Service.Outlet) as Service,
|
|
777
|
-
On: accessory.context.On ?? false,
|
|
778
718
|
};
|
|
779
719
|
accessory.context.Outlet = this.Outlet as object;
|
|
780
720
|
this.warnLog('Removing any leftover Outlet Service');
|
|
@@ -787,7 +727,6 @@ export class Others extends irdeviceBase {
|
|
|
787
727
|
this.GarageDoor = {
|
|
788
728
|
Name: accessory.context.GarageDoor.Name ?? `${accessory.displayName} Garage Door`,
|
|
789
729
|
Service: accessory.getService(this.hap.Service.GarageDoorOpener) as Service,
|
|
790
|
-
On: accessory.context.On ?? false,
|
|
791
730
|
};
|
|
792
731
|
accessory.context.GarageDoor = this.GarageDoor as object;
|
|
793
732
|
this.warnLog('Removing any leftover Garage Door Service');
|
|
@@ -800,7 +739,6 @@ export class Others extends irdeviceBase {
|
|
|
800
739
|
this.Door = {
|
|
801
740
|
Name: accessory.context.Door.Name ?? `${accessory.displayName} Door`,
|
|
802
741
|
Service: accessory.getService(this.hap.Service.Door) as Service,
|
|
803
|
-
On: accessory.context.On ?? false,
|
|
804
742
|
};
|
|
805
743
|
accessory.context.Door = this.Door as object;
|
|
806
744
|
this.warnLog('Removing any leftover Door Service');
|
|
@@ -813,7 +751,6 @@ export class Others extends irdeviceBase {
|
|
|
813
751
|
this.LockMechanism = {
|
|
814
752
|
Name: accessory.context.LockMechanism.Name ?? `${accessory.displayName} Lock`,
|
|
815
753
|
Service: accessory.getService(this.hap.Service.LockMechanism) as Service,
|
|
816
|
-
On: accessory.context.On ?? false,
|
|
817
754
|
};
|
|
818
755
|
accessory.context.LockMechanism = this.LockMechanism as object;
|
|
819
756
|
this.warnLog('Removing any leftover Lock Service');
|
|
@@ -826,7 +763,6 @@ export class Others extends irdeviceBase {
|
|
|
826
763
|
this.Faucet = {
|
|
827
764
|
Name: accessory.context.Faucet.Name ?? `${accessory.displayName} Faucet`,
|
|
828
765
|
Service: accessory.getService(this.hap.Service.Faucet) as Service,
|
|
829
|
-
On: accessory.context.On ?? false,
|
|
830
766
|
};
|
|
831
767
|
accessory.context.Faucet = this.Faucet as object;
|
|
832
768
|
this.warnLog('Removing any leftover Faucet Service');
|
|
@@ -839,7 +775,6 @@ export class Others extends irdeviceBase {
|
|
|
839
775
|
this.Fan = {
|
|
840
776
|
Name: accessory.context.Fan.Name ?? `${accessory.displayName} Fan`,
|
|
841
777
|
Service: accessory.getService(this.hap.Service.Fanv2) as Service,
|
|
842
|
-
On: accessory.context.On ?? false,
|
|
843
778
|
};
|
|
844
779
|
accessory.context.Fan = this.Fan as object;
|
|
845
780
|
this.warnLog('Removing any leftover Fan Service');
|
|
@@ -852,7 +787,6 @@ export class Others extends irdeviceBase {
|
|
|
852
787
|
this.Window = {
|
|
853
788
|
Name: accessory.context.Window.Name ?? `${accessory.displayName} Window`,
|
|
854
789
|
Service: accessory.getService(this.hap.Service.Window) as Service,
|
|
855
|
-
On: accessory.context.On ?? false,
|
|
856
790
|
};
|
|
857
791
|
accessory.context.Window = this.Window as object;
|
|
858
792
|
this.warnLog('Removing any leftover Window Service');
|
|
@@ -865,7 +799,6 @@ export class Others extends irdeviceBase {
|
|
|
865
799
|
this.WindowCovering = {
|
|
866
800
|
Name: accessory.context.WindowCovering.Name ?? `${accessory.displayName} Window Covering`,
|
|
867
801
|
Service: accessory.getService(this.hap.Service.WindowCovering) as Service,
|
|
868
|
-
On: accessory.context.On ?? false,
|
|
869
802
|
};
|
|
870
803
|
accessory.context.WindowCovering = this.WindowCovering as object;
|
|
871
804
|
this.warnLog('Removing any leftover Window Covering Service');
|
|
@@ -878,7 +811,6 @@ export class Others extends irdeviceBase {
|
|
|
878
811
|
this.StatefulProgrammableSwitch = {
|
|
879
812
|
Name: accessory.context.StatefulProgrammableSwitch.Name ?? `${accessory.displayName} Stateful Programmable Switch`,
|
|
880
813
|
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
881
|
-
On: accessory.context.On ?? false,
|
|
882
814
|
};
|
|
883
815
|
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch as object;
|
|
884
816
|
this.warnLog('Removing any leftover Stateful Programmable Switch Service');
|
|
@@ -891,7 +823,6 @@ export class Others extends irdeviceBase {
|
|
|
891
823
|
this.Switch = {
|
|
892
824
|
Name: accessory.context.Switch.Name ?? `${accessory.displayName} Switch`,
|
|
893
825
|
Service: accessory.getService(this.hap.Service.Switch) as Service,
|
|
894
|
-
On: accessory.context.On ?? false,
|
|
895
826
|
};
|
|
896
827
|
accessory.context.Switch = this.Switch as object;
|
|
897
828
|
this.warnLog('Removing any leftover Switch Service');
|