@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/dist/devices/bots.js
CHANGED
|
@@ -52,10 +52,15 @@ class Bot {
|
|
|
52
52
|
// get the LightBulb service if it exists, otherwise create a new LightBulb service
|
|
53
53
|
// you can create multiple services for each accessory
|
|
54
54
|
if (device.bot?.deviceType === 'switch') {
|
|
55
|
+
this.removeFanService(accessory);
|
|
55
56
|
this.removeLockService(accessory);
|
|
56
57
|
this.removeDoorService(accessory);
|
|
58
|
+
this.removeFaucetService(accessory);
|
|
57
59
|
this.removeOutletService(accessory);
|
|
60
|
+
this.removeWindowService(accessory);
|
|
58
61
|
this.removeGarageDoorService(accessory);
|
|
62
|
+
this.removeWindowCoveringService(accessory);
|
|
63
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
59
64
|
// Add switchService
|
|
60
65
|
(this.switchService =
|
|
61
66
|
accessory.getService(this.platform.Service.Switch) ||
|
|
@@ -65,10 +70,15 @@ class Bot {
|
|
|
65
70
|
this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
|
|
66
71
|
}
|
|
67
72
|
else if (device.bot?.deviceType === 'garagedoor') {
|
|
73
|
+
this.removeFanService(accessory);
|
|
68
74
|
this.removeLockService(accessory);
|
|
69
75
|
this.removeDoorService(accessory);
|
|
76
|
+
this.removeFaucetService(accessory);
|
|
70
77
|
this.removeOutletService(accessory);
|
|
71
78
|
this.removeSwitchService(accessory);
|
|
79
|
+
this.removeWindowService(accessory);
|
|
80
|
+
this.removeWindowCoveringService(accessory);
|
|
81
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
72
82
|
// Add switchService
|
|
73
83
|
(this.garageDoorService =
|
|
74
84
|
accessory.getService(this.platform.Service.GarageDoorOpener) ||
|
|
@@ -79,10 +89,15 @@ class Bot {
|
|
|
79
89
|
this.garageDoorService.setCharacteristic(this.platform.Characteristic.ObstructionDetected, false);
|
|
80
90
|
}
|
|
81
91
|
else if (device.bot?.deviceType === 'door') {
|
|
92
|
+
this.removeFanService(accessory);
|
|
82
93
|
this.removeLockService(accessory);
|
|
83
94
|
this.removeOutletService(accessory);
|
|
95
|
+
this.removeFaucetService(accessory);
|
|
84
96
|
this.removeSwitchService(accessory);
|
|
97
|
+
this.removeWindowService(accessory);
|
|
85
98
|
this.removeGarageDoorService(accessory);
|
|
99
|
+
this.removeWindowCoveringService(accessory);
|
|
100
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
86
101
|
// Add switchService
|
|
87
102
|
(this.doorService =
|
|
88
103
|
accessory.getService(this.platform.Service.Door) ||
|
|
@@ -98,11 +113,66 @@ class Bot {
|
|
|
98
113
|
}).onSet(this.handleOnSet.bind(this));
|
|
99
114
|
this.doorService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
100
115
|
}
|
|
116
|
+
else if (device.bot?.deviceType === 'window') {
|
|
117
|
+
this.removeFanService(accessory);
|
|
118
|
+
this.removeLockService(accessory);
|
|
119
|
+
this.removeDoorService(accessory);
|
|
120
|
+
this.removeOutletService(accessory);
|
|
121
|
+
this.removeFaucetService(accessory);
|
|
122
|
+
this.removeSwitchService(accessory);
|
|
123
|
+
this.removeGarageDoorService(accessory);
|
|
124
|
+
this.removeWindowCoveringService(accessory);
|
|
125
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
126
|
+
// Add switchService
|
|
127
|
+
(this.windowService =
|
|
128
|
+
accessory.getService(this.platform.Service.Window) ||
|
|
129
|
+
accessory.addService(this.platform.Service.Window)), `${accessory.displayName} Window`;
|
|
130
|
+
this.infoLog(`Bot: ${accessory.displayName} Displaying as Window`);
|
|
131
|
+
this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
132
|
+
this.windowService.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
133
|
+
.setProps({
|
|
134
|
+
validValues: [0, 100],
|
|
135
|
+
minValue: 0,
|
|
136
|
+
maxValue: 100,
|
|
137
|
+
minStep: 100,
|
|
138
|
+
}).onSet(this.handleOnSet.bind(this));
|
|
139
|
+
this.windowService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
140
|
+
}
|
|
141
|
+
else if (device.bot?.deviceType === 'windowcovering') {
|
|
142
|
+
this.removeFanService(accessory);
|
|
143
|
+
this.removeLockService(accessory);
|
|
144
|
+
this.removeDoorService(accessory);
|
|
145
|
+
this.removeOutletService(accessory);
|
|
146
|
+
this.removeFaucetService(accessory);
|
|
147
|
+
this.removeSwitchService(accessory);
|
|
148
|
+
this.removeWindowService(accessory);
|
|
149
|
+
this.removeGarageDoorService(accessory);
|
|
150
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
151
|
+
// Add switchService
|
|
152
|
+
(this.windowCoveringService =
|
|
153
|
+
accessory.getService(this.platform.Service.WindowCovering) ||
|
|
154
|
+
accessory.addService(this.platform.Service.WindowCovering)), `${accessory.displayName} Window Covering`;
|
|
155
|
+
this.infoLog(`Bot: ${accessory.displayName} Displaying as Window Covering`);
|
|
156
|
+
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
157
|
+
this.windowCoveringService.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
158
|
+
.setProps({
|
|
159
|
+
validValues: [0, 100],
|
|
160
|
+
minValue: 0,
|
|
161
|
+
maxValue: 100,
|
|
162
|
+
minStep: 100,
|
|
163
|
+
}).onSet(this.handleOnSet.bind(this));
|
|
164
|
+
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
165
|
+
}
|
|
101
166
|
else if (device.bot?.deviceType === 'lock') {
|
|
167
|
+
this.removeFanService(accessory);
|
|
102
168
|
this.removeDoorService(accessory);
|
|
103
169
|
this.removeOutletService(accessory);
|
|
104
170
|
this.removeSwitchService(accessory);
|
|
171
|
+
this.removeFaucetService(accessory);
|
|
172
|
+
this.removeWindowService(accessory);
|
|
105
173
|
this.removeGarageDoorService(accessory);
|
|
174
|
+
this.removeWindowCoveringService(accessory);
|
|
175
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
106
176
|
// Add switchService
|
|
107
177
|
(this.lockService =
|
|
108
178
|
accessory.getService(this.platform.Service.LockMechanism) ||
|
|
@@ -111,11 +181,71 @@ class Bot {
|
|
|
111
181
|
this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
112
182
|
this.lockService.getCharacteristic(this.platform.Characteristic.LockTargetState).onSet(this.handleOnSet.bind(this));
|
|
113
183
|
}
|
|
184
|
+
else if (device.bot?.deviceType === 'faucet') {
|
|
185
|
+
this.removeFanService(accessory);
|
|
186
|
+
this.removeLockService(accessory);
|
|
187
|
+
this.removeDoorService(accessory);
|
|
188
|
+
this.removeOutletService(accessory);
|
|
189
|
+
this.removeSwitchService(accessory);
|
|
190
|
+
this.removeWindowService(accessory);
|
|
191
|
+
this.removeGarageDoorService(accessory);
|
|
192
|
+
this.removeWindowCoveringService(accessory);
|
|
193
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
194
|
+
// Add switchService
|
|
195
|
+
(this.faucetService =
|
|
196
|
+
accessory.getService(this.platform.Service.Faucet) ||
|
|
197
|
+
accessory.addService(this.platform.Service.Faucet)), `${accessory.displayName} Faucet`;
|
|
198
|
+
this.infoLog(`Bot: ${accessory.displayName} Displaying as Faucet`);
|
|
199
|
+
this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
200
|
+
this.faucetService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.handleOnSet.bind(this));
|
|
201
|
+
}
|
|
202
|
+
else if (device.bot?.deviceType === 'fan') {
|
|
203
|
+
this.removeLockService(accessory);
|
|
204
|
+
this.removeDoorService(accessory);
|
|
205
|
+
this.removeFaucetService(accessory);
|
|
206
|
+
this.removeOutletService(accessory);
|
|
207
|
+
this.removeSwitchService(accessory);
|
|
208
|
+
this.removeWindowService(accessory);
|
|
209
|
+
this.removeGarageDoorService(accessory);
|
|
210
|
+
this.removeWindowCoveringService(accessory);
|
|
211
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
212
|
+
// Add switchService
|
|
213
|
+
(this.fanService =
|
|
214
|
+
accessory.getService(this.platform.Service.Fan) ||
|
|
215
|
+
accessory.addService(this.platform.Service.Fan)), `${accessory.displayName} Fan`;
|
|
216
|
+
this.infoLog(`Bot: ${accessory.displayName} Displaying as Fan`);
|
|
217
|
+
this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
218
|
+
this.fanService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
|
|
219
|
+
}
|
|
220
|
+
else if (device.bot?.deviceType === 'stateful') {
|
|
221
|
+
this.removeFanService(accessory);
|
|
222
|
+
this.removeLockService(accessory);
|
|
223
|
+
this.removeDoorService(accessory);
|
|
224
|
+
this.removeFaucetService(accessory);
|
|
225
|
+
this.removeOutletService(accessory);
|
|
226
|
+
this.removeSwitchService(accessory);
|
|
227
|
+
this.removeWindowService(accessory);
|
|
228
|
+
this.removeGarageDoorService(accessory);
|
|
229
|
+
this.removeWindowCoveringService(accessory);
|
|
230
|
+
// Add switchService
|
|
231
|
+
(this.statefulProgrammableSwitchService =
|
|
232
|
+
accessory.getService(this.platform.Service.StatefulProgrammableSwitch) ||
|
|
233
|
+
accessory.addService(this.platform.Service.StatefulProgrammableSwitch)), `${accessory.displayName} Stateful Programmable Switch`;
|
|
234
|
+
this.infoLog(`Bot: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
235
|
+
this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
236
|
+
this.statefulProgrammableSwitchService.getCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState)
|
|
237
|
+
.onSet(this.handleOnSet.bind(this));
|
|
238
|
+
}
|
|
114
239
|
else {
|
|
240
|
+
this.removeFanService(accessory);
|
|
115
241
|
this.removeLockService(accessory);
|
|
116
242
|
this.removeDoorService(accessory);
|
|
243
|
+
this.removeFaucetService(accessory);
|
|
117
244
|
this.removeSwitchService(accessory);
|
|
245
|
+
this.removeWindowService(accessory);
|
|
118
246
|
this.removeGarageDoorService(accessory);
|
|
247
|
+
this.removeWindowCoveringService(accessory);
|
|
248
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
119
249
|
// Add outletService
|
|
120
250
|
(this.outletService =
|
|
121
251
|
accessory.getService(this.platform.Service.Outlet) ||
|
|
@@ -168,42 +298,82 @@ class Bot {
|
|
|
168
298
|
}
|
|
169
299
|
removeOutletService(accessory) {
|
|
170
300
|
// If outletService still pressent, then remove first
|
|
301
|
+
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
171
302
|
if (this.outletService) {
|
|
172
|
-
this.
|
|
303
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
173
304
|
}
|
|
174
|
-
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
175
305
|
accessory.removeService(this.outletService);
|
|
176
306
|
}
|
|
177
307
|
removeGarageDoorService(accessory) {
|
|
178
308
|
// If garageDoorService still pressent, then remove first
|
|
309
|
+
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
179
310
|
if (this.garageDoorService) {
|
|
180
|
-
this.
|
|
311
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
181
312
|
}
|
|
182
|
-
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
183
313
|
accessory.removeService(this.garageDoorService);
|
|
184
314
|
}
|
|
185
315
|
removeDoorService(accessory) {
|
|
186
316
|
// If doorService still pressent, then remove first
|
|
317
|
+
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
187
318
|
if (this.doorService) {
|
|
188
|
-
this.
|
|
319
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
|
|
189
320
|
}
|
|
190
|
-
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
191
321
|
accessory.removeService(this.doorService);
|
|
192
322
|
}
|
|
193
323
|
removeLockService(accessory) {
|
|
194
324
|
// If lockService still pressent, then remove first
|
|
325
|
+
this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
|
|
195
326
|
if (this.lockService) {
|
|
196
|
-
this.
|
|
327
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
197
328
|
}
|
|
198
|
-
this.lockService = this.accessory.getService(this.platform.Service.Door);
|
|
199
329
|
accessory.removeService(this.lockService);
|
|
200
330
|
}
|
|
331
|
+
removeFaucetService(accessory) {
|
|
332
|
+
// If faucetService still pressent, then remove first
|
|
333
|
+
this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
|
|
334
|
+
if (this.faucetService) {
|
|
335
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
336
|
+
}
|
|
337
|
+
accessory.removeService(this.faucetService);
|
|
338
|
+
}
|
|
339
|
+
removeFanService(accessory) {
|
|
340
|
+
// If fanService still pressent, then remove first
|
|
341
|
+
this.fanService = this.accessory.getService(this.platform.Service.Fan);
|
|
342
|
+
if (this.fanService) {
|
|
343
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
344
|
+
}
|
|
345
|
+
accessory.removeService(this.fanService);
|
|
346
|
+
}
|
|
347
|
+
removeWindowService(accessory) {
|
|
348
|
+
// If windowService still pressent, then remove first
|
|
349
|
+
this.windowService = this.accessory.getService(this.platform.Service.Window);
|
|
350
|
+
if (this.windowService) {
|
|
351
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
|
|
352
|
+
}
|
|
353
|
+
accessory.removeService(this.windowService);
|
|
354
|
+
}
|
|
355
|
+
removeWindowCoveringService(accessory) {
|
|
356
|
+
// If windowCoveringService still pressent, then remove first
|
|
357
|
+
this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
|
|
358
|
+
if (this.windowCoveringService) {
|
|
359
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
360
|
+
}
|
|
361
|
+
accessory.removeService(this.windowCoveringService);
|
|
362
|
+
}
|
|
363
|
+
removeStatefulProgrammableSwitchService(accessory) {
|
|
364
|
+
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
365
|
+
this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
|
|
366
|
+
if (this.statefulProgrammableSwitchService) {
|
|
367
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
368
|
+
}
|
|
369
|
+
accessory.removeService(this.statefulProgrammableSwitchService);
|
|
370
|
+
}
|
|
201
371
|
removeSwitchService(accessory) {
|
|
202
372
|
// If switchService still pressent, then remove first
|
|
373
|
+
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
203
374
|
if (this.switchService) {
|
|
204
|
-
this.
|
|
375
|
+
this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
205
376
|
}
|
|
206
|
-
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
207
377
|
accessory.removeService(this.switchService);
|
|
208
378
|
}
|
|
209
379
|
refreshRate() {
|
|
@@ -322,15 +492,19 @@ class Bot {
|
|
|
322
492
|
this.accessory.context.On = this.OnCached;
|
|
323
493
|
}
|
|
324
494
|
else {
|
|
325
|
-
if (this.deviceStatus.body.power === 'on') {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
|
|
495
|
+
/*if (this.deviceStatus.body.power === 'on') {
|
|
496
|
+
this.On = true;
|
|
497
|
+
this.OnCached = this.On;
|
|
498
|
+
this.accessory.context.On = this.OnCached;
|
|
499
|
+
} else {
|
|
500
|
+
this.On = false;
|
|
501
|
+
this.OnCached = this.On;
|
|
502
|
+
this.accessory.context.On = this.OnCached;
|
|
503
|
+
}*/
|
|
504
|
+
this.OnCached = this.On;
|
|
505
|
+
this.accessory.context.On = this.OnCached;
|
|
506
|
+
if (this.On === undefined) {
|
|
331
507
|
this.On = false;
|
|
332
|
-
this.OnCached = this.On;
|
|
333
|
-
this.accessory.context.On = this.OnCached;
|
|
334
508
|
}
|
|
335
509
|
}
|
|
336
510
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
@@ -376,68 +550,63 @@ class Bot {
|
|
|
376
550
|
// Convert to BLE Address
|
|
377
551
|
const switchbot = await this.connectBLE();
|
|
378
552
|
// Start to monitor advertisement packets
|
|
379
|
-
if (switchbot
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
this.connected = false;
|
|
399
|
-
this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
// Wait 2 seconds
|
|
403
|
-
return switchbot.wait(this.scanDuration * 1000);
|
|
404
|
-
}).then(async () => {
|
|
405
|
-
// Stop to monitor
|
|
406
|
-
switchbot.stopScan();
|
|
407
|
-
if (this.connected) {
|
|
408
|
-
this.parseStatus();
|
|
409
|
-
this.updateHomeKitCharacteristics();
|
|
553
|
+
if (switchbot === false) {
|
|
554
|
+
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection: ${switchbot}`);
|
|
555
|
+
}
|
|
556
|
+
switchbot.startScan({
|
|
557
|
+
model: 'H',
|
|
558
|
+
id: this.device.bleMac,
|
|
559
|
+
}).then(() => {
|
|
560
|
+
// Set an event hander
|
|
561
|
+
switchbot.onadvertisement = (ad) => {
|
|
562
|
+
this.serviceData = ad.serviceData;
|
|
563
|
+
this.mode = ad.serviceData.mode;
|
|
564
|
+
this.state = ad.serviceData.state;
|
|
565
|
+
this.battery = ad.serviceData.battery;
|
|
566
|
+
this.debugLog(`Bot: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
567
|
+
this.debugLog(`Bot: ${this.accessory.displayName}, model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},`
|
|
568
|
+
+ ` mode: ${ad.serviceData.mode}, state: ${ad.serviceData.state}, battery: ${ad.serviceData.battery}`);
|
|
569
|
+
if (this.serviceData) {
|
|
570
|
+
this.connected = true;
|
|
571
|
+
this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
410
572
|
}
|
|
411
573
|
else {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}).catch(async (e) => {
|
|
415
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
416
|
-
if (this.deviceLogging === 'debug') {
|
|
417
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
418
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
419
|
-
}
|
|
420
|
-
if (this.platform.debugMode) {
|
|
421
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
422
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
574
|
+
this.connected = false;
|
|
575
|
+
this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
423
576
|
}
|
|
577
|
+
};
|
|
578
|
+
// Wait 2 seconds
|
|
579
|
+
return switchbot.wait(this.scanDuration * 1000);
|
|
580
|
+
}).then(async () => {
|
|
581
|
+
// Stop to monitor
|
|
582
|
+
switchbot.stopScan();
|
|
583
|
+
if (this.connected) {
|
|
584
|
+
this.parseStatus();
|
|
585
|
+
this.updateHomeKitCharacteristics();
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
424
589
|
if (this.platform.config.credentials?.openToken) {
|
|
425
590
|
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
426
591
|
await this.openAPIRefreshStatus();
|
|
427
592
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
593
|
+
}
|
|
594
|
+
}).catch(async (e) => {
|
|
595
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
596
|
+
if (this.deviceLogging === 'debug') {
|
|
597
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
598
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
599
|
+
}
|
|
600
|
+
if (this.platform.debugMode) {
|
|
601
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
602
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
603
|
+
}
|
|
604
|
+
if (this.platform.config.credentials?.openToken) {
|
|
605
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
606
|
+
await this.openAPIRefreshStatus();
|
|
607
|
+
}
|
|
608
|
+
this.apiError(e);
|
|
609
|
+
});
|
|
441
610
|
}
|
|
442
611
|
async openAPIRefreshStatus() {
|
|
443
612
|
if (this.platform.config.credentials?.openToken) {
|
|
@@ -484,84 +653,84 @@ class Bot {
|
|
|
484
653
|
});
|
|
485
654
|
}
|
|
486
655
|
async BLEpushChanges() {
|
|
656
|
+
this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.OnCached}`);
|
|
487
657
|
if (this.On !== this.OnCached) {
|
|
488
658
|
this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges`);
|
|
489
659
|
const switchbot = await this.connectBLE();
|
|
490
|
-
if (switchbot !== false) {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
else {
|
|
507
|
-
this.outletService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
508
|
-
}
|
|
509
|
-
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}, Switch Timeout`);
|
|
510
|
-
}, 500);
|
|
511
|
-
}).catch(async (e) => {
|
|
512
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
513
|
-
if (this.deviceLogging === 'debug') {
|
|
514
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
515
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
516
|
-
}
|
|
517
|
-
if (this.platform.debugMode) {
|
|
518
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
519
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
520
|
-
}
|
|
521
|
-
if (this.platform.config.credentials?.openToken) {
|
|
522
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
523
|
-
await this.openAPIpushChanges();
|
|
524
|
-
}
|
|
525
|
-
this.apiError(e);
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
else if (this.botMode === 'switch') {
|
|
529
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Press Mode: ${this.botMode}`);
|
|
530
|
-
switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac }).then((device_list) => {
|
|
531
|
-
this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
532
|
-
return this.turnOnOff(device_list);
|
|
533
|
-
}).then(() => {
|
|
534
|
-
this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
|
|
535
|
-
this.OnCached = this.On;
|
|
536
|
-
this.accessory.context.On = this.OnCached;
|
|
537
|
-
}).catch(async (e) => {
|
|
538
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
539
|
-
if (this.deviceLogging === 'debug') {
|
|
540
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
541
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
542
|
-
}
|
|
543
|
-
if (this.platform.debugMode) {
|
|
544
|
-
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
545
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
660
|
+
//if (switchbot !== false) {
|
|
661
|
+
if (this.botMode === 'press') {
|
|
662
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
663
|
+
switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac })
|
|
664
|
+
.then((device_list) => {
|
|
665
|
+
this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
666
|
+
return device_list[0].press({ id: this.device.bleMac });
|
|
667
|
+
}).then(() => {
|
|
668
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
|
|
669
|
+
this.On = false;
|
|
670
|
+
this.OnCached = this.On;
|
|
671
|
+
this.accessory.context.On = this.OnCached;
|
|
672
|
+
setTimeout(() => {
|
|
673
|
+
if (this.device.bot?.deviceType === 'switch') {
|
|
674
|
+
this.switchService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
546
675
|
}
|
|
547
|
-
|
|
548
|
-
this.
|
|
549
|
-
await this.openAPIpushChanges();
|
|
676
|
+
else {
|
|
677
|
+
this.outletService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
550
678
|
}
|
|
551
|
-
this.
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
679
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}, Switch Timeout`);
|
|
680
|
+
}, 500);
|
|
681
|
+
}).catch(async (e) => {
|
|
682
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
683
|
+
if (this.deviceLogging === 'debug') {
|
|
684
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
685
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
686
|
+
}
|
|
687
|
+
if (this.platform.debugMode) {
|
|
688
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
689
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
690
|
+
}
|
|
691
|
+
if (this.platform.config.credentials?.openToken) {
|
|
692
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
693
|
+
await this.openAPIpushChanges();
|
|
694
|
+
}
|
|
695
|
+
this.apiError(e);
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
else if (this.botMode === 'switch') {
|
|
699
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Press Mode: ${this.botMode}`);
|
|
700
|
+
switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac }).then((device_list) => {
|
|
701
|
+
this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
702
|
+
return this.turnOnOff(device_list);
|
|
703
|
+
}).then(() => {
|
|
704
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
|
|
705
|
+
this.OnCached = this.On;
|
|
706
|
+
this.accessory.context.On = this.OnCached;
|
|
707
|
+
}).catch(async (e) => {
|
|
708
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
709
|
+
if (this.deviceLogging === 'debug') {
|
|
710
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
711
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
712
|
+
}
|
|
713
|
+
if (this.platform.debugMode) {
|
|
714
|
+
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
715
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
716
|
+
}
|
|
717
|
+
if (this.platform.config.credentials?.openToken) {
|
|
718
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
719
|
+
await this.openAPIpushChanges();
|
|
720
|
+
}
|
|
721
|
+
this.apiError(e);
|
|
722
|
+
});
|
|
557
723
|
}
|
|
558
724
|
else {
|
|
559
|
-
|
|
560
|
-
if (this.platform.config.credentials?.openToken) {
|
|
561
|
-
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
562
|
-
await this.openAPIpushChanges();
|
|
563
|
-
}
|
|
725
|
+
throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
564
726
|
}
|
|
727
|
+
/* } else {
|
|
728
|
+
this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
729
|
+
if (this.platform.config.credentials?.openToken) {
|
|
730
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
731
|
+
await this.openAPIpushChanges();
|
|
732
|
+
}
|
|
733
|
+
}*/
|
|
565
734
|
}
|
|
566
735
|
this.OnCached = this.On;
|
|
567
736
|
this.accessory.context.On = this.OnCached;
|
|
@@ -667,24 +836,114 @@ class Bot {
|
|
|
667
836
|
}
|
|
668
837
|
this.debugLog(`Bot: ${this.accessory.displayName} Door On: ${this.On}`);
|
|
669
838
|
}
|
|
839
|
+
else if (this.device.bot?.deviceType === 'window') {
|
|
840
|
+
if (this.On === undefined) {
|
|
841
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
844
|
+
if (this.On) {
|
|
845
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
|
|
846
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
|
|
847
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
848
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
|
|
852
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
|
|
853
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
854
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Window On: ${this.On}`);
|
|
858
|
+
}
|
|
859
|
+
else if (this.device.bot?.deviceType === 'windowcovering') {
|
|
860
|
+
if (this.On === undefined) {
|
|
861
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
if (this.On) {
|
|
865
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
|
|
866
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
|
|
867
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
868
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
869
|
+
}
|
|
870
|
+
else {
|
|
871
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
|
|
872
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
|
|
873
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
874
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Window Covering On: ${this.On}`);
|
|
878
|
+
}
|
|
670
879
|
else if (this.device.bot?.deviceType === 'lock') {
|
|
671
880
|
if (this.On === undefined) {
|
|
672
881
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
673
882
|
}
|
|
674
883
|
else {
|
|
675
884
|
if (this.On) {
|
|
676
|
-
this.
|
|
677
|
-
this.
|
|
885
|
+
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, this.platform.Characteristic.LockTargetState.UNSECURED);
|
|
886
|
+
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState, this.platform.Characteristic.LockCurrentState.UNSECURED);
|
|
678
887
|
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`);
|
|
679
888
|
}
|
|
680
889
|
else {
|
|
681
|
-
this.
|
|
682
|
-
this.
|
|
890
|
+
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, this.platform.Characteristic.LockTargetState.SECURED);
|
|
891
|
+
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState, this.platform.Characteristic.LockCurrentState.SECURED);
|
|
683
892
|
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`);
|
|
684
893
|
}
|
|
685
894
|
}
|
|
686
895
|
this.debugLog(`Bot: ${this.accessory.displayName} Lock On: ${this.On}`);
|
|
687
896
|
}
|
|
897
|
+
else if (this.device.bot?.deviceType === 'faucet') {
|
|
898
|
+
if (this.On === undefined) {
|
|
899
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
900
|
+
}
|
|
901
|
+
else {
|
|
902
|
+
if (this.On) {
|
|
903
|
+
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE);
|
|
904
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
905
|
+
}
|
|
906
|
+
else {
|
|
907
|
+
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.INACTIVE);
|
|
908
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Faucet On: ${this.On}`);
|
|
912
|
+
}
|
|
913
|
+
else if (this.device.bot?.deviceType === 'fan') {
|
|
914
|
+
if (this.On === undefined) {
|
|
915
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
if (this.On) {
|
|
919
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
920
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
921
|
+
}
|
|
922
|
+
else {
|
|
923
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
924
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Fan On: ${this.On}`);
|
|
928
|
+
}
|
|
929
|
+
else if (this.device.bot?.deviceType === 'stateful') {
|
|
930
|
+
if (this.On === undefined) {
|
|
931
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
if (this.On) {
|
|
935
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
936
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
937
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`);
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
941
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
942
|
+
this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
this.debugLog(`Bot: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
|
|
946
|
+
}
|
|
688
947
|
else if (this.device.bot?.deviceType === 'switch') {
|
|
689
948
|
if (this.On === undefined) {
|
|
690
949
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
@@ -731,10 +990,30 @@ class Bot {
|
|
|
731
990
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
732
991
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
733
992
|
}
|
|
993
|
+
else if (this.device.bot?.deviceType === 'window') {
|
|
994
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
995
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
996
|
+
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
997
|
+
}
|
|
998
|
+
else if (this.device.bot?.deviceType === 'windowcovering') {
|
|
999
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
1000
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
1001
|
+
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, e);
|
|
1002
|
+
}
|
|
734
1003
|
else if (this.device.bot?.deviceType === 'lock') {
|
|
735
1004
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, e);
|
|
736
1005
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
|
|
737
1006
|
}
|
|
1007
|
+
else if (this.device.bot?.deviceType === 'faucet') {
|
|
1008
|
+
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
1009
|
+
}
|
|
1010
|
+
else if (this.device.bot?.deviceType === 'fan') {
|
|
1011
|
+
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
1012
|
+
}
|
|
1013
|
+
else if (this.device.bot?.deviceType === 'stateful') {
|
|
1014
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, e);
|
|
1015
|
+
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, e);
|
|
1016
|
+
}
|
|
738
1017
|
else if (this.device.bot?.deviceType === 'switch') {
|
|
739
1018
|
this.switchService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
740
1019
|
}
|
|
@@ -801,9 +1080,11 @@ class Bot {
|
|
|
801
1080
|
this.On = true;
|
|
802
1081
|
}
|
|
803
1082
|
}
|
|
804
|
-
else if (this.device.bot?.deviceType === 'door'
|
|
1083
|
+
else if (this.device.bot?.deviceType === 'door'
|
|
1084
|
+
|| this.device.bot?.deviceType === 'window'
|
|
1085
|
+
|| this.device.bot?.deviceType === 'windowcovering') {
|
|
805
1086
|
this.debugLog(`Bot: ${this.accessory.displayName} TargetPosition: ${value}`);
|
|
806
|
-
if (value ===
|
|
1087
|
+
if (value === 0) {
|
|
807
1088
|
this.On = false;
|
|
808
1089
|
}
|
|
809
1090
|
else {
|
|
@@ -819,6 +1100,24 @@ class Bot {
|
|
|
819
1100
|
this.On = true;
|
|
820
1101
|
}
|
|
821
1102
|
}
|
|
1103
|
+
else if (this.device.bot?.deviceType === 'faucet') {
|
|
1104
|
+
this.debugLog(`Bot: ${this.accessory.displayName} Active: ${value}`);
|
|
1105
|
+
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
1106
|
+
this.On = false;
|
|
1107
|
+
}
|
|
1108
|
+
else {
|
|
1109
|
+
this.On = true;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
else if (this.device.bot?.deviceType === 'stateful') {
|
|
1113
|
+
this.debugLog(`Bot: ${this.accessory.displayName} ProgrammableSwitchOutputState: ${value}`);
|
|
1114
|
+
if (value === 0) {
|
|
1115
|
+
this.On = false;
|
|
1116
|
+
}
|
|
1117
|
+
else {
|
|
1118
|
+
this.On = true;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
822
1121
|
else {
|
|
823
1122
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${value}`);
|
|
824
1123
|
this.On = value;
|