@switchbot/homebridge-switchbot 3.6.1-beta.0 → 3.6.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/config.schema.json +11 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +36 -18
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -2
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +186 -396
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +36 -19
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +36 -19
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +36 -19
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +37 -18
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.js +2 -2
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +36 -19
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +36 -17
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +36 -17
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +36 -17
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +36 -17
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +37 -18
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +36 -17
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +36 -17
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +36 -17
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +37 -18
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +36 -17
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +36 -17
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -0
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +186 -228
- package/dist/irdevice/other.js.map +1 -1
- package/dist/platform.d.ts +4 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +32 -0
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +33 -18
- package/src/device/bot.ts +179 -406
- package/src/device/ceilinglight.ts +33 -20
- package/src/device/colorbulb.ts +33 -20
- package/src/device/contact.ts +33 -20
- package/src/device/curtain.ts +34 -18
- package/src/device/device.ts +2 -2
- package/src/device/fan.ts +33 -20
- package/src/device/hub.ts +33 -17
- package/src/device/humidifier.ts +33 -17
- package/src/device/iosensor.ts +33 -17
- package/src/device/lightstrip.ts +33 -17
- package/src/device/lock.ts +34 -18
- package/src/device/meter.ts +33 -17
- package/src/device/meterplus.ts +33 -17
- package/src/device/motion.ts +33 -17
- package/src/device/plug.ts +34 -18
- package/src/device/robotvacuumcleaner.ts +33 -17
- package/src/device/waterdetector.ts +33 -17
- package/src/irdevice/other.ts +214 -283
- package/src/platform.ts +30 -0
- package/src/settings.ts +1 -0
package/dist/device/bot.js
CHANGED
|
@@ -24,6 +24,7 @@ export class Bot extends deviceBase {
|
|
|
24
24
|
Fan;
|
|
25
25
|
StatefulProgrammableSwitch;
|
|
26
26
|
Outlet;
|
|
27
|
+
On;
|
|
27
28
|
// OpenAPI
|
|
28
29
|
deviceStatus;
|
|
29
30
|
//Webhook
|
|
@@ -71,18 +72,13 @@ export class Bot extends deviceBase {
|
|
|
71
72
|
this.Switch = {
|
|
72
73
|
Name: accessory.context.Switch.Name ?? accessory.displayName,
|
|
73
74
|
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch),
|
|
74
|
-
On: accessory.context.On ?? false,
|
|
75
75
|
};
|
|
76
76
|
accessory.context.Switch = this.Switch;
|
|
77
77
|
this.debugLog('Displaying as Switch');
|
|
78
78
|
// Initialize Switch Characteristics
|
|
79
79
|
this.Switch.Service
|
|
80
80
|
.setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name)
|
|
81
|
-
.setCharacteristic(this.hap.Characteristic.On, this.Switch.On)
|
|
82
81
|
.getCharacteristic(this.hap.Characteristic.On)
|
|
83
|
-
.onGet(() => {
|
|
84
|
-
return this.Switch.On;
|
|
85
|
-
})
|
|
86
82
|
.onSet(this.OnSet.bind(this));
|
|
87
83
|
// Remove other services
|
|
88
84
|
this.removeFanService(accessory);
|
|
@@ -103,7 +99,6 @@ export class Bot extends deviceBase {
|
|
|
103
99
|
this.GarageDoor = {
|
|
104
100
|
Name: accessory.context.GarageDoor.Name ?? accessory.displayName,
|
|
105
101
|
Service: accessory.getService(this.hap.Service.GarageDoorOpener) ?? accessory.addService(this.hap.Service.GarageDoorOpener),
|
|
106
|
-
On: accessory.context.On ?? false,
|
|
107
102
|
};
|
|
108
103
|
accessory.context.GarageDoor = this.GarageDoor;
|
|
109
104
|
this.debugLog('Displaying as Garage Door Opener');
|
|
@@ -111,14 +106,12 @@ export class Bot extends deviceBase {
|
|
|
111
106
|
this.GarageDoor.Service
|
|
112
107
|
.setCharacteristic(this.hap.Characteristic.Name, this.GarageDoor.Name)
|
|
113
108
|
.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false)
|
|
114
|
-
.getCharacteristic(this.hap.Characteristic.TargetDoorState)
|
|
109
|
+
.getCharacteristic(this.hap.Characteristic.TargetDoorState)
|
|
110
|
+
.setProps({
|
|
115
111
|
validValues: [0, 100],
|
|
116
112
|
minValue: 0,
|
|
117
113
|
maxValue: 100,
|
|
118
114
|
minStep: 100,
|
|
119
|
-
})
|
|
120
|
-
.onGet(() => {
|
|
121
|
-
return this.GarageDoor.On;
|
|
122
115
|
})
|
|
123
116
|
.onSet(this.OnSet.bind(this));
|
|
124
117
|
// Remove other services
|
|
@@ -140,7 +133,6 @@ export class Bot extends deviceBase {
|
|
|
140
133
|
this.Door = {
|
|
141
134
|
Name: accessory.context.Door.Name ?? accessory.displayName,
|
|
142
135
|
Service: accessory.getService(this.hap.Service.Door) ?? accessory.addService(this.hap.Service.Door),
|
|
143
|
-
On: accessory.context.On ?? false,
|
|
144
136
|
};
|
|
145
137
|
accessory.context.Door = this.Door;
|
|
146
138
|
this.debugLog('Displaying as Door');
|
|
@@ -153,9 +145,6 @@ export class Bot extends deviceBase {
|
|
|
153
145
|
minValue: 0,
|
|
154
146
|
maxValue: 100,
|
|
155
147
|
minStep: 100,
|
|
156
|
-
})
|
|
157
|
-
.onGet(() => {
|
|
158
|
-
return this.Door.On;
|
|
159
148
|
})
|
|
160
149
|
.onSet(this.OnSet.bind(this));
|
|
161
150
|
// Remove other services
|
|
@@ -177,7 +166,6 @@ export class Bot extends deviceBase {
|
|
|
177
166
|
this.Window = {
|
|
178
167
|
Name: accessory.context.Window.Name ?? accessory.displayName,
|
|
179
168
|
Service: accessory.getService(this.hap.Service.Window) ?? accessory.addService(this.hap.Service.Window),
|
|
180
|
-
On: accessory.context.On ?? false,
|
|
181
169
|
};
|
|
182
170
|
accessory.context.Window = this.Window;
|
|
183
171
|
this.debugLog('Displaying as Window');
|
|
@@ -190,9 +178,6 @@ export class Bot extends deviceBase {
|
|
|
190
178
|
minValue: 0,
|
|
191
179
|
maxValue: 100,
|
|
192
180
|
minStep: 100,
|
|
193
|
-
})
|
|
194
|
-
.onGet(() => {
|
|
195
|
-
return this.Window.On;
|
|
196
181
|
})
|
|
197
182
|
.onSet(this.OnSet.bind(this));
|
|
198
183
|
// Remove other services
|
|
@@ -214,7 +199,6 @@ export class Bot extends deviceBase {
|
|
|
214
199
|
this.WindowCovering = {
|
|
215
200
|
Name: accessory.context.WindowCovering.Name ?? accessory.displayName,
|
|
216
201
|
Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering),
|
|
217
|
-
On: accessory.context.On ?? false,
|
|
218
202
|
};
|
|
219
203
|
accessory.context.WindowCovering = this.WindowCovering;
|
|
220
204
|
this.debugLog('Displaying as Window Covering');
|
|
@@ -222,14 +206,12 @@ export class Bot extends deviceBase {
|
|
|
222
206
|
this.WindowCovering.Service
|
|
223
207
|
.setCharacteristic(this.hap.Characteristic.Name, this.WindowCovering.Name)
|
|
224
208
|
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
225
|
-
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
209
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition)
|
|
210
|
+
.setProps({
|
|
226
211
|
validValues: [0, 100],
|
|
227
212
|
minValue: 0,
|
|
228
213
|
maxValue: 100,
|
|
229
214
|
minStep: 100,
|
|
230
|
-
})
|
|
231
|
-
.onGet(() => {
|
|
232
|
-
return this.WindowCovering.On;
|
|
233
215
|
})
|
|
234
216
|
.onSet(this.OnSet.bind(this));
|
|
235
217
|
// Remove other services
|
|
@@ -251,17 +233,14 @@ export class Bot extends deviceBase {
|
|
|
251
233
|
this.LockMechanism = {
|
|
252
234
|
Name: accessory.context.LockMechanism.Name ?? accessory.displayName,
|
|
253
235
|
Service: accessory.getService(this.hap.Service.LockMechanism) ?? accessory.addService(this.hap.Service.LockMechanism),
|
|
254
|
-
On: accessory.context.On ?? false,
|
|
255
236
|
};
|
|
256
237
|
accessory.context.LockMechanism = this.LockMechanism;
|
|
257
238
|
this.debugLog('Displaying as Lock');
|
|
258
239
|
// Initialize Lock Characteristics
|
|
259
240
|
this.LockMechanism.Service
|
|
260
241
|
.setCharacteristic(this.hap.Characteristic.Name, this.LockMechanism.Name)
|
|
242
|
+
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
261
243
|
.getCharacteristic(this.hap.Characteristic.LockTargetState)
|
|
262
|
-
.onGet(() => {
|
|
263
|
-
return this.LockMechanism.On;
|
|
264
|
-
})
|
|
265
244
|
.onSet(this.OnSet.bind(this));
|
|
266
245
|
// Remove other services
|
|
267
246
|
this.removeFanService(accessory);
|
|
@@ -282,7 +261,6 @@ export class Bot extends deviceBase {
|
|
|
282
261
|
this.Faucet = {
|
|
283
262
|
Name: accessory.context.Faucet.Name ?? accessory.displayName,
|
|
284
263
|
Service: accessory.getService(this.hap.Service.Faucet) ?? accessory.addService(this.hap.Service.Faucet),
|
|
285
|
-
On: accessory.context.On ?? false,
|
|
286
264
|
};
|
|
287
265
|
accessory.context.Faucet = this.Faucet;
|
|
288
266
|
this.debugLog('Displaying as Faucet');
|
|
@@ -290,9 +268,6 @@ export class Bot extends deviceBase {
|
|
|
290
268
|
this.Faucet.Service
|
|
291
269
|
.setCharacteristic(this.hap.Characteristic.Name, this.Faucet.Name)
|
|
292
270
|
.getCharacteristic(this.hap.Characteristic.Active)
|
|
293
|
-
.onGet(() => {
|
|
294
|
-
return this.Faucet.On;
|
|
295
|
-
})
|
|
296
271
|
.onSet(this.OnSet.bind(this));
|
|
297
272
|
// Remove other services
|
|
298
273
|
this.removeFanService(accessory);
|
|
@@ -313,17 +288,13 @@ export class Bot extends deviceBase {
|
|
|
313
288
|
this.Fan = {
|
|
314
289
|
Name: accessory.context.Fan.Name ?? accessory.displayName,
|
|
315
290
|
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2),
|
|
316
|
-
On: accessory.context.On ?? false,
|
|
317
291
|
};
|
|
318
292
|
accessory.context.Fan = this.Fan;
|
|
319
293
|
this.debugLog('Displaying as Fan');
|
|
320
294
|
// Initialize Fan Characteristics
|
|
321
295
|
this.Fan.Service
|
|
322
296
|
.setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name)
|
|
323
|
-
.getCharacteristic(this.hap.Characteristic.
|
|
324
|
-
.onGet(() => {
|
|
325
|
-
return this.Fan.On;
|
|
326
|
-
})
|
|
297
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
327
298
|
.onSet(this.OnSet.bind(this));
|
|
328
299
|
// Remove other services
|
|
329
300
|
this.removeLockService(accessory);
|
|
@@ -345,7 +316,6 @@ export class Bot extends deviceBase {
|
|
|
345
316
|
Name: accessory.context.StatefulProgrammableSwitch.Name ?? accessory.displayName,
|
|
346
317
|
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
347
318
|
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch),
|
|
348
|
-
On: accessory.context.On ?? false,
|
|
349
319
|
};
|
|
350
320
|
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch;
|
|
351
321
|
this.debugLog('Displaying as Stateful Programmable Switch');
|
|
@@ -353,9 +323,6 @@ export class Bot extends deviceBase {
|
|
|
353
323
|
this.StatefulProgrammableSwitch.Service
|
|
354
324
|
.setCharacteristic(this.hap.Characteristic.Name, this.StatefulProgrammableSwitch.Name)
|
|
355
325
|
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
356
|
-
.onGet(() => {
|
|
357
|
-
return this.StatefulProgrammableSwitch.On;
|
|
358
|
-
})
|
|
359
326
|
.onSet(this.OnSet.bind(this));
|
|
360
327
|
// Remove other services
|
|
361
328
|
this.removeFanService(accessory);
|
|
@@ -368,7 +335,7 @@ export class Bot extends deviceBase {
|
|
|
368
335
|
this.removeGarageDoorService(accessory);
|
|
369
336
|
this.removeWindowCoveringService(accessory);
|
|
370
337
|
}
|
|
371
|
-
else {
|
|
338
|
+
else if (this.botDeviceType === 'outlet') {
|
|
372
339
|
// Set category
|
|
373
340
|
accessory.category = 7 /* this.hap.Categories.OUTLET */;
|
|
374
341
|
// Initialize Switch property
|
|
@@ -376,7 +343,6 @@ export class Bot extends deviceBase {
|
|
|
376
343
|
this.Outlet = {
|
|
377
344
|
Name: accessory.context.Outlet.Name ?? accessory.displayName,
|
|
378
345
|
Service: accessory.getService(this.hap.Service.Outlet) ?? accessory.addService(this.hap.Service.Outlet),
|
|
379
|
-
On: accessory.context.On ?? false,
|
|
380
346
|
};
|
|
381
347
|
accessory.context.Outlet = this.Outlet;
|
|
382
348
|
this.debugLog('Displaying as Outlet');
|
|
@@ -384,9 +350,6 @@ export class Bot extends deviceBase {
|
|
|
384
350
|
this.Outlet.Service
|
|
385
351
|
.setCharacteristic(this.hap.Characteristic.Name, this.Outlet.Name)
|
|
386
352
|
.getCharacteristic(this.hap.Characteristic.On)
|
|
387
|
-
.onGet(() => {
|
|
388
|
-
return this.Outlet.On;
|
|
389
|
-
})
|
|
390
353
|
.onSet(this.OnSet.bind(this));
|
|
391
354
|
// Remove other services
|
|
392
355
|
this.removeFanService(accessory);
|
|
@@ -399,6 +362,9 @@ export class Bot extends deviceBase {
|
|
|
399
362
|
this.removeWindowCoveringService(accessory);
|
|
400
363
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
401
364
|
}
|
|
365
|
+
else {
|
|
366
|
+
this.errorLog('Device Type not set');
|
|
367
|
+
}
|
|
402
368
|
// Retrieve initial values and updateHomekit
|
|
403
369
|
this.debugLog('Retrieve initial values and update Homekit');
|
|
404
370
|
this.refreshStatus();
|
|
@@ -445,19 +411,10 @@ export class Bot extends deviceBase {
|
|
|
445
411
|
await this.debugLog(`(power, battery, deviceMode) = BLE:(${this.serviceData.state}, ${this.serviceData.battery}, ${this.serviceData.mode}),`
|
|
446
412
|
+ ` current:(${this.accessory.context.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
|
|
447
413
|
// BLEmode (true if Switch Mode) | (false if Press Mode)
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
this.setOn(Boolean(this.serviceData.state));
|
|
453
|
-
}
|
|
454
|
-
this.debugLog(`Switch Mode, mode: ${this.serviceData.mode}, On: ${this.accessory.context.On}`);
|
|
455
|
-
}
|
|
456
|
-
else {
|
|
457
|
-
this.setOn(false);
|
|
458
|
-
this.accessory.context.On = await this.getOn();
|
|
459
|
-
this.debugLog(`Press Mode, mode: ${this.serviceData.mode}, On: ${this.accessory.context.On}`);
|
|
460
|
-
}
|
|
414
|
+
this.On = this.serviceData.mode ? this.serviceData.state : false;
|
|
415
|
+
const mode = this.serviceData.mode ? 'Switch' : 'Press';
|
|
416
|
+
await this.debugLog(`${mode} Mode, On: ${this.accessory.context.On}`);
|
|
417
|
+
this.accessory.context.On = this.On;
|
|
461
418
|
// BatteryLevel
|
|
462
419
|
this.Battery.BatteryLevel = this.serviceData.battery;
|
|
463
420
|
await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
@@ -474,17 +431,8 @@ export class Bot extends deviceBase {
|
|
|
474
431
|
await this.debugLog(`(power, battery, deviceMode) = API:(${this.deviceStatus.power}, ${this.deviceStatus.battery}, ${this.botMode}),`
|
|
475
432
|
+ ` current:(${this.accessory.context.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
|
|
476
433
|
// On
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
this.accessory.context.On = await this.getOn();
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
this.setOn(this.deviceStatus.power === 'on' ? true : false);
|
|
483
|
-
this.accessory.context.On = await this.getOn();
|
|
484
|
-
if (this.getOn() === undefined) {
|
|
485
|
-
this.setOn(false);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
434
|
+
this.On = this.botMode === 'press' ? false : this.deviceStatus.power === 'on' ? true : false;
|
|
435
|
+
this.accessory.context.On = this.On;
|
|
488
436
|
await this.debugLog(`On: ${this.accessory.context.On}`);
|
|
489
437
|
// Battery Level
|
|
490
438
|
this.Battery.BatteryLevel = this.deviceStatus.battery;
|
|
@@ -510,13 +458,11 @@ export class Bot extends deviceBase {
|
|
|
510
458
|
}
|
|
511
459
|
async parseStatusWebhook() {
|
|
512
460
|
await this.debugLog('parseStatusWebhook');
|
|
513
|
-
const getOn = await this.getOn();
|
|
514
461
|
await this.debugLog(`(power, battery, deviceMode) = Webhook:(${this.webhookContext.power}, ${this.webhookContext.battery},`
|
|
515
|
-
+ ` ${this.webhookContext.deviceMode}), current:(${
|
|
462
|
+
+ ` ${this.webhookContext.deviceMode}), current:(${this.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
|
|
516
463
|
// On
|
|
517
|
-
|
|
518
|
-
await this.
|
|
519
|
-
await this.debugLog(`On: ${setOn}`);
|
|
464
|
+
this.On = this.webhookContext.power === 'on' ? true : false;
|
|
465
|
+
await this.debugLog(`On: ${this.On}`);
|
|
520
466
|
// BatteryLevel
|
|
521
467
|
this.Battery.BatteryLevel = this.webhookContext.battery;
|
|
522
468
|
await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
@@ -535,7 +481,7 @@ export class Bot extends deviceBase {
|
|
|
535
481
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
536
482
|
await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
537
483
|
}
|
|
538
|
-
else if (this.BLE) {
|
|
484
|
+
else if (this.BLE || this.config.options?.BLE) {
|
|
539
485
|
await this.BLERefreshStatus();
|
|
540
486
|
}
|
|
541
487
|
else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
@@ -548,26 +494,45 @@ export class Bot extends deviceBase {
|
|
|
548
494
|
}
|
|
549
495
|
async BLERefreshStatus() {
|
|
550
496
|
await this.debugLog('BLERefreshStatus');
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const serviceData = await this.monitorAdvertisementPackets(switchbot);
|
|
560
|
-
// Update HomeKit
|
|
561
|
-
if (serviceData.model === SwitchBotBLEModel.Bot && serviceData.modelName === SwitchBotBLEModelName.Bot) {
|
|
562
|
-
this.serviceData = serviceData;
|
|
497
|
+
if (this.config.options?.BLE) {
|
|
498
|
+
await this.debugLog('is listening to Platform BLE.');
|
|
499
|
+
this.device.bleMac = this.device.deviceId.match(/.{1,2}/g).join(':').toLowerCase();
|
|
500
|
+
await this.debugLog(`bleMac: ${this.device.bleMac}`);
|
|
501
|
+
this.platform.bleEventHandler[this.device.bleMac] = async (context) => {
|
|
502
|
+
try {
|
|
503
|
+
await this.debugLog(`received BLE: ${JSON.stringify(context)}`);
|
|
504
|
+
this.serviceData = context;
|
|
563
505
|
await this.BLEparseStatus();
|
|
564
506
|
await this.updateHomeKitCharacteristics();
|
|
565
507
|
}
|
|
566
|
-
|
|
567
|
-
await this.errorLog(`failed to
|
|
568
|
-
await this.BLERefreshConnection(switchbot);
|
|
508
|
+
catch (e) {
|
|
509
|
+
await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
569
510
|
}
|
|
570
|
-
}
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
await this.debugLog('is using Device BLE Scanning.');
|
|
515
|
+
const switchbot = await this.switchbotBLE();
|
|
516
|
+
if (switchbot === undefined) {
|
|
517
|
+
await this.BLERefreshConnection(switchbot);
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
// Start to monitor advertisement packets
|
|
521
|
+
(async () => {
|
|
522
|
+
// Start to monitor advertisement packets
|
|
523
|
+
const serviceData = await this.monitorAdvertisementPackets(switchbot);
|
|
524
|
+
// Update HomeKit
|
|
525
|
+
if (serviceData.model === SwitchBotBLEModel.Bot && serviceData.modelName === SwitchBotBLEModelName.Bot) {
|
|
526
|
+
this.serviceData = serviceData;
|
|
527
|
+
await this.BLEparseStatus();
|
|
528
|
+
await this.updateHomeKitCharacteristics();
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
|
|
532
|
+
await this.BLERefreshConnection(switchbot);
|
|
533
|
+
}
|
|
534
|
+
})();
|
|
535
|
+
}
|
|
571
536
|
}
|
|
572
537
|
}
|
|
573
538
|
async openAPIRefreshStatus() {
|
|
@@ -643,31 +608,26 @@ export class Bot extends deviceBase {
|
|
|
643
608
|
}
|
|
644
609
|
async BLEpushChanges() {
|
|
645
610
|
await this.debugLog('BLEpushChanges');
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
this.debugLog(`BLEpushChanges On: ${On} OnCached: ${this.accessory.context.On}`);
|
|
611
|
+
if (this.On !== this.accessory.context.On || this.allowPush) {
|
|
612
|
+
await this.debugLog(`BLEpushChanges On: ${this.On} OnCached: ${this.accessory.context.On}`);
|
|
649
613
|
const switchbot = await this.platform.connectBLE(this.accessory, this.device);
|
|
650
614
|
await this.convertBLEAddress();
|
|
651
615
|
//if (switchbot !== false) {
|
|
616
|
+
await this.debugLog(`Bot Mode: ${this.botMode}`);
|
|
652
617
|
if (this.botMode === 'press') {
|
|
653
|
-
this.debugLog(`Bot Mode: ${this.botMode}`);
|
|
654
618
|
switchbot
|
|
655
619
|
.discover({ model: 'H', quick: true, id: this.device.bleMac })
|
|
656
620
|
.then(async (device_list) => {
|
|
657
|
-
this.infoLog(`On: ${On}`);
|
|
621
|
+
await this.infoLog(`On: ${this.On}`);
|
|
658
622
|
return await device_list[0].press({ id: this.device.bleMac });
|
|
659
623
|
})
|
|
660
624
|
.then(async () => {
|
|
661
|
-
await this.successLog(`On: ${On} sent over SwitchBot BLE, sent successfully`);
|
|
625
|
+
await this.successLog(`On: ${this.On} sent over SwitchBot BLE, sent successfully`);
|
|
662
626
|
await this.updateHomeKitCharacteristics();
|
|
663
|
-
setTimeout(() => {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
}
|
|
667
|
-
else {
|
|
668
|
-
this.Outlet?.Service.getCharacteristic(this.hap.Characteristic.On).updateValue(On);
|
|
669
|
-
}
|
|
670
|
-
this.debugLog(`On: ${On}, Switch Timeout`);
|
|
627
|
+
setTimeout(async () => {
|
|
628
|
+
this.On = false;
|
|
629
|
+
await this.updateHomeKitCharacteristics();
|
|
630
|
+
this.debugLog(`On: ${this.On}, Switch Timeout`);
|
|
671
631
|
}, 500);
|
|
672
632
|
})
|
|
673
633
|
.catch(async (e) => {
|
|
@@ -677,15 +637,14 @@ export class Bot extends deviceBase {
|
|
|
677
637
|
});
|
|
678
638
|
}
|
|
679
639
|
else if (this.botMode === 'switch') {
|
|
680
|
-
this.debugLog(`Press Mode: ${this.botMode}`);
|
|
681
640
|
switchbot
|
|
682
641
|
.discover({ model: this.device.bleModel, quick: true, id: this.device.bleMac })
|
|
683
642
|
.then(async (device_list) => {
|
|
684
|
-
this.infoLog(`On: ${On}`);
|
|
643
|
+
this.infoLog(`On: ${this.On}`);
|
|
685
644
|
return await this.retryBLE({
|
|
686
645
|
max: await this.maxRetryBLE(),
|
|
687
646
|
fn: async () => {
|
|
688
|
-
if (On) {
|
|
647
|
+
if (this.On) {
|
|
689
648
|
return await device_list[0].turnOn({ id: this.device.bleMac });
|
|
690
649
|
}
|
|
691
650
|
else {
|
|
@@ -695,7 +654,7 @@ export class Bot extends deviceBase {
|
|
|
695
654
|
});
|
|
696
655
|
})
|
|
697
656
|
.then(async () => {
|
|
698
|
-
await this.successLog(`On: ${On} sent over SwitchBot BLE, sent successfully`);
|
|
657
|
+
await this.successLog(`On: ${this.On} sent over SwitchBot BLE, sent successfully`);
|
|
699
658
|
await this.updateHomeKitCharacteristics();
|
|
700
659
|
})
|
|
701
660
|
.catch(async (e) => {
|
|
@@ -709,32 +668,24 @@ export class Bot extends deviceBase {
|
|
|
709
668
|
}
|
|
710
669
|
}
|
|
711
670
|
else {
|
|
712
|
-
await this.debugLog(`No Changes (BLEpushChanges), On: ${On} OnCached: ${this.accessory.context.On}`);
|
|
671
|
+
await this.debugLog(`No Changes (BLEpushChanges), On: ${this.On} OnCached: ${this.accessory.context.On}`);
|
|
713
672
|
}
|
|
714
673
|
}
|
|
715
674
|
async openAPIpushChanges() {
|
|
716
675
|
await this.debugLog('openAPIpushChanges');
|
|
717
|
-
let On = await this.getOn();
|
|
718
676
|
if (this.multiPressCount > 0) {
|
|
719
677
|
await this.debugLog(`${this.multiPressCount} request(s) queued.`);
|
|
720
|
-
On = true;
|
|
721
678
|
}
|
|
722
|
-
if (On !== this.accessory.context.On || this.allowPush || this.multiPressCount > 0) {
|
|
679
|
+
if (this.On !== this.accessory.context.On || this.allowPush || this.multiPressCount > 0) {
|
|
723
680
|
let command = '';
|
|
724
|
-
if (this.botMode === 'switch'
|
|
725
|
-
command = 'turnOn';
|
|
726
|
-
|
|
727
|
-
await this.debugLog(`Switch Mode, Turning ${On}`);
|
|
728
|
-
}
|
|
729
|
-
else if (this.botMode === 'switch' && !On) {
|
|
730
|
-
command = 'turnOff';
|
|
731
|
-
On = false;
|
|
732
|
-
await this.debugLog(`Switch Mode, Turning ${On}`);
|
|
681
|
+
if (this.botMode === 'switch') {
|
|
682
|
+
command = this.On ? 'turnOn' : 'turnOff';
|
|
683
|
+
await this.debugLog(`Switch Mode, Command: ${command}`);
|
|
733
684
|
}
|
|
734
685
|
else if (this.botMode === 'press' || this.botMode === 'multipress') {
|
|
735
686
|
command = 'press';
|
|
736
687
|
await this.debugLog('Press Mode');
|
|
737
|
-
On = false;
|
|
688
|
+
this.On = false;
|
|
738
689
|
}
|
|
739
690
|
else {
|
|
740
691
|
throw new Error('Device Parameters not set for this Bot.');
|
|
@@ -761,7 +712,7 @@ export class Bot extends deviceBase {
|
|
|
761
712
|
this.multiPressCount--;
|
|
762
713
|
if (this.multiPressCount > 0) {
|
|
763
714
|
await this.debugLog(`multiPressCount: ${this.multiPressCount}`);
|
|
764
|
-
On = true;
|
|
715
|
+
this.On = true;
|
|
765
716
|
await this.openAPIpushChanges();
|
|
766
717
|
}
|
|
767
718
|
}
|
|
@@ -772,127 +723,69 @@ export class Bot extends deviceBase {
|
|
|
772
723
|
}
|
|
773
724
|
}
|
|
774
725
|
else {
|
|
775
|
-
await this.debugLog(`No Changes (openAPIpushChanges), On: ${On} OnCached: ${this.accessory.context.On}`);
|
|
726
|
+
await this.debugLog(`No Changes (openAPIpushChanges), On: ${this.On} OnCached: ${this.accessory.context.On}`);
|
|
776
727
|
}
|
|
777
728
|
}
|
|
778
729
|
/**
|
|
779
730
|
* Handle requests to set the "On" characteristic
|
|
780
731
|
*/
|
|
781
732
|
async OnSet(value) {
|
|
782
|
-
if (this.botDeviceType === '
|
|
733
|
+
if (this.botDeviceType === 'switch') {
|
|
734
|
+
if (this.Switch) {
|
|
735
|
+
await this.debugLog(`Set On: ${value}`);
|
|
736
|
+
this.On = value === false ? false : true;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
else if (this.botDeviceType === 'garagedoor') {
|
|
783
740
|
if (this.GarageDoor) {
|
|
784
741
|
await this.debugLog(`Set TargetDoorState: ${value}`);
|
|
785
|
-
this.
|
|
786
|
-
if (value === this.hap.Characteristic.TargetDoorState.CLOSED) {
|
|
787
|
-
await this.setOn(false);
|
|
788
|
-
this.GarageDoor.On = false;
|
|
789
|
-
}
|
|
790
|
-
else {
|
|
791
|
-
await this.setOn(true);
|
|
792
|
-
this.GarageDoor.On = true;
|
|
793
|
-
}
|
|
742
|
+
this.On = value === this.hap.Characteristic.TargetDoorState.CLOSED ? false : true;
|
|
794
743
|
}
|
|
795
744
|
}
|
|
796
745
|
else if (this.botDeviceType === 'door') {
|
|
797
746
|
if (this.Door) {
|
|
798
747
|
await this.debugLog(`Set TargetPosition: ${value}`);
|
|
799
|
-
|
|
800
|
-
await this.setOn(false);
|
|
801
|
-
this.Door.On = false;
|
|
802
|
-
}
|
|
803
|
-
else {
|
|
804
|
-
await this.setOn(true);
|
|
805
|
-
this.Door.On = true;
|
|
806
|
-
}
|
|
748
|
+
this.On = value === 0 ? false : true;
|
|
807
749
|
}
|
|
808
750
|
}
|
|
809
751
|
else if (this.botDeviceType === 'window') {
|
|
810
752
|
if (this.Window) {
|
|
811
753
|
await this.debugLog(`Set TargetPosition: ${value}`);
|
|
812
|
-
|
|
813
|
-
await this.setOn(false);
|
|
814
|
-
this.Window.On = false;
|
|
815
|
-
}
|
|
816
|
-
else {
|
|
817
|
-
await this.setOn(true);
|
|
818
|
-
this.Window.On = true;
|
|
819
|
-
}
|
|
754
|
+
this.On = value === 0 ? false : true;
|
|
820
755
|
}
|
|
821
756
|
}
|
|
822
757
|
else if (this.botDeviceType === 'windowcovering') {
|
|
823
758
|
if (this.WindowCovering) {
|
|
824
759
|
await this.debugLog(`Set TargetPosition: ${value}`);
|
|
825
|
-
|
|
826
|
-
await this.setOn(false);
|
|
827
|
-
this.WindowCovering.On = false;
|
|
828
|
-
}
|
|
829
|
-
else {
|
|
830
|
-
await this.setOn(true);
|
|
831
|
-
this.WindowCovering.On = true;
|
|
832
|
-
}
|
|
760
|
+
this.On = value === 0 ? false : true;
|
|
833
761
|
}
|
|
834
762
|
}
|
|
835
763
|
else if (this.botDeviceType === 'lock') {
|
|
836
764
|
if (this.LockMechanism) {
|
|
837
765
|
await this.debugLog(`Set LockTargetState: ${value}`);
|
|
838
|
-
|
|
839
|
-
await this.setOn(false);
|
|
840
|
-
this.LockMechanism.On = false;
|
|
841
|
-
}
|
|
842
|
-
else {
|
|
843
|
-
await this.setOn(true);
|
|
844
|
-
this.LockMechanism.On = true;
|
|
845
|
-
}
|
|
766
|
+
this.On = value === this.hap.Characteristic.LockTargetState.SECURED ? false : true;
|
|
846
767
|
}
|
|
847
768
|
}
|
|
848
769
|
else if (this.botDeviceType === 'faucet') {
|
|
849
770
|
if (this.Faucet) {
|
|
850
771
|
await this.debugLog(`Set Active: ${value}`);
|
|
851
|
-
|
|
852
|
-
await this.setOn(false);
|
|
853
|
-
this.Faucet.On = false;
|
|
854
|
-
}
|
|
855
|
-
else {
|
|
856
|
-
await this.setOn(true);
|
|
857
|
-
this.Faucet.On = true;
|
|
858
|
-
}
|
|
772
|
+
this.On = value === this.hap.Characteristic.Active.INACTIVE ? false : true;
|
|
859
773
|
}
|
|
860
774
|
}
|
|
861
775
|
else if (this.botDeviceType === 'stateful') {
|
|
862
776
|
if (this.StatefulProgrammableSwitch) {
|
|
863
777
|
await this.debugLog(`Set ProgrammableSwitchOutputState: ${value}`);
|
|
864
|
-
|
|
865
|
-
await this.setOn(false);
|
|
866
|
-
this.StatefulProgrammableSwitch.On = false;
|
|
867
|
-
}
|
|
868
|
-
else {
|
|
869
|
-
await this.setOn(true);
|
|
870
|
-
this.StatefulProgrammableSwitch.On = true;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
else if (this.botDeviceType === 'switch') {
|
|
875
|
-
if (this.Switch) {
|
|
876
|
-
await this.debugLog(`Set ProgrammableSwitchOutputState: ${value}`);
|
|
877
|
-
if (value === 0) {
|
|
878
|
-
await this.setOn(false);
|
|
879
|
-
this.Switch.On = false;
|
|
880
|
-
}
|
|
881
|
-
else {
|
|
882
|
-
await this.setOn(true);
|
|
883
|
-
this.Switch.On = true;
|
|
884
|
-
}
|
|
778
|
+
this.On = value === 0 ? false : true;
|
|
885
779
|
}
|
|
886
780
|
}
|
|
887
781
|
else {
|
|
888
782
|
if (this.Outlet) {
|
|
889
783
|
await this.debugLog(`Set On: ${value}`);
|
|
890
|
-
|
|
891
|
-
this.Outlet.On = value;
|
|
784
|
+
this.On = value === false ? false : true;
|
|
892
785
|
}
|
|
893
786
|
}
|
|
894
787
|
if (this.device.bot?.mode === 'multipress') {
|
|
895
|
-
if (
|
|
788
|
+
if (this.On === true) {
|
|
896
789
|
this.multiPressCount++;
|
|
897
790
|
await this.debugLog(`multiPressCount: ${this.multiPressCount}`);
|
|
898
791
|
}
|
|
@@ -903,199 +796,192 @@ export class Bot extends deviceBase {
|
|
|
903
796
|
* Updates the status for each of the HomeKit Characteristics
|
|
904
797
|
*/
|
|
905
798
|
async updateHomeKitCharacteristics() {
|
|
799
|
+
await this.debugLog('updateHomeKitCharacteristics');
|
|
800
|
+
// BatteryLevel
|
|
801
|
+
if (this.Battery.BatteryLevel === undefined) {
|
|
802
|
+
await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
this.accessory.context.BatteryLevel = this.Battery.BatteryLevel;
|
|
806
|
+
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel);
|
|
807
|
+
await this.debugLog(`updateCharacteristic BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
808
|
+
}
|
|
809
|
+
// StatusLowBattery
|
|
810
|
+
if (this.Battery.StatusLowBattery === undefined) {
|
|
811
|
+
await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
|
|
815
|
+
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
|
|
816
|
+
await this.debugLog(`updateCharacteristic StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
817
|
+
}
|
|
906
818
|
// State
|
|
907
|
-
if (this.botDeviceType === '
|
|
908
|
-
if (this.
|
|
909
|
-
await this.debugLog(`On: ${this.
|
|
819
|
+
if (this.botDeviceType === 'switch' && this.Switch) {
|
|
820
|
+
if (this.On === undefined) {
|
|
821
|
+
await this.debugLog(`On: ${this.On}`);
|
|
822
|
+
}
|
|
823
|
+
else {
|
|
824
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
825
|
+
await this.debugLog(`updateCharacteristic On: ${this.On}`);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
else if (this.botDeviceType === 'garagedoor' && this.GarageDoor) {
|
|
829
|
+
if (this.On === undefined) {
|
|
830
|
+
await this.debugLog(`On: ${this.On}`);
|
|
910
831
|
}
|
|
911
832
|
else {
|
|
912
|
-
if (this.
|
|
833
|
+
if (this.On) {
|
|
913
834
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.OPEN);
|
|
914
835
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.OPEN);
|
|
915
|
-
await this.debugLog(`updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open (${this.
|
|
836
|
+
await this.debugLog(`updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open (${this.On})`);
|
|
916
837
|
}
|
|
917
838
|
else {
|
|
918
839
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED);
|
|
919
840
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED);
|
|
920
|
-
await this.debugLog(`updateCharacteristicc TargetDoorState:
|
|
841
|
+
await this.debugLog(`updateCharacteristicc TargetDoorState: Closed, CurrentDoorState: Closed (${this.On})`);
|
|
921
842
|
}
|
|
922
843
|
}
|
|
923
|
-
await this.
|
|
924
|
-
await this.debugLog(`Garage Door On: ${this.GarageDoor?.On}`);
|
|
844
|
+
await this.debugLog(`Garage Door On: ${this.On}`);
|
|
925
845
|
}
|
|
926
|
-
else if (this.botDeviceType === 'door') {
|
|
927
|
-
if (this.
|
|
928
|
-
await this.debugLog(`On: ${this.
|
|
846
|
+
else if (this.botDeviceType === 'door' && this.Door) {
|
|
847
|
+
if (this.On === undefined) {
|
|
848
|
+
await this.debugLog(`On: ${this.On}`);
|
|
929
849
|
}
|
|
930
850
|
else {
|
|
931
|
-
if (this.
|
|
851
|
+
if (this.On) {
|
|
932
852
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
933
853
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
934
854
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
935
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.
|
|
855
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`);
|
|
936
856
|
}
|
|
937
857
|
else {
|
|
938
858
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
939
859
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
940
860
|
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
941
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.
|
|
861
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`);
|
|
942
862
|
}
|
|
943
863
|
}
|
|
944
|
-
await this.
|
|
945
|
-
await this.debugLog(`Door On: ${this.Door?.On}`);
|
|
864
|
+
await this.debugLog(`Door On: ${this.On}`);
|
|
946
865
|
}
|
|
947
|
-
else if (this.botDeviceType === 'window') {
|
|
948
|
-
if (this.
|
|
949
|
-
await this.debugLog(`On: ${this.
|
|
866
|
+
else if (this.botDeviceType === 'window' && this.Window) {
|
|
867
|
+
if (this.On === undefined) {
|
|
868
|
+
await this.debugLog(`On: ${this.On}`);
|
|
950
869
|
}
|
|
951
870
|
else {
|
|
952
|
-
if (this.
|
|
871
|
+
if (this.On) {
|
|
953
872
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
954
873
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
955
874
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
956
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.
|
|
875
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`);
|
|
957
876
|
}
|
|
958
877
|
else {
|
|
959
878
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
960
879
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
961
880
|
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
962
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.
|
|
881
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`);
|
|
963
882
|
}
|
|
964
883
|
}
|
|
965
|
-
await this.
|
|
966
|
-
await this.debugLog(`Window On: ${this.Window?.On}`);
|
|
884
|
+
await this.debugLog(`Window On: ${this.On}`);
|
|
967
885
|
}
|
|
968
|
-
else if (this.botDeviceType === 'windowcovering') {
|
|
969
|
-
if (this.
|
|
970
|
-
await this.debugLog(`On: ${this.
|
|
886
|
+
else if (this.botDeviceType === 'windowcovering' && this.WindowCovering) {
|
|
887
|
+
if (this.On === undefined) {
|
|
888
|
+
await this.debugLog(`On: ${this.On}`);
|
|
971
889
|
}
|
|
972
890
|
else {
|
|
973
|
-
if (this.
|
|
891
|
+
if (this.On) {
|
|
974
892
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
|
|
975
893
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
|
|
976
894
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
977
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.
|
|
895
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`);
|
|
978
896
|
}
|
|
979
897
|
else {
|
|
980
898
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0);
|
|
981
899
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0);
|
|
982
900
|
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
|
|
983
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.
|
|
901
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`);
|
|
984
902
|
}
|
|
985
903
|
}
|
|
986
|
-
await this.
|
|
987
|
-
await this.debugLog(`Window Covering On: ${this.WindowCovering?.On}`);
|
|
904
|
+
await this.debugLog(`Window Covering On: ${this.On}`);
|
|
988
905
|
}
|
|
989
|
-
else if (this.botDeviceType === 'lock') {
|
|
990
|
-
if (this.
|
|
991
|
-
await this.debugLog(`On: ${this.
|
|
906
|
+
else if (this.botDeviceType === 'lock' && this.LockMechanism) {
|
|
907
|
+
if (this.On === undefined) {
|
|
908
|
+
await this.debugLog(`On: ${this.On}`);
|
|
992
909
|
}
|
|
993
910
|
else {
|
|
994
|
-
if (this.
|
|
911
|
+
if (this.On) {
|
|
995
912
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
|
|
996
913
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
|
|
997
|
-
await this.debugLog(`updateCharacteristicc LockTargetState: UNSECURED, LockCurrentState: UNSECURED (${this.
|
|
914
|
+
await this.debugLog(`updateCharacteristicc LockTargetState: UNSECURED, LockCurrentState: UNSECURED (${this.On})`);
|
|
998
915
|
}
|
|
999
916
|
else {
|
|
1000
917
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
|
|
1001
918
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
|
|
1002
|
-
await this.debugLog(`updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED (${this.
|
|
919
|
+
await this.debugLog(`updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED (${this.On})`);
|
|
1003
920
|
}
|
|
1004
921
|
}
|
|
1005
|
-
await this.
|
|
1006
|
-
await this.debugLog(`Lock On: ${this.LockMechanism?.On}`);
|
|
922
|
+
await this.debugLog(`Lock On: ${this.On}`);
|
|
1007
923
|
}
|
|
1008
|
-
else if (this.botDeviceType === 'faucet') {
|
|
1009
|
-
if (this.
|
|
1010
|
-
await this.debugLog(`On: ${this.
|
|
924
|
+
else if (this.botDeviceType === 'faucet' && this.Faucet) {
|
|
925
|
+
if (this.On === undefined) {
|
|
926
|
+
await this.debugLog(`On: ${this.On}`);
|
|
1011
927
|
}
|
|
1012
928
|
else {
|
|
1013
|
-
if (this.
|
|
929
|
+
if (this.On) {
|
|
1014
930
|
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
|
|
1015
|
-
await this.debugLog(`updateCharacteristic Active: ${this.
|
|
931
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`);
|
|
1016
932
|
}
|
|
1017
933
|
else {
|
|
1018
934
|
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
1019
|
-
await this.debugLog(`updateCharacteristic Active: ${this.
|
|
935
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`);
|
|
1020
936
|
}
|
|
1021
937
|
}
|
|
1022
|
-
await this.
|
|
1023
|
-
await this.debugLog(`Faucet On: ${this.Faucet?.On}`);
|
|
938
|
+
await this.debugLog(`Faucet On: ${this.On}`);
|
|
1024
939
|
}
|
|
1025
|
-
else if (this.botDeviceType === 'fan') {
|
|
1026
|
-
if (this.
|
|
1027
|
-
await this.debugLog(`On: ${this.
|
|
940
|
+
else if (this.botDeviceType === 'fan' && this.Fan) {
|
|
941
|
+
if (this.On === undefined) {
|
|
942
|
+
await this.debugLog(`On: ${this.On}`);
|
|
1028
943
|
}
|
|
1029
944
|
else {
|
|
1030
|
-
if (this.
|
|
1031
|
-
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.
|
|
1032
|
-
await this.debugLog(`updateCharacteristic
|
|
945
|
+
if (this.On) {
|
|
946
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE);
|
|
947
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`);
|
|
1033
948
|
}
|
|
1034
949
|
else {
|
|
1035
|
-
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.
|
|
1036
|
-
await this.debugLog(`updateCharacteristic
|
|
950
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE);
|
|
951
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`);
|
|
1037
952
|
}
|
|
1038
953
|
}
|
|
1039
|
-
await this.
|
|
1040
|
-
await this.debugLog(`Fan On: ${this.Fan?.On}`);
|
|
954
|
+
await this.debugLog(`Fan On: ${this.On}`);
|
|
1041
955
|
}
|
|
1042
|
-
else if (this.botDeviceType === 'stateful') {
|
|
1043
|
-
if (this.
|
|
1044
|
-
await this.debugLog(`On: ${this.
|
|
956
|
+
else if (this.botDeviceType === 'stateful' && this.StatefulProgrammableSwitch) {
|
|
957
|
+
if (this.On === undefined) {
|
|
958
|
+
await this.debugLog(`On: ${this.On}`);
|
|
1045
959
|
}
|
|
1046
960
|
else {
|
|
1047
|
-
if (this.
|
|
961
|
+
if (this.On) {
|
|
1048
962
|
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
1049
963
|
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
1050
|
-
await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.
|
|
964
|
+
await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.On})`);
|
|
1051
965
|
}
|
|
1052
966
|
else {
|
|
1053
967
|
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
1054
968
|
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
1055
|
-
await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.
|
|
969
|
+
await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.On})`);
|
|
1056
970
|
}
|
|
1057
971
|
}
|
|
1058
|
-
await this.
|
|
1059
|
-
await this.debugLog(`StatefulProgrammableSwitch On: ${this.StatefulProgrammableSwitch?.On}`);
|
|
972
|
+
await this.debugLog(`StatefulProgrammableSwitch On: ${this.On}`);
|
|
1060
973
|
}
|
|
1061
|
-
else if (this.botDeviceType === '
|
|
1062
|
-
if (this.
|
|
1063
|
-
await this.debugLog(`On: ${this.
|
|
974
|
+
else if (this.botDeviceType === 'outlet' && this.Outlet) {
|
|
975
|
+
if (this.On === undefined) {
|
|
976
|
+
await this.debugLog(`On: ${this.On}`);
|
|
1064
977
|
}
|
|
1065
978
|
else {
|
|
1066
|
-
this.
|
|
1067
|
-
await this.debugLog(`updateCharacteristic On: ${this.
|
|
979
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
980
|
+
await this.debugLog(`updateCharacteristic On: ${this.On}`);
|
|
1068
981
|
}
|
|
1069
|
-
await this.setOn(Boolean(this.Switch?.On));
|
|
1070
982
|
}
|
|
1071
983
|
else {
|
|
1072
|
-
|
|
1073
|
-
await this.debugLog(`On: ${this.Outlet?.On}`);
|
|
1074
|
-
}
|
|
1075
|
-
else {
|
|
1076
|
-
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.Outlet.On);
|
|
1077
|
-
await this.debugLog(`updateCharacteristic On: ${this.Outlet.On}`);
|
|
1078
|
-
}
|
|
1079
|
-
await this.setOn(Boolean(this.Outlet?.On));
|
|
1080
|
-
}
|
|
1081
|
-
this.accessory.context.On = await this.getOn();
|
|
1082
|
-
// BatteryLevel
|
|
1083
|
-
if (this.Battery.BatteryLevel === undefined) {
|
|
1084
|
-
await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
1085
|
-
}
|
|
1086
|
-
else {
|
|
1087
|
-
this.accessory.context.BatteryLevel = this.Battery.BatteryLevel;
|
|
1088
|
-
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel);
|
|
1089
|
-
await this.debugLog(`updateCharacteristic BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
1090
|
-
}
|
|
1091
|
-
// StatusLowBattery
|
|
1092
|
-
if (this.Battery.StatusLowBattery === undefined) {
|
|
1093
|
-
await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
1094
|
-
}
|
|
1095
|
-
else {
|
|
1096
|
-
this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
|
|
1097
|
-
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
|
|
1098
|
-
await this.debugLog(`updateCharacteristic StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
984
|
+
await this.errorLog(`botDeviceType: ${this.botDeviceType}, On: ${this.On}`);
|
|
1099
985
|
}
|
|
1100
986
|
}
|
|
1101
987
|
async removeOutletService(accessory) {
|
|
@@ -1104,7 +990,6 @@ export class Bot extends deviceBase {
|
|
|
1104
990
|
this.Outlet = {
|
|
1105
991
|
Name: accessory.context.Outlet.Name ?? accessory.displayName,
|
|
1106
992
|
Service: accessory.getService(this.hap.Service.Outlet),
|
|
1107
|
-
On: accessory.context.On ?? false,
|
|
1108
993
|
};
|
|
1109
994
|
accessory.context.Outlet = this.Outlet;
|
|
1110
995
|
await this.warnLog('Removing any leftover Outlet Service');
|
|
@@ -1116,7 +1001,6 @@ export class Bot extends deviceBase {
|
|
|
1116
1001
|
this.GarageDoor = {
|
|
1117
1002
|
Name: accessory.context.GarageDoor.Name ?? accessory.displayName,
|
|
1118
1003
|
Service: accessory.getService(this.hap.Service.GarageDoorOpener),
|
|
1119
|
-
On: accessory.context.On ?? false,
|
|
1120
1004
|
};
|
|
1121
1005
|
accessory.context.GarageDoor = this.GarageDoor;
|
|
1122
1006
|
await this.warnLog('Removing any leftover Garage Door Service');
|
|
@@ -1128,7 +1012,6 @@ export class Bot extends deviceBase {
|
|
|
1128
1012
|
this.Door = {
|
|
1129
1013
|
Name: accessory.context.Door.Name ?? accessory.displayName,
|
|
1130
1014
|
Service: accessory.getService(this.hap.Service.Door),
|
|
1131
|
-
On: accessory.context.On ?? false,
|
|
1132
1015
|
};
|
|
1133
1016
|
accessory.context.Door = this.Door;
|
|
1134
1017
|
await this.warnLog('Removing any leftover Door Service');
|
|
@@ -1140,7 +1023,6 @@ export class Bot extends deviceBase {
|
|
|
1140
1023
|
this.LockMechanism = {
|
|
1141
1024
|
Name: accessory.context.LockMechanism.Name ?? accessory.displayName,
|
|
1142
1025
|
Service: accessory.getService(this.hap.Service.LockMechanism),
|
|
1143
|
-
On: accessory.context.On ?? false,
|
|
1144
1026
|
};
|
|
1145
1027
|
accessory.context.LockMechanism = this.LockMechanism;
|
|
1146
1028
|
this.warnLog('Removing any leftover Lock Service');
|
|
@@ -1152,7 +1034,6 @@ export class Bot extends deviceBase {
|
|
|
1152
1034
|
this.Faucet = {
|
|
1153
1035
|
Name: accessory.context.Faucet.Name ?? accessory.displayName,
|
|
1154
1036
|
Service: accessory.getService(this.hap.Service.Valve),
|
|
1155
|
-
On: accessory.context.On ?? false,
|
|
1156
1037
|
};
|
|
1157
1038
|
accessory.context.Faucet = this.Faucet;
|
|
1158
1039
|
await this.warnLog('Removing any leftover Faucet Service');
|
|
@@ -1164,7 +1045,6 @@ export class Bot extends deviceBase {
|
|
|
1164
1045
|
this.Fan = {
|
|
1165
1046
|
Name: accessory.context.Fan.Name ?? accessory.displayName,
|
|
1166
1047
|
Service: accessory.getService(this.hap.Service.Fan),
|
|
1167
|
-
On: accessory.context.On ?? false,
|
|
1168
1048
|
};
|
|
1169
1049
|
accessory.context.Fan = this.Fan;
|
|
1170
1050
|
this.warnLog('Removing any leftover Fan Service');
|
|
@@ -1176,7 +1056,6 @@ export class Bot extends deviceBase {
|
|
|
1176
1056
|
this.Window = {
|
|
1177
1057
|
Name: accessory.context.Window.Name ?? accessory.displayName,
|
|
1178
1058
|
Service: accessory.getService(this.hap.Service.Window),
|
|
1179
|
-
On: accessory.context.On ?? false,
|
|
1180
1059
|
};
|
|
1181
1060
|
accessory.context.Window = this.Window;
|
|
1182
1061
|
await this.warnLog('Removing any leftover Window Service');
|
|
@@ -1188,7 +1067,6 @@ export class Bot extends deviceBase {
|
|
|
1188
1067
|
this.WindowCovering = {
|
|
1189
1068
|
Name: accessory.context.WindowCovering.Name ?? accessory.displayName,
|
|
1190
1069
|
Service: accessory.getService(this.hap.Service.WindowCovering),
|
|
1191
|
-
On: accessory.context.On ?? false,
|
|
1192
1070
|
};
|
|
1193
1071
|
accessory.context.WindowCovering = this.WindowCovering;
|
|
1194
1072
|
await this.warnLog('Removing any leftover Window Covering Service');
|
|
@@ -1200,7 +1078,6 @@ export class Bot extends deviceBase {
|
|
|
1200
1078
|
this.StatefulProgrammableSwitch = {
|
|
1201
1079
|
Name: accessory.context.StatefulProgrammableSwitch.Name ?? accessory.displayName,
|
|
1202
1080
|
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch),
|
|
1203
|
-
On: accessory.context.On ?? false,
|
|
1204
1081
|
};
|
|
1205
1082
|
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch;
|
|
1206
1083
|
await this.warnLog('Removing any leftover Stateful Programmable Switch Service');
|
|
@@ -1212,98 +1089,11 @@ export class Bot extends deviceBase {
|
|
|
1212
1089
|
this.Switch = {
|
|
1213
1090
|
Name: accessory.context.Switch.Name ?? accessory.displayName,
|
|
1214
1091
|
Service: accessory.getService(this.hap.Service.Switch),
|
|
1215
|
-
On: accessory.context.On ?? false,
|
|
1216
1092
|
};
|
|
1217
1093
|
accessory.context.Switch = this.Switch;
|
|
1218
1094
|
await this.warnLog('Removing any leftover Switch Service');
|
|
1219
1095
|
accessory.removeService(this.Switch.Service);
|
|
1220
1096
|
}
|
|
1221
|
-
async getOn() {
|
|
1222
|
-
let On;
|
|
1223
|
-
if (this.botDeviceType === 'garagedoor') {
|
|
1224
|
-
On = this.GarageDoor?.On ? true : false;
|
|
1225
|
-
}
|
|
1226
|
-
else if (this.botDeviceType === 'door') {
|
|
1227
|
-
On = this.Door?.On ? true : false;
|
|
1228
|
-
}
|
|
1229
|
-
else if (this.botDeviceType === 'window') {
|
|
1230
|
-
On = this.Window?.On ? true : false;
|
|
1231
|
-
}
|
|
1232
|
-
else if (this.botDeviceType === 'windowcovering') {
|
|
1233
|
-
On = this.WindowCovering?.On ? true : false;
|
|
1234
|
-
}
|
|
1235
|
-
else if (this.botDeviceType === 'lock') {
|
|
1236
|
-
On = this.LockMechanism?.On ? true : false;
|
|
1237
|
-
}
|
|
1238
|
-
else if (this.botDeviceType === 'faucet') {
|
|
1239
|
-
On = this.Faucet?.On ? true : false;
|
|
1240
|
-
}
|
|
1241
|
-
else if (this.botDeviceType === 'fan') {
|
|
1242
|
-
On = this.Fan?.On ? true : false;
|
|
1243
|
-
}
|
|
1244
|
-
else if (this.botDeviceType === 'stateful') {
|
|
1245
|
-
On = this.StatefulProgrammableSwitch?.On ? true : false;
|
|
1246
|
-
}
|
|
1247
|
-
else if (this.botDeviceType === 'switch') {
|
|
1248
|
-
On = this.Switch?.On ? true : false;
|
|
1249
|
-
}
|
|
1250
|
-
else {
|
|
1251
|
-
On = this.Outlet?.On ? true : false;
|
|
1252
|
-
}
|
|
1253
|
-
return On;
|
|
1254
|
-
}
|
|
1255
|
-
async setOn(On) {
|
|
1256
|
-
if (this.botDeviceType === 'garagedoor') {
|
|
1257
|
-
if (this.GarageDoor) {
|
|
1258
|
-
this.GarageDoor.On = On;
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
else if (this.botDeviceType === 'door') {
|
|
1262
|
-
if (this.Door) {
|
|
1263
|
-
this.Door.On = On;
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
else if (this.botDeviceType === 'window') {
|
|
1267
|
-
if (this.Window) {
|
|
1268
|
-
this.Window.On = On;
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
else if (this.botDeviceType === 'windowcovering') {
|
|
1272
|
-
if (this.WindowCovering) {
|
|
1273
|
-
this.WindowCovering.On = On;
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
else if (this.botDeviceType === 'lock') {
|
|
1277
|
-
if (this.LockMechanism) {
|
|
1278
|
-
this.LockMechanism.On = On;
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
else if (this.botDeviceType === 'faucet') {
|
|
1282
|
-
if (this.Faucet) {
|
|
1283
|
-
this.Faucet.On = On;
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
else if (this.botDeviceType === 'fan') {
|
|
1287
|
-
if (this.Fan) {
|
|
1288
|
-
this.Fan.On = On;
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
else if (this.botDeviceType === 'stateful') {
|
|
1292
|
-
if (this.StatefulProgrammableSwitch) {
|
|
1293
|
-
this.StatefulProgrammableSwitch.On = On;
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
else if (this.botDeviceType === 'switch') {
|
|
1297
|
-
if (this.Switch) {
|
|
1298
|
-
this.Switch.On = On;
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
else {
|
|
1302
|
-
if (this.Outlet) {
|
|
1303
|
-
this.Outlet.On = On;
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
1097
|
async getBotConfigSettings(device) {
|
|
1308
1098
|
//Bot Device Type
|
|
1309
1099
|
this.botDeviceType = this.accessory.context.botDeviceType === device.bot?.deviceType ? this.accessory.context.botDeviceType
|
|
@@ -1422,6 +1212,8 @@ export class Bot extends deviceBase {
|
|
|
1422
1212
|
}
|
|
1423
1213
|
}
|
|
1424
1214
|
async apiError(e) {
|
|
1215
|
+
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e);
|
|
1216
|
+
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
|
|
1425
1217
|
if (this.botDeviceType === 'garagedoor') {
|
|
1426
1218
|
if (this.GarageDoor) {
|
|
1427
1219
|
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e);
|
|
@@ -1482,8 +1274,6 @@ export class Bot extends deviceBase {
|
|
|
1482
1274
|
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
1483
1275
|
}
|
|
1484
1276
|
}
|
|
1485
|
-
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e);
|
|
1486
|
-
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
|
|
1487
1277
|
}
|
|
1488
1278
|
}
|
|
1489
1279
|
//# sourceMappingURL=bot.js.map
|