@switchbot/homebridge-switchbot 2.8.2 → 2.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/npm-version-script.js +81 -0
- package/CHANGELOG.md +9 -0
- package/config.schema.json +37 -1
- package/dist/device/bot.d.ts +2 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +48 -37
- package/dist/device/bot.js.map +1 -1
- package/dist/irdevice/other.d.ts +24 -2
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +574 -38
- package/dist/irdevice/other.js.map +1 -1
- package/package.json +4 -4
- package/src/device/bot.ts +49 -37
- package/src/irdevice/other.ts +607 -39
package/src/irdevice/other.ts
CHANGED
|
@@ -11,9 +11,18 @@ import { Devices, irDevicesConfig, irdevice } from '../settings';
|
|
|
11
11
|
export class Others {
|
|
12
12
|
// Services
|
|
13
13
|
fanService?: Service;
|
|
14
|
+
doorService?: Service;
|
|
15
|
+
lockService?: Service;
|
|
16
|
+
faucetService?: Service;
|
|
17
|
+
windowService?: Service;
|
|
18
|
+
switchService?: Service;
|
|
19
|
+
outletService?: Service;
|
|
20
|
+
garageDoorService?: Service;
|
|
21
|
+
windowCoveringService?: Service;
|
|
22
|
+
statefulProgrammableSwitchService?: Service;
|
|
14
23
|
|
|
15
24
|
// Characteristic Values
|
|
16
|
-
|
|
25
|
+
On?: CharacteristicValue;
|
|
17
26
|
FirmwareRevision!: CharacteristicValue;
|
|
18
27
|
|
|
19
28
|
// Config
|
|
@@ -45,39 +54,300 @@ export class Others {
|
|
|
45
54
|
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
46
55
|
.updateValue(this.setFirmwareRevision(accessory, device));
|
|
47
56
|
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
// deviceType
|
|
58
|
+
if (this.otherDeviceType === 'switch') {
|
|
59
|
+
this.removeFanService(accessory);
|
|
60
|
+
this.removeLockService(accessory);
|
|
61
|
+
this.removeDoorService(accessory);
|
|
62
|
+
this.removeFaucetService(accessory);
|
|
63
|
+
this.removeOutletService(accessory);
|
|
64
|
+
this.removeWindowService(accessory);
|
|
65
|
+
this.removeGarageDoorService(accessory);
|
|
66
|
+
this.removeWindowCoveringService(accessory);
|
|
67
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
68
|
+
|
|
69
|
+
// Add switchService
|
|
70
|
+
(this.switchService = accessory.getService(this.platform.Service.Switch) || accessory.addService(this.platform.Service.Switch)),
|
|
71
|
+
`${accessory.displayName} Switch`;
|
|
72
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Switch`);
|
|
73
|
+
|
|
74
|
+
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
75
|
+
if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
76
|
+
this.switchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
77
|
+
}
|
|
78
|
+
this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
79
|
+
} else if (this.otherDeviceType === 'garagedoor') {
|
|
80
|
+
this.removeFanService(accessory);
|
|
81
|
+
this.removeLockService(accessory);
|
|
82
|
+
this.removeDoorService(accessory);
|
|
83
|
+
this.removeFaucetService(accessory);
|
|
84
|
+
this.removeOutletService(accessory);
|
|
85
|
+
this.removeSwitchService(accessory);
|
|
86
|
+
this.removeWindowService(accessory);
|
|
87
|
+
this.removeWindowCoveringService(accessory);
|
|
88
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
89
|
+
|
|
90
|
+
// Add switchService
|
|
91
|
+
(this.garageDoorService =
|
|
92
|
+
accessory.getService(this.platform.Service.GarageDoorOpener) || accessory.addService(this.platform.Service.GarageDoorOpener)),
|
|
93
|
+
`${accessory.displayName} Garage Door Opener`;
|
|
94
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
95
|
+
|
|
96
|
+
this.garageDoorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
97
|
+
if (!this.garageDoorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
98
|
+
this.garageDoorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
99
|
+
}
|
|
100
|
+
this.garageDoorService.getCharacteristic(this.platform.Characteristic.TargetDoorState).onSet(this.OnSet.bind(this));
|
|
101
|
+
this.garageDoorService.setCharacteristic(this.platform.Characteristic.ObstructionDetected, false);
|
|
102
|
+
} else if (this.otherDeviceType === 'door') {
|
|
103
|
+
this.removeFanService(accessory);
|
|
104
|
+
this.removeLockService(accessory);
|
|
105
|
+
this.removeOutletService(accessory);
|
|
106
|
+
this.removeFaucetService(accessory);
|
|
107
|
+
this.removeSwitchService(accessory);
|
|
108
|
+
this.removeWindowService(accessory);
|
|
109
|
+
this.removeGarageDoorService(accessory);
|
|
110
|
+
this.removeWindowCoveringService(accessory);
|
|
111
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
112
|
+
|
|
113
|
+
// Add switchService
|
|
114
|
+
(this.doorService = accessory.getService(this.platform.Service.Door) || accessory.addService(this.platform.Service.Door)),
|
|
115
|
+
`${accessory.displayName} Door`;
|
|
116
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Door`);
|
|
117
|
+
|
|
118
|
+
this.doorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
119
|
+
if (!this.doorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
120
|
+
this.doorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
121
|
+
}
|
|
122
|
+
this.doorService
|
|
123
|
+
.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
124
|
+
.setProps({
|
|
125
|
+
validValues: [0, 100],
|
|
126
|
+
minValue: 0,
|
|
127
|
+
maxValue: 100,
|
|
128
|
+
minStep: 100,
|
|
129
|
+
})
|
|
130
|
+
.onSet(this.OnSet.bind(this));
|
|
131
|
+
this.doorService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
132
|
+
} else if (this.otherDeviceType === 'window') {
|
|
133
|
+
this.removeFanService(accessory);
|
|
134
|
+
this.removeLockService(accessory);
|
|
135
|
+
this.removeDoorService(accessory);
|
|
136
|
+
this.removeOutletService(accessory);
|
|
137
|
+
this.removeFaucetService(accessory);
|
|
138
|
+
this.removeSwitchService(accessory);
|
|
139
|
+
this.removeGarageDoorService(accessory);
|
|
140
|
+
this.removeWindowCoveringService(accessory);
|
|
141
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
142
|
+
|
|
143
|
+
// Add switchService
|
|
144
|
+
(this.windowService = accessory.getService(this.platform.Service.Window) || accessory.addService(this.platform.Service.Window)),
|
|
145
|
+
`${accessory.displayName} Window`;
|
|
146
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window`);
|
|
147
|
+
|
|
148
|
+
this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
149
|
+
if (!this.windowService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
150
|
+
this.windowService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
151
|
+
}
|
|
152
|
+
this.windowService
|
|
153
|
+
.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
154
|
+
.setProps({
|
|
155
|
+
validValues: [0, 100],
|
|
156
|
+
minValue: 0,
|
|
157
|
+
maxValue: 100,
|
|
158
|
+
minStep: 100,
|
|
159
|
+
})
|
|
160
|
+
.onSet(this.OnSet.bind(this));
|
|
161
|
+
this.windowService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
162
|
+
} else if (this.otherDeviceType === 'windowcovering') {
|
|
163
|
+
this.removeFanService(accessory);
|
|
164
|
+
this.removeLockService(accessory);
|
|
165
|
+
this.removeDoorService(accessory);
|
|
166
|
+
this.removeOutletService(accessory);
|
|
167
|
+
this.removeFaucetService(accessory);
|
|
168
|
+
this.removeSwitchService(accessory);
|
|
169
|
+
this.removeWindowService(accessory);
|
|
170
|
+
this.removeGarageDoorService(accessory);
|
|
171
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
172
|
+
|
|
173
|
+
// Add switchService
|
|
174
|
+
(this.windowCoveringService =
|
|
175
|
+
accessory.getService(this.platform.Service.WindowCovering) || accessory.addService(this.platform.Service.WindowCovering)),
|
|
176
|
+
`${accessory.displayName} Window Covering`;
|
|
177
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
178
|
+
|
|
179
|
+
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
180
|
+
if (!this.windowCoveringService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
181
|
+
this.windowCoveringService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
182
|
+
}
|
|
183
|
+
this.windowCoveringService
|
|
184
|
+
.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
185
|
+
.setProps({
|
|
186
|
+
validValues: [0, 100],
|
|
187
|
+
minValue: 0,
|
|
188
|
+
maxValue: 100,
|
|
189
|
+
minStep: 100,
|
|
190
|
+
})
|
|
191
|
+
.onSet(this.OnSet.bind(this));
|
|
192
|
+
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
193
|
+
} else if (this.otherDeviceType === 'lock') {
|
|
194
|
+
this.removeFanService(accessory);
|
|
195
|
+
this.removeDoorService(accessory);
|
|
196
|
+
this.removeOutletService(accessory);
|
|
197
|
+
this.removeSwitchService(accessory);
|
|
198
|
+
this.removeFaucetService(accessory);
|
|
199
|
+
this.removeWindowService(accessory);
|
|
200
|
+
this.removeGarageDoorService(accessory);
|
|
201
|
+
this.removeWindowCoveringService(accessory);
|
|
202
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
203
|
+
|
|
204
|
+
// Add switchService
|
|
205
|
+
(this.lockService = accessory.getService(this.platform.Service.LockMechanism) || accessory.addService(this.platform.Service.LockMechanism)),
|
|
206
|
+
`${accessory.displayName} Lock`;
|
|
207
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Lock`);
|
|
208
|
+
|
|
209
|
+
this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
210
|
+
if (!this.lockService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
211
|
+
this.lockService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
55
212
|
}
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.
|
|
60
|
-
|
|
213
|
+
this.lockService.getCharacteristic(this.platform.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
|
|
214
|
+
} else if (this.otherDeviceType === 'faucet') {
|
|
215
|
+
this.removeFanService(accessory);
|
|
216
|
+
this.removeLockService(accessory);
|
|
217
|
+
this.removeDoorService(accessory);
|
|
218
|
+
this.removeOutletService(accessory);
|
|
219
|
+
this.removeSwitchService(accessory);
|
|
220
|
+
this.removeWindowService(accessory);
|
|
221
|
+
this.removeGarageDoorService(accessory);
|
|
222
|
+
this.removeWindowCoveringService(accessory);
|
|
223
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
224
|
+
|
|
225
|
+
// Add switchService
|
|
226
|
+
(this.faucetService = accessory.getService(this.platform.Service.Faucet) || accessory.addService(this.platform.Service.Faucet)),
|
|
227
|
+
`${accessory.displayName} Faucet`;
|
|
228
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Faucet`);
|
|
229
|
+
|
|
230
|
+
this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
231
|
+
if (!this.faucetService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
232
|
+
this.faucetService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
233
|
+
}
|
|
234
|
+
this.faucetService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.OnSet.bind(this));
|
|
235
|
+
} else if (this.otherDeviceType === 'fan') {
|
|
236
|
+
this.removeLockService(accessory);
|
|
237
|
+
this.removeDoorService(accessory);
|
|
238
|
+
this.removeFaucetService(accessory);
|
|
239
|
+
this.removeOutletService(accessory);
|
|
240
|
+
this.removeSwitchService(accessory);
|
|
241
|
+
this.removeWindowService(accessory);
|
|
242
|
+
this.removeGarageDoorService(accessory);
|
|
243
|
+
this.removeWindowCoveringService(accessory);
|
|
244
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
245
|
+
|
|
246
|
+
// Add switchService
|
|
247
|
+
(this.fanService = accessory.getService(this.platform.Service.Fan) || accessory.addService(this.platform.Service.Fan)),
|
|
61
248
|
`${accessory.displayName} Fan`;
|
|
249
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Fan`);
|
|
62
250
|
|
|
63
|
-
this.fanService.setCharacteristic(this.platform.Characteristic.Name,
|
|
251
|
+
this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
64
252
|
if (!this.fanService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
65
|
-
this.fanService.addCharacteristic(this.platform.Characteristic.ConfiguredName,
|
|
253
|
+
this.fanService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
254
|
+
}
|
|
255
|
+
this.fanService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
256
|
+
} else if (this.otherDeviceType === 'stateful') {
|
|
257
|
+
this.removeFanService(accessory);
|
|
258
|
+
this.removeLockService(accessory);
|
|
259
|
+
this.removeDoorService(accessory);
|
|
260
|
+
this.removeFaucetService(accessory);
|
|
261
|
+
this.removeOutletService(accessory);
|
|
262
|
+
this.removeSwitchService(accessory);
|
|
263
|
+
this.removeWindowService(accessory);
|
|
264
|
+
this.removeGarageDoorService(accessory);
|
|
265
|
+
this.removeWindowCoveringService(accessory);
|
|
266
|
+
|
|
267
|
+
// Add switchService
|
|
268
|
+
(this.statefulProgrammableSwitchService =
|
|
269
|
+
accessory.getService(this.platform.Service.StatefulProgrammableSwitch) ||
|
|
270
|
+
accessory.addService(this.platform.Service.StatefulProgrammableSwitch)),
|
|
271
|
+
`${accessory.displayName} Stateful Programmable Switch`;
|
|
272
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
273
|
+
|
|
274
|
+
this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
275
|
+
if (!this.statefulProgrammableSwitchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
276
|
+
this.statefulProgrammableSwitchService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
66
277
|
}
|
|
67
|
-
this.
|
|
278
|
+
this.statefulProgrammableSwitchService
|
|
279
|
+
.getCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState)
|
|
280
|
+
.onSet(this.OnSet.bind(this));
|
|
68
281
|
} else {
|
|
69
|
-
this.
|
|
282
|
+
this.removeFanService(accessory);
|
|
283
|
+
this.removeLockService(accessory);
|
|
284
|
+
this.removeDoorService(accessory);
|
|
285
|
+
this.removeFaucetService(accessory);
|
|
286
|
+
this.removeSwitchService(accessory);
|
|
287
|
+
this.removeWindowService(accessory);
|
|
288
|
+
this.removeGarageDoorService(accessory);
|
|
289
|
+
this.removeWindowCoveringService(accessory);
|
|
290
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
291
|
+
|
|
292
|
+
// Add outletService
|
|
293
|
+
(this.outletService = accessory.getService(this.platform.Service.Outlet) || accessory.addService(this.platform.Service.Outlet)),
|
|
294
|
+
`${accessory.displayName} Outlet`;
|
|
295
|
+
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Outlet`);
|
|
296
|
+
|
|
297
|
+
this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
298
|
+
if (!this.outletService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
299
|
+
this.outletService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
300
|
+
}
|
|
301
|
+
this.outletService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
70
302
|
}
|
|
71
303
|
}
|
|
72
304
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (this.
|
|
78
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Handle requests to set the "On" characteristic
|
|
307
|
+
*/
|
|
308
|
+
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
309
|
+
if (this.otherDeviceType === 'garagedoor') {
|
|
310
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetDoorState: ${value}`);
|
|
311
|
+
if (value === this.platform.Characteristic.TargetDoorState.CLOSED) {
|
|
312
|
+
this.On = false;
|
|
313
|
+
} else {
|
|
314
|
+
this.On = true;
|
|
315
|
+
}
|
|
316
|
+
} else if (
|
|
317
|
+
this.otherDeviceType === 'door' ||
|
|
318
|
+
this.otherDeviceType === 'window' ||
|
|
319
|
+
this.otherDeviceType === 'windowcovering'
|
|
320
|
+
) {
|
|
321
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
|
|
322
|
+
if (value === 0) {
|
|
323
|
+
this.On = false;
|
|
324
|
+
} else {
|
|
325
|
+
this.On = true;
|
|
326
|
+
}
|
|
327
|
+
} else if (this.otherDeviceType === 'lock') {
|
|
328
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
|
|
329
|
+
if (value === this.platform.Characteristic.LockTargetState.SECURED) {
|
|
330
|
+
this.On = false;
|
|
331
|
+
} else {
|
|
332
|
+
this.On = true;
|
|
333
|
+
}
|
|
334
|
+
} else if (this.otherDeviceType === 'faucet') {
|
|
335
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
336
|
+
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
337
|
+
this.On = false;
|
|
338
|
+
} else {
|
|
339
|
+
this.On = true;
|
|
340
|
+
}
|
|
341
|
+
} else if (this.otherDeviceType === 'stateful') {
|
|
342
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set ProgrammableSwitchOutputState: ${value}`);
|
|
343
|
+
if (value === 0) {
|
|
344
|
+
this.On = false;
|
|
345
|
+
} else {
|
|
346
|
+
this.On = true;
|
|
347
|
+
}
|
|
79
348
|
} else {
|
|
80
|
-
|
|
349
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Set On: ${value}`);
|
|
350
|
+
this.On = value;
|
|
81
351
|
}
|
|
82
352
|
}
|
|
83
353
|
|
|
@@ -93,11 +363,11 @@ export class Others {
|
|
|
93
363
|
*/
|
|
94
364
|
async pushOnChanges(): Promise<void> {
|
|
95
365
|
this.debugLog(
|
|
96
|
-
`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges
|
|
366
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${this.On},` +
|
|
97
367
|
` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`,
|
|
98
368
|
);
|
|
99
369
|
if (this.device.customize) {
|
|
100
|
-
if (this.
|
|
370
|
+
if (this.On && !this.disablePushOn) {
|
|
101
371
|
const commandType: string = await this.commandType();
|
|
102
372
|
const command: string = await this.commandOn();
|
|
103
373
|
const bodyChange = JSON.stringify({
|
|
@@ -114,11 +384,11 @@ export class Others {
|
|
|
114
384
|
|
|
115
385
|
async pushOffChanges(): Promise<void> {
|
|
116
386
|
this.debugLog(
|
|
117
|
-
`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges
|
|
387
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${this.On},` +
|
|
118
388
|
` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`,
|
|
119
389
|
);
|
|
120
390
|
if (this.device.customize) {
|
|
121
|
-
if (this.
|
|
391
|
+
if (!this.On && !this.disablePushOff) {
|
|
122
392
|
const commandType: string = await this.commandType();
|
|
123
393
|
const command: string = await this.commandOff();
|
|
124
394
|
const bodyChange = JSON.stringify({
|
|
@@ -174,13 +444,190 @@ export class Others {
|
|
|
174
444
|
}
|
|
175
445
|
|
|
176
446
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
447
|
+
if (this.otherDeviceType === 'garagedoor') {
|
|
448
|
+
if (this.On === undefined) {
|
|
449
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
450
|
+
} else {
|
|
451
|
+
if (this.On) {
|
|
452
|
+
this.garageDoorService?.updateCharacteristic(
|
|
453
|
+
this.platform.Characteristic.TargetDoorState,
|
|
454
|
+
this.platform.Characteristic.TargetDoorState.OPEN,
|
|
455
|
+
);
|
|
456
|
+
this.garageDoorService?.updateCharacteristic(
|
|
457
|
+
this.platform.Characteristic.CurrentDoorState,
|
|
458
|
+
this.platform.Characteristic.CurrentDoorState.OPEN,
|
|
459
|
+
);
|
|
460
|
+
this.debugLog(
|
|
461
|
+
`${this.device.remoteType}: ` + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`,
|
|
462
|
+
);
|
|
463
|
+
} else {
|
|
464
|
+
this.garageDoorService?.updateCharacteristic(
|
|
465
|
+
this.platform.Characteristic.TargetDoorState,
|
|
466
|
+
this.platform.Characteristic.TargetDoorState.CLOSED,
|
|
467
|
+
);
|
|
468
|
+
this.garageDoorService?.updateCharacteristic(
|
|
469
|
+
this.platform.Characteristic.CurrentDoorState,
|
|
470
|
+
this.platform.Characteristic.CurrentDoorState.CLOSED,
|
|
471
|
+
);
|
|
472
|
+
this.debugLog(
|
|
473
|
+
`${this.device.remoteType}: ` + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`,
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Garage Door On: ${this.On}`);
|
|
478
|
+
} else if (this.otherDeviceType === 'door') {
|
|
479
|
+
if (this.On === undefined) {
|
|
480
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
481
|
+
} else {
|
|
482
|
+
if (this.On) {
|
|
483
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
|
|
484
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
|
|
485
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
486
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
487
|
+
} else {
|
|
488
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
|
|
489
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
|
|
490
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
491
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Door On: ${this.On}`);
|
|
495
|
+
} else if (this.otherDeviceType === 'window') {
|
|
496
|
+
if (this.On === undefined) {
|
|
497
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
498
|
+
} else {
|
|
499
|
+
if (this.On) {
|
|
500
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
|
|
501
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
|
|
502
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
503
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
504
|
+
} else {
|
|
505
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
|
|
506
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
|
|
507
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
508
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window On: ${this.On}`);
|
|
512
|
+
} else if (this.otherDeviceType === 'windowcovering') {
|
|
513
|
+
if (this.On === undefined) {
|
|
514
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
515
|
+
} else {
|
|
516
|
+
if (this.On) {
|
|
517
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
|
|
518
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
|
|
519
|
+
this.windowCoveringService?.updateCharacteristic(
|
|
520
|
+
this.platform.Characteristic.PositionState,
|
|
521
|
+
this.platform.Characteristic.PositionState.STOPPED,
|
|
522
|
+
);
|
|
523
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
524
|
+
} else {
|
|
525
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
|
|
526
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
|
|
527
|
+
this.windowCoveringService?.updateCharacteristic(
|
|
528
|
+
this.platform.Characteristic.PositionState,
|
|
529
|
+
this.platform.Characteristic.PositionState.STOPPED,
|
|
530
|
+
);
|
|
531
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Window Covering On: ${this.On}`);
|
|
535
|
+
} else if (this.otherDeviceType === 'lock') {
|
|
536
|
+
if (this.On === undefined) {
|
|
537
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
538
|
+
} else {
|
|
539
|
+
if (this.On) {
|
|
540
|
+
this.lockService?.updateCharacteristic(
|
|
541
|
+
this.platform.Characteristic.LockTargetState,
|
|
542
|
+
this.platform.Characteristic.LockTargetState.UNSECURED,
|
|
543
|
+
);
|
|
544
|
+
this.lockService?.updateCharacteristic(
|
|
545
|
+
this.platform.Characteristic.LockCurrentState,
|
|
546
|
+
this.platform.Characteristic.LockCurrentState.UNSECURED,
|
|
547
|
+
);
|
|
548
|
+
this.debugLog(
|
|
549
|
+
`${this.device.remoteType}: ` +
|
|
550
|
+
`${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`,
|
|
551
|
+
);
|
|
552
|
+
} else {
|
|
553
|
+
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, this.platform.Characteristic.LockTargetState.SECURED);
|
|
554
|
+
this.lockService?.updateCharacteristic(
|
|
555
|
+
this.platform.Characteristic.LockCurrentState,
|
|
556
|
+
this.platform.Characteristic.LockCurrentState.SECURED,
|
|
557
|
+
);
|
|
558
|
+
this.debugLog(
|
|
559
|
+
`${this.device.remoteType}: ` + `${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`,
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Lock On: ${this.On}`);
|
|
564
|
+
} else if (this.otherDeviceType === 'faucet') {
|
|
565
|
+
if (this.On === undefined) {
|
|
566
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
567
|
+
} else {
|
|
568
|
+
if (this.On) {
|
|
569
|
+
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE);
|
|
570
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
571
|
+
} else {
|
|
572
|
+
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.INACTIVE);
|
|
573
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Faucet On: ${this.On}`);
|
|
577
|
+
} else if (this.otherDeviceType === 'fan') {
|
|
578
|
+
if (this.On === undefined) {
|
|
579
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
580
|
+
} else {
|
|
581
|
+
if (this.On) {
|
|
582
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
583
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
584
|
+
} else {
|
|
585
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
586
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Fan On: ${this.On}`);
|
|
590
|
+
} else if (this.otherDeviceType === 'stateful') {
|
|
591
|
+
if (this.On === undefined) {
|
|
592
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
593
|
+
} else {
|
|
594
|
+
if (this.On) {
|
|
595
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(
|
|
596
|
+
this.platform.Characteristic.ProgrammableSwitchEvent,
|
|
597
|
+
this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
598
|
+
);
|
|
599
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
600
|
+
this.debugLog(
|
|
601
|
+
`${this.device.remoteType}: ` +
|
|
602
|
+
`${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`,
|
|
603
|
+
);
|
|
604
|
+
} else {
|
|
605
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(
|
|
606
|
+
this.platform.Characteristic.ProgrammableSwitchEvent,
|
|
607
|
+
this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
608
|
+
);
|
|
609
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
610
|
+
this.debugLog(
|
|
611
|
+
`${this.device.remoteType}: ` +
|
|
612
|
+
`${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`,
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
|
|
617
|
+
} else if (this.otherDeviceType === 'switch') {
|
|
618
|
+
if (this.On === undefined) {
|
|
619
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
620
|
+
} else {
|
|
621
|
+
this.switchService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
622
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
623
|
+
}
|
|
180
624
|
} else {
|
|
181
|
-
this.
|
|
182
|
-
|
|
183
|
-
|
|
625
|
+
if (this.On === undefined) {
|
|
626
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
627
|
+
} else {
|
|
628
|
+
this.outletService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
629
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
630
|
+
}
|
|
184
631
|
}
|
|
185
632
|
// FirmwareRevision
|
|
186
633
|
if (this.FirmwareRevision === undefined) {
|
|
@@ -281,8 +728,127 @@ export class Others {
|
|
|
281
728
|
}
|
|
282
729
|
|
|
283
730
|
async apiError(e: any): Promise<void> {
|
|
284
|
-
|
|
285
|
-
|
|
731
|
+
if (this.otherDeviceType === 'garagedoor') {
|
|
732
|
+
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.TargetDoorState, e);
|
|
733
|
+
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.CurrentDoorState, e);
|
|
734
|
+
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.ObstructionDetected, e);
|
|
735
|
+
} else if (this.otherDeviceType === 'door') {
|
|
736
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
737
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
738
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
739
|
+
} else if (this.otherDeviceType === 'window') {
|
|
740
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
741
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
742
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
743
|
+
} else if (this.otherDeviceType === 'windowcovering') {
|
|
744
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
745
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
746
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
747
|
+
} else if (this.otherDeviceType === 'lock') {
|
|
748
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, e);
|
|
749
|
+
this.doorService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
|
|
750
|
+
} else if (this.otherDeviceType === 'faucet') {
|
|
751
|
+
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
752
|
+
} else if (this.otherDeviceType === 'fan') {
|
|
753
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
754
|
+
} else if (this.otherDeviceType === 'stateful') {
|
|
755
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, e);
|
|
756
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, e);
|
|
757
|
+
} else if (this.otherDeviceType === 'switch') {
|
|
758
|
+
this.switchService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
759
|
+
} else {
|
|
760
|
+
this.outletService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
765
|
+
// If outletService still pressent, then remove first
|
|
766
|
+
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
767
|
+
if (this.outletService) {
|
|
768
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
769
|
+
}
|
|
770
|
+
accessory.removeService(this.outletService!);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
774
|
+
// If garageDoorService still pressent, then remove first
|
|
775
|
+
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
776
|
+
if (this.garageDoorService) {
|
|
777
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
778
|
+
}
|
|
779
|
+
accessory.removeService(this.garageDoorService!);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
783
|
+
// If doorService still pressent, then remove first
|
|
784
|
+
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
785
|
+
if (this.doorService) {
|
|
786
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
787
|
+
}
|
|
788
|
+
accessory.removeService(this.doorService!);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
792
|
+
// If lockService still pressent, then remove first
|
|
793
|
+
this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
|
|
794
|
+
if (this.lockService) {
|
|
795
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
796
|
+
}
|
|
797
|
+
accessory.removeService(this.lockService!);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
801
|
+
// If faucetService still pressent, then remove first
|
|
802
|
+
this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
|
|
803
|
+
if (this.faucetService) {
|
|
804
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
805
|
+
}
|
|
806
|
+
accessory.removeService(this.faucetService!);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
810
|
+
// If fanService still pressent, then remove first
|
|
811
|
+
this.fanService = this.accessory.getService(this.platform.Service.Fan);
|
|
812
|
+
if (this.fanService) {
|
|
813
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
814
|
+
}
|
|
815
|
+
accessory.removeService(this.fanService!);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
819
|
+
// If windowService still pressent, then remove first
|
|
820
|
+
this.windowService = this.accessory.getService(this.platform.Service.Window);
|
|
821
|
+
if (this.windowService) {
|
|
822
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
823
|
+
}
|
|
824
|
+
accessory.removeService(this.windowService!);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
828
|
+
// If windowCoveringService still pressent, then remove first
|
|
829
|
+
this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
|
|
830
|
+
if (this.windowCoveringService) {
|
|
831
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
832
|
+
}
|
|
833
|
+
accessory.removeService(this.windowCoveringService!);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
837
|
+
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
838
|
+
this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
|
|
839
|
+
if (this.statefulProgrammableSwitchService) {
|
|
840
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
841
|
+
}
|
|
842
|
+
accessory.removeService(this.statefulProgrammableSwitchService!);
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
846
|
+
// If switchService still pressent, then remove first
|
|
847
|
+
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
848
|
+
if (this.switchService) {
|
|
849
|
+
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
850
|
+
}
|
|
851
|
+
accessory.removeService(this.switchService!);
|
|
286
852
|
}
|
|
287
853
|
|
|
288
854
|
async deviceType(device: irdevice & irDevicesConfig): Promise<void> {
|
|
@@ -292,7 +858,9 @@ export class Others {
|
|
|
292
858
|
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
|
|
293
859
|
}
|
|
294
860
|
} else {
|
|
861
|
+
this.otherDeviceType = 'outlet';
|
|
295
862
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} No Device Type Set, deviceType: ${this.device.other?.deviceType}`);
|
|
863
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Using default deviceType: ${this.otherDeviceType}`);
|
|
296
864
|
}
|
|
297
865
|
}
|
|
298
866
|
|
|
@@ -314,10 +882,10 @@ export class Others {
|
|
|
314
882
|
}
|
|
315
883
|
|
|
316
884
|
async context() {
|
|
317
|
-
if (this.
|
|
318
|
-
this.
|
|
885
|
+
if (this.On === undefined) {
|
|
886
|
+
this.On = true;
|
|
319
887
|
} else {
|
|
320
|
-
this.
|
|
888
|
+
this.On = this.accessory.context.On;
|
|
321
889
|
}
|
|
322
890
|
}
|
|
323
891
|
|