@switchbot/homebridge-switchbot 1.6.4-beta.4 → 1.7.1-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/CHANGELOG.md +18 -2
- package/config.schema.json +79 -0
- package/dist/devices/bots.d.ts +17 -7
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +324 -20
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/contact.d.ts +9 -0
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +109 -30
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +1 -1
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/motion.d.ts +9 -1
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +115 -40
- package/dist/devices/motion.js.map +1 -1
- package/dist/settings.d.ts +8 -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 +324 -20
- package/src/devices/contact.ts +109 -29
- package/src/devices/curtains.ts +1 -1
- package/src/devices/motion.ts +122 -46
- package/src/settings.ts +9 -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}`);
|
|
@@ -721,6 +911,44 @@ export class Bot {
|
|
|
721
911
|
}
|
|
722
912
|
}
|
|
723
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}`);
|
|
724
952
|
} else if (this.device.bot?.deviceType === 'lock') {
|
|
725
953
|
if (this.On === undefined) {
|
|
726
954
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
@@ -740,6 +968,51 @@ export class Bot {
|
|
|
740
968
|
}
|
|
741
969
|
}
|
|
742
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}`);
|
|
743
1016
|
} else if (this.device.bot?.deviceType === 'switch') {
|
|
744
1017
|
if (this.On === undefined) {
|
|
745
1018
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
@@ -780,9 +1053,24 @@ export class Bot {
|
|
|
780
1053
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, e);
|
|
781
1054
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, e);
|
|
782
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);
|
|
783
1064
|
} else if (this.device.bot?.deviceType === 'lock') {
|
|
784
1065
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, e);
|
|
785
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);
|
|
786
1074
|
} else if (this.device.bot?.deviceType === 'switch') {
|
|
787
1075
|
this.switchService?.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
788
1076
|
} else {
|
|
@@ -848,9 +1136,11 @@ export class Bot {
|
|
|
848
1136
|
} else {
|
|
849
1137
|
this.On = true;
|
|
850
1138
|
}
|
|
851
|
-
} 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') {
|
|
852
1142
|
this.debugLog(`Bot: ${this.accessory.displayName} TargetPosition: ${value}`);
|
|
853
|
-
if (value ===
|
|
1143
|
+
if (value === 0) {
|
|
854
1144
|
this.On = false;
|
|
855
1145
|
} else {
|
|
856
1146
|
this.On = true;
|
|
@@ -862,6 +1152,20 @@ export class Bot {
|
|
|
862
1152
|
} else {
|
|
863
1153
|
this.On = true;
|
|
864
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
|
+
}
|
|
865
1169
|
} else {
|
|
866
1170
|
this.debugLog(`Bot: ${this.accessory.displayName} On: ${value}`);
|
|
867
1171
|
this.On = value;
|