@switchbot/homebridge-switchbot 1.6.4-beta.3 → 1.7.1-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/CHANGELOG.md +15 -2
- package/config.schema.json +48 -0
- package/dist/devices/bots.d.ts +17 -8
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +448 -149
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/contact.d.ts +5 -0
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +93 -3
- package/dist/devices/contact.js.map +1 -1
- package/dist/settings.d.ts +2 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/devices/bots.ts +427 -127
- package/src/devices/contact.ts +99 -3
- package/src/settings.ts +2 -0
package/src/devices/bots.ts
CHANGED
|
@@ -13,12 +13,17 @@ import { DeviceURL, device, devicesConfig, serviceData, ad, switchbot, deviceSta
|
|
|
13
13
|
*/
|
|
14
14
|
export class Bot {
|
|
15
15
|
// Services
|
|
16
|
-
private
|
|
16
|
+
private fanService?: Service;
|
|
17
17
|
private doorService?: Service;
|
|
18
18
|
private lockService?: Service;
|
|
19
|
-
private
|
|
19
|
+
private faucetService?: Service;
|
|
20
|
+
private windowService?: Service;
|
|
21
|
+
private switchService?: Service;
|
|
20
22
|
private outletService?: Service;
|
|
21
23
|
private batteryService?: Service;
|
|
24
|
+
private garageDoorService?: Service;
|
|
25
|
+
private windowCoveringService?: Service;
|
|
26
|
+
private statefulProgrammableSwitchService?: Service;
|
|
22
27
|
|
|
23
28
|
|
|
24
29
|
// Characteristic Values
|
|
@@ -98,10 +103,15 @@ export class Bot {
|
|
|
98
103
|
// get the LightBulb service if it exists, otherwise create a new LightBulb service
|
|
99
104
|
// you can create multiple services for each accessory
|
|
100
105
|
if (device.bot?.deviceType === 'switch') {
|
|
106
|
+
this.removeFanService(accessory);
|
|
101
107
|
this.removeLockService(accessory);
|
|
102
108
|
this.removeDoorService(accessory);
|
|
109
|
+
this.removeFaucetService(accessory);
|
|
103
110
|
this.removeOutletService(accessory);
|
|
111
|
+
this.removeWindowService(accessory);
|
|
104
112
|
this.removeGarageDoorService(accessory);
|
|
113
|
+
this.removeWindowCoveringService(accessory);
|
|
114
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
105
115
|
|
|
106
116
|
// Add switchService
|
|
107
117
|
(this.switchService =
|
|
@@ -112,10 +122,15 @@ export class Bot {
|
|
|
112
122
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
113
123
|
this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
|
|
114
124
|
} else if (device.bot?.deviceType === 'garagedoor') {
|
|
125
|
+
this.removeFanService(accessory);
|
|
115
126
|
this.removeLockService(accessory);
|
|
116
127
|
this.removeDoorService(accessory);
|
|
128
|
+
this.removeFaucetService(accessory);
|
|
117
129
|
this.removeOutletService(accessory);
|
|
118
130
|
this.removeSwitchService(accessory);
|
|
131
|
+
this.removeWindowService(accessory);
|
|
132
|
+
this.removeWindowCoveringService(accessory);
|
|
133
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
119
134
|
|
|
120
135
|
// Add switchService
|
|
121
136
|
(this.garageDoorService =
|
|
@@ -127,10 +142,15 @@ export class Bot {
|
|
|
127
142
|
this.garageDoorService.getCharacteristic(this.platform.Characteristic.TargetDoorState).onSet(this.handleOnSet.bind(this));
|
|
128
143
|
this.garageDoorService.setCharacteristic(this.platform.Characteristic.ObstructionDetected, false);
|
|
129
144
|
} else if (device.bot?.deviceType === 'door') {
|
|
145
|
+
this.removeFanService(accessory);
|
|
130
146
|
this.removeLockService(accessory);
|
|
131
147
|
this.removeOutletService(accessory);
|
|
148
|
+
this.removeFaucetService(accessory);
|
|
132
149
|
this.removeSwitchService(accessory);
|
|
150
|
+
this.removeWindowService(accessory);
|
|
133
151
|
this.removeGarageDoorService(accessory);
|
|
152
|
+
this.removeWindowCoveringService(accessory);
|
|
153
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
134
154
|
|
|
135
155
|
// Add switchService
|
|
136
156
|
(this.doorService =
|
|
@@ -147,11 +167,68 @@ export class Bot {
|
|
|
147
167
|
minStep: 100,
|
|
148
168
|
}).onSet(this.handleOnSet.bind(this));
|
|
149
169
|
this.doorService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
170
|
+
} else if (device.bot?.deviceType === 'window') {
|
|
171
|
+
this.removeFanService(accessory);
|
|
172
|
+
this.removeLockService(accessory);
|
|
173
|
+
this.removeDoorService(accessory);
|
|
174
|
+
this.removeOutletService(accessory);
|
|
175
|
+
this.removeFaucetService(accessory);
|
|
176
|
+
this.removeSwitchService(accessory);
|
|
177
|
+
this.removeGarageDoorService(accessory);
|
|
178
|
+
this.removeWindowCoveringService(accessory);
|
|
179
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
180
|
+
|
|
181
|
+
// Add switchService
|
|
182
|
+
(this.windowService =
|
|
183
|
+
accessory.getService(this.platform.Service.Window) ||
|
|
184
|
+
accessory.addService(this.platform.Service.Window)), `${accessory.displayName} Window`;
|
|
185
|
+
this.infoLog(`Bot: ${accessory.displayName} Displaying as Window`);
|
|
186
|
+
|
|
187
|
+
this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
188
|
+
this.windowService.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
189
|
+
.setProps({
|
|
190
|
+
validValues: [0, 100],
|
|
191
|
+
minValue: 0,
|
|
192
|
+
maxValue: 100,
|
|
193
|
+
minStep: 100,
|
|
194
|
+
}).onSet(this.handleOnSet.bind(this));
|
|
195
|
+
this.windowService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
196
|
+
} else if (device.bot?.deviceType === 'windowcovering') {
|
|
197
|
+
this.removeFanService(accessory);
|
|
198
|
+
this.removeLockService(accessory);
|
|
199
|
+
this.removeDoorService(accessory);
|
|
200
|
+
this.removeOutletService(accessory);
|
|
201
|
+
this.removeFaucetService(accessory);
|
|
202
|
+
this.removeSwitchService(accessory);
|
|
203
|
+
this.removeWindowService(accessory);
|
|
204
|
+
this.removeGarageDoorService(accessory);
|
|
205
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
206
|
+
|
|
207
|
+
// Add switchService
|
|
208
|
+
(this.windowCoveringService =
|
|
209
|
+
accessory.getService(this.platform.Service.WindowCovering) ||
|
|
210
|
+
accessory.addService(this.platform.Service.WindowCovering)), `${accessory.displayName} Window Covering`;
|
|
211
|
+
this.infoLog(`Bot: ${accessory.displayName} Displaying as Window Covering`);
|
|
212
|
+
|
|
213
|
+
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
214
|
+
this.windowCoveringService.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
215
|
+
.setProps({
|
|
216
|
+
validValues: [0, 100],
|
|
217
|
+
minValue: 0,
|
|
218
|
+
maxValue: 100,
|
|
219
|
+
minStep: 100,
|
|
220
|
+
}).onSet(this.handleOnSet.bind(this));
|
|
221
|
+
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
150
222
|
} else if (device.bot?.deviceType === 'lock') {
|
|
223
|
+
this.removeFanService(accessory);
|
|
151
224
|
this.removeDoorService(accessory);
|
|
152
225
|
this.removeOutletService(accessory);
|
|
153
226
|
this.removeSwitchService(accessory);
|
|
227
|
+
this.removeFaucetService(accessory);
|
|
228
|
+
this.removeWindowService(accessory);
|
|
154
229
|
this.removeGarageDoorService(accessory);
|
|
230
|
+
this.removeWindowCoveringService(accessory);
|
|
231
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
155
232
|
|
|
156
233
|
// Add switchService
|
|
157
234
|
(this.lockService =
|
|
@@ -161,11 +238,74 @@ export class Bot {
|
|
|
161
238
|
|
|
162
239
|
this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
163
240
|
this.lockService.getCharacteristic(this.platform.Characteristic.LockTargetState).onSet(this.handleOnSet.bind(this));
|
|
241
|
+
} else if (device.bot?.deviceType === 'faucet') {
|
|
242
|
+
this.removeFanService(accessory);
|
|
243
|
+
this.removeLockService(accessory);
|
|
244
|
+
this.removeDoorService(accessory);
|
|
245
|
+
this.removeOutletService(accessory);
|
|
246
|
+
this.removeSwitchService(accessory);
|
|
247
|
+
this.removeWindowService(accessory);
|
|
248
|
+
this.removeGarageDoorService(accessory);
|
|
249
|
+
this.removeWindowCoveringService(accessory);
|
|
250
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
251
|
+
|
|
252
|
+
// Add switchService
|
|
253
|
+
(this.faucetService =
|
|
254
|
+
accessory.getService(this.platform.Service.Faucet) ||
|
|
255
|
+
accessory.addService(this.platform.Service.Faucet)), `${accessory.displayName} Faucet`;
|
|
256
|
+
this.infoLog(`Bot: ${accessory.displayName} Displaying as Faucet`);
|
|
257
|
+
|
|
258
|
+
this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
259
|
+
this.faucetService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.handleOnSet.bind(this));
|
|
260
|
+
} else if (device.bot?.deviceType === 'fan') {
|
|
261
|
+
this.removeLockService(accessory);
|
|
262
|
+
this.removeDoorService(accessory);
|
|
263
|
+
this.removeFaucetService(accessory);
|
|
264
|
+
this.removeOutletService(accessory);
|
|
265
|
+
this.removeSwitchService(accessory);
|
|
266
|
+
this.removeWindowService(accessory);
|
|
267
|
+
this.removeGarageDoorService(accessory);
|
|
268
|
+
this.removeWindowCoveringService(accessory);
|
|
269
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
270
|
+
|
|
271
|
+
// Add switchService
|
|
272
|
+
(this.fanService =
|
|
273
|
+
accessory.getService(this.platform.Service.Fan) ||
|
|
274
|
+
accessory.addService(this.platform.Service.Fan)), `${accessory.displayName} Fan`;
|
|
275
|
+
this.infoLog(`Bot: ${accessory.displayName} Displaying as Fan`);
|
|
276
|
+
|
|
277
|
+
this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
278
|
+
this.fanService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
|
|
279
|
+
} else if (device.bot?.deviceType === 'stateful') {
|
|
280
|
+
this.removeFanService(accessory);
|
|
281
|
+
this.removeLockService(accessory);
|
|
282
|
+
this.removeDoorService(accessory);
|
|
283
|
+
this.removeFaucetService(accessory);
|
|
284
|
+
this.removeOutletService(accessory);
|
|
285
|
+
this.removeSwitchService(accessory);
|
|
286
|
+
this.removeWindowService(accessory);
|
|
287
|
+
this.removeGarageDoorService(accessory);
|
|
288
|
+
this.removeWindowCoveringService(accessory);
|
|
289
|
+
|
|
290
|
+
// Add switchService
|
|
291
|
+
(this.statefulProgrammableSwitchService =
|
|
292
|
+
accessory.getService(this.platform.Service.StatefulProgrammableSwitch) ||
|
|
293
|
+
accessory.addService(this.platform.Service.StatefulProgrammableSwitch)), `${accessory.displayName} Stateful Programmable Switch`;
|
|
294
|
+
this.infoLog(`Bot: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
295
|
+
|
|
296
|
+
this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
297
|
+
this.statefulProgrammableSwitchService.getCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState)
|
|
298
|
+
.onSet(this.handleOnSet.bind(this));
|
|
164
299
|
} else {
|
|
300
|
+
this.removeFanService(accessory);
|
|
165
301
|
this.removeLockService(accessory);
|
|
166
302
|
this.removeDoorService(accessory);
|
|
303
|
+
this.removeFaucetService(accessory);
|
|
167
304
|
this.removeSwitchService(accessory);
|
|
305
|
+
this.removeWindowService(accessory);
|
|
168
306
|
this.removeGarageDoorService(accessory);
|
|
307
|
+
this.removeWindowCoveringService(accessory);
|
|
308
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
169
309
|
|
|
170
310
|
// Add outletService
|
|
171
311
|
(this.outletService =
|
|
@@ -226,48 +366,93 @@ export class Bot {
|
|
|
226
366
|
});
|
|
227
367
|
}
|
|
228
368
|
|
|
229
|
-
|
|
369
|
+
public removeOutletService(accessory: PlatformAccessory) {
|
|
230
370
|
// If outletService still pressent, then remove first
|
|
371
|
+
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
231
372
|
if (this.outletService) {
|
|
232
|
-
this.
|
|
373
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
233
374
|
}
|
|
234
|
-
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
235
375
|
accessory.removeService(this.outletService!);
|
|
236
376
|
}
|
|
237
377
|
|
|
238
|
-
|
|
378
|
+
public removeGarageDoorService(accessory: PlatformAccessory) {
|
|
239
379
|
// If garageDoorService still pressent, then remove first
|
|
380
|
+
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
240
381
|
if (this.garageDoorService) {
|
|
241
|
-
this.
|
|
382
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
242
383
|
}
|
|
243
|
-
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
244
384
|
accessory.removeService(this.garageDoorService!);
|
|
245
385
|
}
|
|
246
386
|
|
|
247
|
-
|
|
387
|
+
public removeDoorService(accessory: PlatformAccessory) {
|
|
248
388
|
// If doorService still pressent, then remove first
|
|
389
|
+
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
249
390
|
if (this.doorService) {
|
|
250
|
-
this.
|
|
391
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
|
|
251
392
|
}
|
|
252
|
-
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
253
393
|
accessory.removeService(this.doorService!);
|
|
254
394
|
}
|
|
255
395
|
|
|
256
|
-
|
|
396
|
+
public removeLockService(accessory: PlatformAccessory) {
|
|
257
397
|
// If lockService still pressent, then remove first
|
|
398
|
+
this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
|
|
258
399
|
if (this.lockService) {
|
|
259
|
-
this.
|
|
400
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
260
401
|
}
|
|
261
|
-
this.lockService = this.accessory.getService(this.platform.Service.Door);
|
|
262
402
|
accessory.removeService(this.lockService!);
|
|
263
403
|
}
|
|
264
404
|
|
|
265
|
-
|
|
405
|
+
public removeFaucetService(accessory: PlatformAccessory) {
|
|
406
|
+
// If faucetService still pressent, then remove first
|
|
407
|
+
this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
|
|
408
|
+
if (this.faucetService) {
|
|
409
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
410
|
+
}
|
|
411
|
+
accessory.removeService(this.faucetService!);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
public removeFanService(accessory: PlatformAccessory) {
|
|
415
|
+
// If fanService still pressent, then remove first
|
|
416
|
+
this.fanService = this.accessory.getService(this.platform.Service.Fan);
|
|
417
|
+
if (this.fanService) {
|
|
418
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
419
|
+
}
|
|
420
|
+
accessory.removeService(this.fanService!);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
public removeWindowService(accessory: PlatformAccessory) {
|
|
424
|
+
// If windowService still pressent, then remove first
|
|
425
|
+
this.windowService = this.accessory.getService(this.platform.Service.Window);
|
|
426
|
+
if (this.windowService) {
|
|
427
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
|
|
428
|
+
}
|
|
429
|
+
accessory.removeService(this.windowService!);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
public removeWindowCoveringService(accessory: PlatformAccessory) {
|
|
433
|
+
// If windowCoveringService still pressent, then remove first
|
|
434
|
+
this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
|
|
435
|
+
if (this.windowCoveringService) {
|
|
436
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
437
|
+
}
|
|
438
|
+
accessory.removeService(this.windowCoveringService!);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
public removeStatefulProgrammableSwitchService(accessory: PlatformAccessory) {
|
|
442
|
+
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
443
|
+
this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
|
|
444
|
+
if (this.statefulProgrammableSwitchService) {
|
|
445
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
446
|
+
}
|
|
447
|
+
accessory.removeService(this.statefulProgrammableSwitchService!);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
public removeSwitchService(accessory: PlatformAccessory) {
|
|
266
451
|
// If switchService still pressent, then remove first
|
|
452
|
+
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
267
453
|
if (this.switchService) {
|
|
268
|
-
this.
|
|
454
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
269
455
|
}
|
|
270
|
-
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
271
456
|
accessory.removeService(this.switchService!);
|
|
272
457
|
}
|
|
273
458
|
|
|
@@ -382,7 +567,7 @@ export class Bot {
|
|
|
382
567
|
this.OnCached = this.On;
|
|
383
568
|
this.accessory.context.On = this.OnCached;
|
|
384
569
|
} else {
|
|
385
|
-
if (this.deviceStatus.body.power === 'on') {
|
|
570
|
+
/*if (this.deviceStatus.body.power === 'on') {
|
|
386
571
|
this.On = true;
|
|
387
572
|
this.OnCached = this.On;
|
|
388
573
|
this.accessory.context.On = this.OnCached;
|
|
@@ -390,6 +575,11 @@ export class Bot {
|
|
|
390
575
|
this.On = false;
|
|
391
576
|
this.OnCached = this.On;
|
|
392
577
|
this.accessory.context.On = this.OnCached;
|
|
578
|
+
}*/
|
|
579
|
+
this.OnCached = this.On;
|
|
580
|
+
this.accessory.context.On = this.OnCached;
|
|
581
|
+
if (this.On === undefined) {
|
|
582
|
+
this.On = false;
|
|
393
583
|
}
|
|
394
584
|
}
|
|
395
585
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
@@ -437,67 +627,62 @@ export class Bot {
|
|
|
437
627
|
// Convert to BLE Address
|
|
438
628
|
const switchbot = await this.connectBLE();
|
|
439
629
|
// Start to monitor advertisement packets
|
|
440
|
-
if (switchbot
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
461
|
-
}
|
|
462
|
-
};
|
|
463
|
-
// Wait 2 seconds
|
|
464
|
-
return switchbot.wait(this.scanDuration * 1000);
|
|
465
|
-
}).then(async () => {
|
|
466
|
-
// Stop to monitor
|
|
467
|
-
switchbot.stopScan();
|
|
468
|
-
if (this.connected) {
|
|
469
|
-
this.parseStatus();
|
|
470
|
-
this.updateHomeKitCharacteristics();
|
|
630
|
+
if (switchbot === false) {
|
|
631
|
+
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection: ${switchbot}`);
|
|
632
|
+
}
|
|
633
|
+
switchbot.startScan({
|
|
634
|
+
model: 'H',
|
|
635
|
+
id: this.device.bleMac,
|
|
636
|
+
}).then(() => {
|
|
637
|
+
// Set an event hander
|
|
638
|
+
switchbot.onadvertisement = (ad: ad) => {
|
|
639
|
+
this.serviceData = ad.serviceData;
|
|
640
|
+
this.mode = ad.serviceData.mode;
|
|
641
|
+
this.state = ad.serviceData.state;
|
|
642
|
+
this.battery = ad.serviceData.battery;
|
|
643
|
+
this.debugLog(`Bot: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
644
|
+
this.debugLog(`Bot: ${this.accessory.displayName}, model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},`
|
|
645
|
+
+ ` mode: ${ad.serviceData.mode}, state: ${ad.serviceData.state}, battery: ${ad.serviceData.battery}`);
|
|
646
|
+
|
|
647
|
+
if (this.serviceData) {
|
|
648
|
+
this.connected = true;
|
|
649
|
+
this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
471
650
|
} else {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}).catch(async (e: any) => {
|
|
475
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
476
|
-
if (this.deviceLogging === 'debug') {
|
|
477
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
478
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
479
|
-
}
|
|
480
|
-
if (this.platform.debugMode) {
|
|
481
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
482
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
651
|
+
this.connected = false;
|
|
652
|
+
this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
483
653
|
}
|
|
654
|
+
};
|
|
655
|
+
// Wait 2 seconds
|
|
656
|
+
return switchbot.wait(this.scanDuration * 1000);
|
|
657
|
+
}).then(async () => {
|
|
658
|
+
// Stop to monitor
|
|
659
|
+
switchbot.stopScan();
|
|
660
|
+
if (this.connected) {
|
|
661
|
+
this.parseStatus();
|
|
662
|
+
this.updateHomeKitCharacteristics();
|
|
663
|
+
} else {
|
|
664
|
+
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
484
665
|
if (this.platform.config.credentials?.openToken) {
|
|
485
666
|
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
486
667
|
await this.openAPIRefreshStatus();
|
|
487
668
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
669
|
+
}
|
|
670
|
+
}).catch(async (e: any) => {
|
|
671
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
672
|
+
if (this.deviceLogging === 'debug') {
|
|
673
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
674
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
675
|
+
}
|
|
676
|
+
if (this.platform.debugMode) {
|
|
677
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
678
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
679
|
+
}
|
|
680
|
+
if (this.platform.config.credentials?.openToken) {
|
|
681
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
682
|
+
await this.openAPIRefreshStatus();
|
|
683
|
+
}
|
|
684
|
+
this.apiError(e);
|
|
685
|
+
});
|
|
501
686
|
}
|
|
502
687
|
|
|
503
688
|
private async openAPIRefreshStatus() {
|
|
@@ -545,54 +730,30 @@ export class Bot {
|
|
|
545
730
|
}
|
|
546
731
|
|
|
547
732
|
private async BLEpushChanges() {
|
|
733
|
+
this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.OnCached}`);
|
|
548
734
|
if (this.On !== this.OnCached) {
|
|
549
735
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges`);
|
|
550
736
|
const switchbot = await this.connectBLE();
|
|
551
|
-
if (switchbot !== false) {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
557
|
-
return device_list[0].press({ id: this.device.bleMac });
|
|
558
|
-
}).then(() => {
|
|
559
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
|
|
560
|
-
this.On = false;
|
|
561
|
-
this.OnCached = this.On;
|
|
562
|
-
this.accessory.context.On = this.OnCached;
|
|
563
|
-
setTimeout(() => {
|
|
564
|
-
if (this.device.bot?.deviceType === 'switch') {
|
|
565
|
-
this.switchService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
566
|
-
} else {
|
|
567
|
-
this.outletService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
568
|
-
}
|
|
569
|
-
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}, Switch Timeout`);
|
|
570
|
-
}, 500);
|
|
571
|
-
}).catch(async (e: any) => {
|
|
572
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
573
|
-
if (this.deviceLogging === 'debug') {
|
|
574
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
575
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
576
|
-
}
|
|
577
|
-
if (this.platform.debugMode) {
|
|
578
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
579
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
580
|
-
}
|
|
581
|
-
if (this.platform.config.credentials?.openToken) {
|
|
582
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
583
|
-
await this.openAPIpushChanges();
|
|
584
|
-
}
|
|
585
|
-
this.apiError(e);
|
|
586
|
-
});
|
|
587
|
-
} else if (this.botMode === 'switch') {
|
|
588
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Press Mode: ${this.botMode}`);
|
|
589
|
-
switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac }).then((device_list: any) => {
|
|
737
|
+
//if (switchbot !== false) {
|
|
738
|
+
if (this.botMode === 'press') {
|
|
739
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
740
|
+
switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac })
|
|
741
|
+
.then((device_list: { press: (arg0: { id: string | undefined; }) => any; }[]) => {
|
|
590
742
|
this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
591
|
-
return this.
|
|
743
|
+
return device_list[0].press({ id: this.device.bleMac });
|
|
592
744
|
}).then(() => {
|
|
593
745
|
this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
|
|
746
|
+
this.On = false;
|
|
594
747
|
this.OnCached = this.On;
|
|
595
748
|
this.accessory.context.On = this.OnCached;
|
|
749
|
+
setTimeout(() => {
|
|
750
|
+
if (this.device.bot?.deviceType === 'switch') {
|
|
751
|
+
this.switchService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
752
|
+
} else {
|
|
753
|
+
this.outletService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
754
|
+
}
|
|
755
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}, Switch Timeout`);
|
|
756
|
+
}, 500);
|
|
596
757
|
}).catch(async (e: any) => {
|
|
597
758
|
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
598
759
|
if (this.deviceLogging === 'debug') {
|
|
@@ -609,16 +770,41 @@ export class Bot {
|
|
|
609
770
|
}
|
|
610
771
|
this.apiError(e);
|
|
611
772
|
});
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
773
|
+
} else if (this.botMode === 'switch') {
|
|
774
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Press Mode: ${this.botMode}`);
|
|
775
|
+
switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac }).then((device_list: any) => {
|
|
776
|
+
this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
777
|
+
return this.turnOnOff(device_list);
|
|
778
|
+
}).then(() => {
|
|
779
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
|
|
780
|
+
this.OnCached = this.On;
|
|
781
|
+
this.accessory.context.On = this.OnCached;
|
|
782
|
+
}).catch(async (e: any) => {
|
|
783
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
784
|
+
if (this.deviceLogging === 'debug') {
|
|
785
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
786
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
787
|
+
}
|
|
788
|
+
if (this.platform.debugMode) {
|
|
789
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
790
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
791
|
+
}
|
|
792
|
+
if (this.platform.config.credentials?.openToken) {
|
|
793
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
794
|
+
await this.openAPIpushChanges();
|
|
795
|
+
}
|
|
796
|
+
this.apiError(e);
|
|
797
|
+
});
|
|
615
798
|
} else {
|
|
616
|
-
|
|
617
|
-
if (this.platform.config.credentials?.openToken) {
|
|
618
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
619
|
-
await this.openAPIpushChanges();
|
|
620
|
-
}
|
|
799
|
+
throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
621
800
|
}
|
|
801
|
+
/* } else {
|
|
802
|
+
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
803
|
+
if (this.platform.config.credentials?.openToken) {
|
|
804
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
805
|
+
await this.openAPIpushChanges();
|
|
806
|
+
}
|
|
807
|
+
}*/
|
|
622
808
|
}
|
|
623
809
|
this.OnCached = this.On;
|
|
624
810
|
this.accessory.context.On = this.OnCached;
|
|
@@ -725,25 +911,108 @@ export class Bot {
|
|
|
725
911
|
}
|
|
726
912
|
}
|
|
727
913
|
this.debugLog(`Bot: ${this.accessory.displayName} Door On: ${this.On}`);
|
|
914
|
+
} else if (this.device.bot?.deviceType === 'window') {
|
|
915
|
+
if (this.On === undefined) {
|
|
916
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
917
|
+
} else {
|
|
918
|
+
if (this.On) {
|
|
919
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
|
|
920
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
|
|
921
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState,
|
|
922
|
+
this.platform.Characteristic.PositionState.STOPPED);
|
|
923
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
924
|
+
} else {
|
|
925
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
|
|
926
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
|
|
927
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState,
|
|
928
|
+
this.platform.Characteristic.PositionState.STOPPED);
|
|
929
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Window On: ${this.On}`);
|
|
933
|
+
} else if (this.device.bot?.deviceType === 'windowcovering') {
|
|
934
|
+
if (this.On === undefined) {
|
|
935
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
936
|
+
} else {
|
|
937
|
+
if (this.On) {
|
|
938
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
|
|
939
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
|
|
940
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState,
|
|
941
|
+
this.platform.Characteristic.PositionState.STOPPED);
|
|
942
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
943
|
+
} else {
|
|
944
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
|
|
945
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
|
|
946
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState,
|
|
947
|
+
this.platform.Characteristic.PositionState.STOPPED);
|
|
948
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Window Covering On: ${this.On}`);
|
|
728
952
|
} else if (this.device.bot?.deviceType === 'lock') {
|
|
729
953
|
if (this.On === undefined) {
|
|
730
954
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
731
955
|
} else {
|
|
732
956
|
if (this.On) {
|
|
733
|
-
this.
|
|
957
|
+
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState,
|
|
734
958
|
this.platform.Characteristic.LockTargetState.UNSECURED);
|
|
735
|
-
this.
|
|
959
|
+
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState,
|
|
736
960
|
this.platform.Characteristic.LockCurrentState.UNSECURED);
|
|
737
961
|
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`);
|
|
738
962
|
} else {
|
|
739
|
-
this.
|
|
963
|
+
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState,
|
|
740
964
|
this.platform.Characteristic.LockTargetState.SECURED);
|
|
741
|
-
this.
|
|
965
|
+
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState,
|
|
742
966
|
this.platform.Characteristic.LockCurrentState.SECURED);
|
|
743
967
|
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`);
|
|
744
968
|
}
|
|
745
969
|
}
|
|
746
970
|
this.debugLog(`Bot: ${this.accessory.displayName} Lock On: ${this.On}`);
|
|
971
|
+
} else if (this.device.bot?.deviceType === 'faucet') {
|
|
972
|
+
if (this.On === undefined) {
|
|
973
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
974
|
+
} else {
|
|
975
|
+
if (this.On) {
|
|
976
|
+
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active,
|
|
977
|
+
this.platform.Characteristic.Active.ACTIVE);
|
|
978
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
979
|
+
} else {
|
|
980
|
+
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active,
|
|
981
|
+
this.platform.Characteristic.Active.INACTIVE);
|
|
982
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Faucet On: ${this.On}`);
|
|
986
|
+
} else if (this.device.bot?.deviceType === 'fan') {
|
|
987
|
+
if (this.On === undefined) {
|
|
988
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
989
|
+
} else {
|
|
990
|
+
if (this.On) {
|
|
991
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
992
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
993
|
+
} else {
|
|
994
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
995
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Fan On: ${this.On}`);
|
|
999
|
+
} else if (this.device.bot?.deviceType === 'stateful') {
|
|
1000
|
+
if (this.On === undefined) {
|
|
1001
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
1002
|
+
} else {
|
|
1003
|
+
if (this.On) {
|
|
1004
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent,
|
|
1005
|
+
this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
1006
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
1007
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`);
|
|
1008
|
+
} else {
|
|
1009
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent,
|
|
1010
|
+
this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
1011
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
1012
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
this.debugLog(`Bot: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
|
|
747
1016
|
} else if (this.device.bot?.deviceType === 'switch') {
|
|
748
1017
|
if (this.On === undefined) {
|
|
749
1018
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
@@ -784,9 +1053,24 @@ export class Bot {
|
|
|
784
1053
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
785
1054
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
786
1055
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
1056
|
+
} else if (this.device.bot?.deviceType === 'window') {
|
|
1057
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
1058
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
1059
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
1060
|
+
} else if (this.device.bot?.deviceType === 'windowcovering') {
|
|
1061
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
1062
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
1063
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
787
1064
|
} else if (this.device.bot?.deviceType === 'lock') {
|
|
788
1065
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, e);
|
|
789
1066
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
|
|
1067
|
+
} else if (this.device.bot?.deviceType === 'faucet') {
|
|
1068
|
+
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
1069
|
+
} else if (this.device.bot?.deviceType === 'fan') {
|
|
1070
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
1071
|
+
} else if (this.device.bot?.deviceType === 'stateful') {
|
|
1072
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, e);
|
|
1073
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, e);
|
|
790
1074
|
} else if (this.device.bot?.deviceType === 'switch') {
|
|
791
1075
|
this.switchService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
792
1076
|
} else {
|
|
@@ -852,9 +1136,11 @@ export class Bot {
|
|
|
852
1136
|
} else {
|
|
853
1137
|
this.On = true;
|
|
854
1138
|
}
|
|
855
|
-
} else if (this.device.bot?.deviceType === 'door'
|
|
1139
|
+
} else if (this.device.bot?.deviceType === 'door'
|
|
1140
|
+
|| this.device.bot?.deviceType === 'window'
|
|
1141
|
+
|| this.device.bot?.deviceType === 'windowcovering') {
|
|
856
1142
|
this.debugLog(`Bot: ${this.accessory.displayName} TargetPosition: ${value}`);
|
|
857
|
-
if (value ===
|
|
1143
|
+
if (value === 0) {
|
|
858
1144
|
this.On = false;
|
|
859
1145
|
} else {
|
|
860
1146
|
this.On = true;
|
|
@@ -866,6 +1152,20 @@ export class Bot {
|
|
|
866
1152
|
} else {
|
|
867
1153
|
this.On = true;
|
|
868
1154
|
}
|
|
1155
|
+
} else if (this.device.bot?.deviceType === 'faucet') {
|
|
1156
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Active: ${value}`);
|
|
1157
|
+
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
1158
|
+
this.On = false;
|
|
1159
|
+
} else {
|
|
1160
|
+
this.On = true;
|
|
1161
|
+
}
|
|
1162
|
+
} else if (this.device.bot?.deviceType === 'stateful') {
|
|
1163
|
+
this.debugLog(`Bot: ${this.accessory.displayName} ProgrammableSwitchOutputState: ${value}`);
|
|
1164
|
+
if (value === 0) {
|
|
1165
|
+
this.On = false;
|
|
1166
|
+
} else {
|
|
1167
|
+
this.On = true;
|
|
1168
|
+
}
|
|
869
1169
|
} else {
|
|
870
1170
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${value}`);
|
|
871
1171
|
this.On = value;
|