@switchbot/homebridge-switchbot 2.0.0-beta.17 → 2.0.0-beta.19
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 +1 -1
- package/config.schema.json +14 -4
- package/dist/device/bot.d.ts +2 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +201 -163
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts +2 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +250 -218
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -0
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +85 -66
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +2 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +166 -136
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +126 -115
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +2 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +156 -130
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +2 -0
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +85 -64
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +2 -0
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +78 -59
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -0
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +76 -57
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +2 -0
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +133 -107
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +2 -0
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +224 -195
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +2 -0
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +127 -105
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +2 -0
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +83 -66
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +8 -6
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +83 -68
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +7 -5
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +90 -75
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +8 -6
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +83 -68
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +8 -6
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +93 -78
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +8 -6
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +68 -52
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +8 -6
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +83 -69
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +2 -0
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +75 -60
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +12 -11
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/device/bot.ts +200 -163
- package/src/device/colorbulb.ts +252 -221
- package/src/device/contact.ts +85 -66
- package/src/device/curtain.ts +165 -136
- package/src/device/humidifier.ts +126 -115
- package/src/device/lock.ts +156 -131
- package/src/device/meter.ts +85 -64
- package/src/device/meterplus.ts +78 -59
- package/src/device/motion.ts +76 -57
- package/src/device/plug.ts +132 -107
- package/src/device/striplight.ts +226 -198
- package/src/irdevice/airconditioner.ts +126 -103
- package/src/irdevice/airpurifier.ts +84 -66
- package/src/irdevice/camera.ts +84 -68
- package/src/irdevice/fan.ts +91 -75
- package/src/irdevice/light.ts +84 -68
- package/src/irdevice/other.ts +94 -78
- package/src/irdevice/tv.ts +69 -53
- package/src/irdevice/vacuumcleaner.ts +83 -68
- package/src/irdevice/waterheater.ts +76 -60
- package/src/settings.ts +12 -11
package/dist/device/bot.js
CHANGED
|
@@ -22,6 +22,7 @@ class Bot {
|
|
|
22
22
|
this.device = device;
|
|
23
23
|
// default placeholders
|
|
24
24
|
this.logs(device);
|
|
25
|
+
this.openAPI();
|
|
25
26
|
this.scan(device);
|
|
26
27
|
this.refreshRate(device);
|
|
27
28
|
this.PressOrSwitch(device);
|
|
@@ -72,7 +73,7 @@ class Bot {
|
|
|
72
73
|
// Add switchService
|
|
73
74
|
(this.switchService = accessory.getService(this.platform.Service.Switch) || accessory.addService(this.platform.Service.Switch)),
|
|
74
75
|
`${accessory.displayName} Switch`;
|
|
75
|
-
this.infoLog(
|
|
76
|
+
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Switch`);
|
|
76
77
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
77
78
|
this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
|
|
78
79
|
}
|
|
@@ -90,7 +91,7 @@ class Bot {
|
|
|
90
91
|
(this.garageDoorService =
|
|
91
92
|
accessory.getService(this.platform.Service.GarageDoorOpener) || accessory.addService(this.platform.Service.GarageDoorOpener)),
|
|
92
93
|
`${accessory.displayName} Garage Door Opener`;
|
|
93
|
-
this.infoLog(
|
|
94
|
+
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
94
95
|
this.garageDoorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
95
96
|
this.garageDoorService.getCharacteristic(this.platform.Characteristic.TargetDoorState).onSet(this.handleOnSet.bind(this));
|
|
96
97
|
this.garageDoorService.setCharacteristic(this.platform.Characteristic.ObstructionDetected, false);
|
|
@@ -108,7 +109,7 @@ class Bot {
|
|
|
108
109
|
// Add switchService
|
|
109
110
|
(this.doorService = accessory.getService(this.platform.Service.Door) || accessory.addService(this.platform.Service.Door)),
|
|
110
111
|
`${accessory.displayName} Door`;
|
|
111
|
-
this.infoLog(
|
|
112
|
+
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Door`);
|
|
112
113
|
this.doorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
113
114
|
this.doorService
|
|
114
115
|
.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
@@ -134,7 +135,7 @@ class Bot {
|
|
|
134
135
|
// Add switchService
|
|
135
136
|
(this.windowService = accessory.getService(this.platform.Service.Window) || accessory.addService(this.platform.Service.Window)),
|
|
136
137
|
`${accessory.displayName} Window`;
|
|
137
|
-
this.infoLog(
|
|
138
|
+
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window`);
|
|
138
139
|
this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
139
140
|
this.windowService
|
|
140
141
|
.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
@@ -161,7 +162,7 @@ class Bot {
|
|
|
161
162
|
(this.windowCoveringService =
|
|
162
163
|
accessory.getService(this.platform.Service.WindowCovering) || accessory.addService(this.platform.Service.WindowCovering)),
|
|
163
164
|
`${accessory.displayName} Window Covering`;
|
|
164
|
-
this.infoLog(
|
|
165
|
+
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
165
166
|
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
166
167
|
this.windowCoveringService
|
|
167
168
|
.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
@@ -187,7 +188,7 @@ class Bot {
|
|
|
187
188
|
// Add switchService
|
|
188
189
|
(this.lockService = accessory.getService(this.platform.Service.LockMechanism) || accessory.addService(this.platform.Service.LockMechanism)),
|
|
189
190
|
`${accessory.displayName} Lock`;
|
|
190
|
-
this.infoLog(
|
|
191
|
+
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Lock`);
|
|
191
192
|
this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
192
193
|
this.lockService.getCharacteristic(this.platform.Characteristic.LockTargetState).onSet(this.handleOnSet.bind(this));
|
|
193
194
|
}
|
|
@@ -204,7 +205,7 @@ class Bot {
|
|
|
204
205
|
// Add switchService
|
|
205
206
|
(this.faucetService = accessory.getService(this.platform.Service.Faucet) || accessory.addService(this.platform.Service.Faucet)),
|
|
206
207
|
`${accessory.displayName} Faucet`;
|
|
207
|
-
this.infoLog(
|
|
208
|
+
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Faucet`);
|
|
208
209
|
this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
209
210
|
this.faucetService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.handleOnSet.bind(this));
|
|
210
211
|
}
|
|
@@ -221,7 +222,7 @@ class Bot {
|
|
|
221
222
|
// Add switchService
|
|
222
223
|
(this.fanService = accessory.getService(this.platform.Service.Fan) || accessory.addService(this.platform.Service.Fan)),
|
|
223
224
|
`${accessory.displayName} Fan`;
|
|
224
|
-
this.infoLog(
|
|
225
|
+
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Fan`);
|
|
225
226
|
this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
226
227
|
this.fanService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
|
|
227
228
|
}
|
|
@@ -240,7 +241,7 @@ class Bot {
|
|
|
240
241
|
accessory.getService(this.platform.Service.StatefulProgrammableSwitch) ||
|
|
241
242
|
accessory.addService(this.platform.Service.StatefulProgrammableSwitch)),
|
|
242
243
|
`${accessory.displayName} Stateful Programmable Switch`;
|
|
243
|
-
this.infoLog(
|
|
244
|
+
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
244
245
|
this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
245
246
|
this.statefulProgrammableSwitchService
|
|
246
247
|
.getCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState)
|
|
@@ -259,24 +260,24 @@ class Bot {
|
|
|
259
260
|
// Add outletService
|
|
260
261
|
(this.outletService = accessory.getService(this.platform.Service.Outlet) || accessory.addService(this.platform.Service.Outlet)),
|
|
261
262
|
`${accessory.displayName} Outlet`;
|
|
262
|
-
this.infoLog(
|
|
263
|
+
this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Outlet`);
|
|
263
264
|
this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
264
265
|
this.outletService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
|
|
265
266
|
}
|
|
266
267
|
// Battery Service
|
|
267
268
|
if (!device.ble) {
|
|
268
|
-
this.debugLog(
|
|
269
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
|
|
269
270
|
this.batteryService = this.accessory.getService(this.platform.Service.Battery);
|
|
270
271
|
accessory.removeService(this.batteryService);
|
|
271
272
|
}
|
|
272
273
|
else if (device.ble && !this.batteryService) {
|
|
273
|
-
this.debugLog(
|
|
274
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
|
|
274
275
|
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
|
|
275
276
|
`${accessory.displayName} Battery`;
|
|
276
277
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
277
278
|
}
|
|
278
279
|
else {
|
|
279
|
-
this.debugLog(
|
|
280
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
|
|
280
281
|
}
|
|
281
282
|
// Retrieve initial values and updateHomekit
|
|
282
283
|
this.updateHomeKitCharacteristics();
|
|
@@ -301,12 +302,13 @@ class Bot {
|
|
|
301
302
|
});
|
|
302
303
|
}
|
|
303
304
|
catch (e) {
|
|
304
|
-
this.errorLog(
|
|
305
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges`);
|
|
305
306
|
if (this.deviceLogging.includes('debug')) {
|
|
306
|
-
this.errorLog(
|
|
307
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges,`
|
|
308
|
+
+ ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
307
309
|
}
|
|
308
310
|
if (this.platform.debugMode) {
|
|
309
|
-
this.errorLog(
|
|
311
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${(0, super_stringify_1.default)(e)}`);
|
|
310
312
|
}
|
|
311
313
|
}
|
|
312
314
|
this.botUpdateInProgress = false;
|
|
@@ -324,19 +326,19 @@ class Bot {
|
|
|
324
326
|
}
|
|
325
327
|
}
|
|
326
328
|
async BLEparseStatus() {
|
|
327
|
-
this.debugLog(
|
|
329
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE parseStatus`);
|
|
328
330
|
// BLEmode (true if Switch Mode) | (false if Press Mode)
|
|
329
331
|
if (this.mode) {
|
|
330
332
|
this.accessory.context.On = this.On;
|
|
331
333
|
if (this.On === undefined) {
|
|
332
334
|
this.On = Boolean(this.state);
|
|
333
335
|
}
|
|
334
|
-
this.debugLog(
|
|
336
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Switch Mode, mode: ${this.mode}, On: ${this.On}`);
|
|
335
337
|
}
|
|
336
338
|
else {
|
|
337
339
|
this.On = false;
|
|
338
340
|
this.accessory.context.On = this.On;
|
|
339
|
-
this.debugLog(
|
|
341
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Press Mode, mode: ${this.mode}, On: ${this.On}`);
|
|
340
342
|
}
|
|
341
343
|
this.BatteryLevel = Number(this.battery);
|
|
342
344
|
if (this.BatteryLevel < 10) {
|
|
@@ -348,14 +350,14 @@ class Bot {
|
|
|
348
350
|
if (Number.isNaN(this.BatteryLevel)) {
|
|
349
351
|
this.BatteryLevel = 100;
|
|
350
352
|
}
|
|
351
|
-
this.debugLog(
|
|
353
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
352
354
|
}
|
|
353
355
|
async openAPIparseStatus() {
|
|
354
356
|
if (this.device.ble) {
|
|
355
357
|
this.SwitchToOpenAPI = false;
|
|
356
358
|
}
|
|
357
359
|
if (this.platform.config.credentials?.token) {
|
|
358
|
-
this.debugLog(
|
|
360
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI parseStatus`);
|
|
359
361
|
if (this.botMode === 'press') {
|
|
360
362
|
this.On = false;
|
|
361
363
|
this.accessory.context.On = this.On;
|
|
@@ -366,7 +368,7 @@ class Bot {
|
|
|
366
368
|
this.On = false;
|
|
367
369
|
}
|
|
368
370
|
}
|
|
369
|
-
this.debugLog(
|
|
371
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
370
372
|
}
|
|
371
373
|
}
|
|
372
374
|
/**
|
|
@@ -381,18 +383,18 @@ class Bot {
|
|
|
381
383
|
}
|
|
382
384
|
}
|
|
383
385
|
async BLERefreshStatus() {
|
|
384
|
-
this.debugLog(
|
|
386
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE refreshStatus`);
|
|
385
387
|
const switchbot = await this.platform.connectBLE();
|
|
386
388
|
// Convert to BLE Address
|
|
387
389
|
this.device.bleMac = this.device
|
|
388
390
|
.deviceId.match(/.{1,2}/g)
|
|
389
391
|
.join(':')
|
|
390
392
|
.toLowerCase();
|
|
391
|
-
this.debugLog(
|
|
393
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
392
394
|
this.getCustomBLEAddress(switchbot);
|
|
393
395
|
// Start to monitor advertisement packets
|
|
394
396
|
if (switchbot === false) {
|
|
395
|
-
this.errorLog(
|
|
397
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection: ${switchbot}`);
|
|
396
398
|
}
|
|
397
399
|
switchbot
|
|
398
400
|
.startScan({
|
|
@@ -406,23 +408,23 @@ class Bot {
|
|
|
406
408
|
if (this.deviceLogging.includes('debug')) {
|
|
407
409
|
this.infoLog(this.address);
|
|
408
410
|
this.infoLog(this.device.bleMac);
|
|
409
|
-
this.infoLog(
|
|
410
|
-
this.infoLog(
|
|
411
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
|
|
412
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
|
|
411
413
|
}
|
|
412
414
|
this.serviceData = ad.serviceData;
|
|
413
415
|
this.mode = ad.serviceData.mode;
|
|
414
416
|
this.state = ad.serviceData.state;
|
|
415
417
|
this.battery = ad.serviceData.battery;
|
|
416
|
-
this.debugLog(
|
|
417
|
-
this.debugLog(
|
|
418
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${(0, super_stringify_1.default)(ad.serviceData)}`);
|
|
419
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}, model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},` +
|
|
418
420
|
` mode: ${ad.serviceData.mode}, state: ${ad.serviceData.state}, battery: ${ad.serviceData.battery}`);
|
|
419
421
|
if (this.serviceData) {
|
|
420
422
|
this.connected = true;
|
|
421
|
-
this.debugLog(
|
|
423
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
422
424
|
}
|
|
423
425
|
else {
|
|
424
426
|
this.connected = false;
|
|
425
|
-
this.debugLog(
|
|
427
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
426
428
|
}
|
|
427
429
|
};
|
|
428
430
|
// Wait 2 seconds
|
|
@@ -436,21 +438,22 @@ class Bot {
|
|
|
436
438
|
this.updateHomeKitCharacteristics();
|
|
437
439
|
}
|
|
438
440
|
else {
|
|
439
|
-
this.errorLog(
|
|
441
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
440
442
|
if (this.platform.config.credentials?.token) {
|
|
441
|
-
this.warnLog(
|
|
443
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
442
444
|
this.SwitchToOpenAPI = true;
|
|
443
445
|
await this.openAPIRefreshStatus();
|
|
444
446
|
}
|
|
445
447
|
}
|
|
446
448
|
})
|
|
447
449
|
.catch(async (e) => {
|
|
448
|
-
this.errorLog(
|
|
450
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
449
451
|
if (this.deviceLogging.includes('debug')) {
|
|
450
|
-
this.errorLog(
|
|
452
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
453
|
+
+ ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
451
454
|
}
|
|
452
455
|
if (this.platform.config.credentials?.token) {
|
|
453
|
-
this.warnLog(
|
|
456
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
454
457
|
this.SwitchToOpenAPI = true;
|
|
455
458
|
await this.openAPIRefreshStatus();
|
|
456
459
|
}
|
|
@@ -466,7 +469,7 @@ class Bot {
|
|
|
466
469
|
});
|
|
467
470
|
// Set an event handler
|
|
468
471
|
switchbot.onadvertisement = (ad) => {
|
|
469
|
-
this.warnLog(
|
|
472
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${(0, super_stringify_1.default)(ad, null, ' ')}`);
|
|
470
473
|
};
|
|
471
474
|
await switchbot.wait(10000);
|
|
472
475
|
// Stop to monitor
|
|
@@ -475,15 +478,15 @@ class Bot {
|
|
|
475
478
|
}
|
|
476
479
|
}
|
|
477
480
|
async openAPIRefreshStatus() {
|
|
478
|
-
if (this.platform.config.credentials?.token) {
|
|
479
|
-
this.debugLog(
|
|
481
|
+
if (this.platform.config.credentials?.token && this.OpenAPI) {
|
|
482
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI refreshStatus`);
|
|
480
483
|
try {
|
|
481
484
|
const t = Date.now();
|
|
482
485
|
const nonce = 'requestID';
|
|
483
486
|
const data = this.platform.config.credentials?.token + t + nonce;
|
|
484
487
|
const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
|
|
485
488
|
const sign = signTerm.toString('base64');
|
|
486
|
-
this.debugLog(
|
|
489
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
487
490
|
const options = {
|
|
488
491
|
hostname: settings_1.HostDomain,
|
|
489
492
|
port: 443,
|
|
@@ -498,7 +501,7 @@ class Bot {
|
|
|
498
501
|
},
|
|
499
502
|
};
|
|
500
503
|
const req = https_1.default.request(options, (res) => {
|
|
501
|
-
this.debugLog(
|
|
504
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Refresh statusCode: ${res.statusCode}`);
|
|
502
505
|
let rawData = '';
|
|
503
506
|
res.on('data', (d) => {
|
|
504
507
|
rawData += d;
|
|
@@ -507,32 +510,37 @@ class Bot {
|
|
|
507
510
|
res.on('end', () => {
|
|
508
511
|
try {
|
|
509
512
|
this.deviceStatus = JSON.parse(rawData);
|
|
510
|
-
this.debugLog(
|
|
513
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${(0, super_stringify_1.default)(this.deviceStatus)}`);
|
|
511
514
|
this.power = this.deviceStatus.body.power;
|
|
512
515
|
this.parseStatus();
|
|
513
516
|
this.updateHomeKitCharacteristics();
|
|
514
517
|
}
|
|
515
518
|
catch (e) {
|
|
516
|
-
this.errorLog(
|
|
519
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
517
520
|
}
|
|
518
521
|
});
|
|
519
522
|
});
|
|
520
523
|
req.on('error', (e) => {
|
|
521
|
-
this.errorLog(
|
|
524
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
522
525
|
});
|
|
523
526
|
req.end();
|
|
524
527
|
}
|
|
525
528
|
catch (e) {
|
|
526
|
-
this.errorLog(
|
|
529
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
527
530
|
if (this.deviceLogging.includes('debug')) {
|
|
528
|
-
this.errorLog(
|
|
531
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
532
|
+
+ ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
529
533
|
}
|
|
530
534
|
if (this.platform.debugMode) {
|
|
531
|
-
this.errorLog(
|
|
535
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
536
|
+
+ ` Error: ${(0, super_stringify_1.default)(e)}`);
|
|
532
537
|
}
|
|
533
538
|
this.apiError(e);
|
|
534
539
|
}
|
|
535
540
|
}
|
|
541
|
+
else {
|
|
542
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI is disabled, commands will not be sent.`);
|
|
543
|
+
}
|
|
536
544
|
}
|
|
537
545
|
/**
|
|
538
546
|
* Pushes the requested changes to the SwitchBot API
|
|
@@ -555,27 +563,27 @@ class Bot {
|
|
|
555
563
|
});
|
|
556
564
|
}
|
|
557
565
|
async BLEpushChanges() {
|
|
558
|
-
this.debugLog(
|
|
566
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.accessory.context.On}`);
|
|
559
567
|
if (this.On !== this.accessory.context.On || this.allowPush) {
|
|
560
|
-
this.debugLog(
|
|
568
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE pushChanges`);
|
|
561
569
|
const switchbot = await this.platform.connectBLE();
|
|
562
570
|
// Convert to BLE Address
|
|
563
571
|
this.device.bleMac = this.device
|
|
564
572
|
.deviceId.match(/.{1,2}/g)
|
|
565
573
|
.join(':')
|
|
566
574
|
.toLowerCase();
|
|
567
|
-
this.debugLog(
|
|
575
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
568
576
|
//if (switchbot !== false) {
|
|
569
577
|
if (this.botMode === 'press') {
|
|
570
|
-
this.debugLog(
|
|
578
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
571
579
|
switchbot
|
|
572
580
|
.discover({ model: 'H', quick: true, id: this.device.bleMac })
|
|
573
581
|
.then((device_list) => {
|
|
574
|
-
this.infoLog(
|
|
582
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
575
583
|
return device_list[0].press({ id: this.device.bleMac });
|
|
576
584
|
})
|
|
577
585
|
.then(() => {
|
|
578
|
-
this.debugLog(
|
|
586
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
|
|
579
587
|
this.accessory.context.On = this.On;
|
|
580
588
|
setTimeout(() => {
|
|
581
589
|
if (this.device.bot?.deviceType === 'switch') {
|
|
@@ -584,53 +592,57 @@ class Bot {
|
|
|
584
592
|
else {
|
|
585
593
|
this.outletService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
|
|
586
594
|
}
|
|
587
|
-
this.debugLog(
|
|
595
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}, Switch Timeout`);
|
|
588
596
|
}, 500);
|
|
589
597
|
})
|
|
590
598
|
.catch(async (e) => {
|
|
591
|
-
this.errorLog(
|
|
599
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
592
600
|
if (this.deviceLogging.includes('debug')) {
|
|
593
|
-
this.errorLog(
|
|
601
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
602
|
+
+ ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
594
603
|
}
|
|
595
604
|
if (this.platform.debugMode) {
|
|
596
|
-
this.errorLog(
|
|
605
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
606
|
+
+ ` Error: ${(0, super_stringify_1.default)(e)}`);
|
|
597
607
|
}
|
|
598
608
|
if (this.platform.config.credentials?.token) {
|
|
599
|
-
this.warnLog(
|
|
609
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
600
610
|
await this.openAPIpushChanges();
|
|
601
611
|
}
|
|
602
612
|
this.apiError(e);
|
|
603
613
|
});
|
|
604
614
|
}
|
|
605
615
|
else if (this.botMode === 'switch') {
|
|
606
|
-
this.debugLog(
|
|
616
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Press Mode: ${this.botMode}`);
|
|
607
617
|
switchbot
|
|
608
618
|
.discover({ model: 'H', quick: true, id: this.device.bleMac })
|
|
609
619
|
.then((device_list) => {
|
|
610
|
-
this.infoLog(
|
|
620
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
611
621
|
return this.turnOnOff(device_list);
|
|
612
622
|
})
|
|
613
623
|
.then(() => {
|
|
614
|
-
this.debugLog(
|
|
624
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
|
|
615
625
|
this.accessory.context.On = this.On;
|
|
616
626
|
})
|
|
617
627
|
.catch(async (e) => {
|
|
618
|
-
this.errorLog(
|
|
628
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
619
629
|
if (this.deviceLogging.includes('debug')) {
|
|
620
|
-
this.errorLog(
|
|
630
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
631
|
+
+ ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
621
632
|
}
|
|
622
633
|
if (this.platform.debugMode) {
|
|
623
|
-
this.errorLog(
|
|
634
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
635
|
+
+ ` Error: ${(0, super_stringify_1.default)(e)}`);
|
|
624
636
|
}
|
|
625
637
|
if (this.platform.config.credentials?.token) {
|
|
626
|
-
this.warnLog(
|
|
638
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
627
639
|
await this.openAPIpushChanges();
|
|
628
640
|
}
|
|
629
641
|
this.apiError(e);
|
|
630
642
|
});
|
|
631
643
|
}
|
|
632
644
|
else {
|
|
633
|
-
throw new Error(
|
|
645
|
+
throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
634
646
|
}
|
|
635
647
|
}
|
|
636
648
|
this.accessory.context.On = this.On;
|
|
@@ -649,10 +661,10 @@ class Bot {
|
|
|
649
661
|
});
|
|
650
662
|
}
|
|
651
663
|
async openAPIpushChanges() {
|
|
652
|
-
if (this.platform.config.credentials?.token) {
|
|
664
|
+
if (this.platform.config.credentials?.token && this.OpenAPI) {
|
|
653
665
|
try {
|
|
654
666
|
if (this.On !== this.accessory.context.On || this.allowPush) {
|
|
655
|
-
this.debugLog(
|
|
667
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
|
|
656
668
|
// Make Push On request to the API
|
|
657
669
|
const t = Date.now();
|
|
658
670
|
const nonce = 'requestID';
|
|
@@ -661,32 +673,32 @@ class Bot {
|
|
|
661
673
|
.update(Buffer.from(data, 'utf-8'))
|
|
662
674
|
.digest();
|
|
663
675
|
const sign = signTerm.toString('base64');
|
|
664
|
-
this.debugLog(
|
|
676
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
665
677
|
let command = '';
|
|
666
678
|
if (this.botMode === 'switch' && this.On) {
|
|
667
679
|
command = 'turnOn';
|
|
668
680
|
this.On = true;
|
|
669
|
-
this.debugLog(
|
|
681
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Switch Mode, Turning ${this.On}`);
|
|
670
682
|
}
|
|
671
683
|
else if (this.botMode === 'switch' && !this.On) {
|
|
672
684
|
command = 'turnOff';
|
|
673
685
|
this.On = false;
|
|
674
|
-
this.debugLog(
|
|
686
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Switch Mode, Turning ${this.On}`);
|
|
675
687
|
}
|
|
676
688
|
else if (this.botMode === 'press') {
|
|
677
689
|
command = 'press';
|
|
678
|
-
this.debugLog(
|
|
690
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Press Mode`);
|
|
679
691
|
this.On = false;
|
|
680
692
|
}
|
|
681
693
|
else {
|
|
682
|
-
throw new Error(
|
|
694
|
+
throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Device Paramters not set for this Bot.`);
|
|
683
695
|
}
|
|
684
696
|
const body = (0, super_stringify_1.default)({
|
|
685
697
|
'command': `${command}`,
|
|
686
698
|
'parameter': 'default',
|
|
687
699
|
'commandType': 'command',
|
|
688
700
|
});
|
|
689
|
-
this.infoLog(
|
|
701
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
|
|
690
702
|
const options = {
|
|
691
703
|
hostname: settings_1.HostDomain,
|
|
692
704
|
port: 443,
|
|
@@ -702,32 +714,39 @@ class Bot {
|
|
|
702
714
|
},
|
|
703
715
|
};
|
|
704
716
|
const req = https_1.default.request(options, res => {
|
|
705
|
-
this.debugLog(
|
|
717
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
|
|
706
718
|
this.statusCode({ res });
|
|
707
719
|
res.on('data', d => {
|
|
708
|
-
this.debugLog(
|
|
720
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
|
|
709
721
|
});
|
|
710
722
|
});
|
|
711
723
|
req.on('error', (e) => {
|
|
712
|
-
this.errorLog(
|
|
724
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
713
725
|
});
|
|
714
726
|
req.write(body);
|
|
715
727
|
req.end();
|
|
716
|
-
this.debugLog(
|
|
728
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges: ${(0, super_stringify_1.default)(req)}`);
|
|
717
729
|
this.accessory.context.On = this.On;
|
|
718
730
|
}
|
|
719
731
|
}
|
|
720
732
|
catch (e) {
|
|
721
|
-
this.errorLog(
|
|
733
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
722
734
|
if (this.deviceLogging.includes('debug')) {
|
|
723
|
-
this.errorLog(
|
|
735
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
736
|
+
+ ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
724
737
|
}
|
|
725
738
|
if (this.platform.debugMode) {
|
|
726
|
-
this.errorLog(
|
|
739
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
740
|
+
+ ` Error: ${(0, super_stringify_1.default)(e)}`);
|
|
727
741
|
}
|
|
728
742
|
this.apiError(e);
|
|
729
743
|
}
|
|
730
744
|
}
|
|
745
|
+
else {
|
|
746
|
+
if (this.deviceLogging.includes('debug')) {
|
|
747
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI is disabled, device status will not be sent.`);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
731
750
|
}
|
|
732
751
|
/**
|
|
733
752
|
* Updates the status for each of the HomeKit Characteristics
|
|
@@ -735,185 +754,191 @@ class Bot {
|
|
|
735
754
|
async updateHomeKitCharacteristics() {
|
|
736
755
|
if (this.device.bot?.deviceType === 'garagedoor') {
|
|
737
756
|
if (this.On === undefined) {
|
|
738
|
-
this.debugLog(
|
|
757
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
739
758
|
}
|
|
740
759
|
else {
|
|
741
760
|
if (this.On) {
|
|
742
761
|
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.TargetDoorState, this.platform.Characteristic.TargetDoorState.OPEN);
|
|
743
762
|
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.CurrentDoorState, this.platform.Characteristic.CurrentDoorState.OPEN);
|
|
744
|
-
this.debugLog(
|
|
763
|
+
this.debugLog(`${this.device.deviceType}: `
|
|
764
|
+
+ `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
|
|
745
765
|
}
|
|
746
766
|
else {
|
|
747
767
|
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.TargetDoorState, this.platform.Characteristic.TargetDoorState.CLOSED);
|
|
748
768
|
this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.CurrentDoorState, this.platform.Characteristic.CurrentDoorState.CLOSED);
|
|
749
|
-
this.debugLog(
|
|
769
|
+
this.debugLog(`${this.device.deviceType}: `
|
|
770
|
+
+ `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
|
|
750
771
|
}
|
|
751
772
|
}
|
|
752
|
-
this.debugLog(
|
|
773
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Garage Door On: ${this.On}`);
|
|
753
774
|
}
|
|
754
775
|
else if (this.device.bot?.deviceType === 'door') {
|
|
755
776
|
if (this.On === undefined) {
|
|
756
|
-
this.debugLog(
|
|
777
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
757
778
|
}
|
|
758
779
|
else {
|
|
759
780
|
if (this.On) {
|
|
760
781
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
|
|
761
782
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
|
|
762
783
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
763
|
-
this.debugLog(
|
|
784
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
764
785
|
}
|
|
765
786
|
else {
|
|
766
787
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
|
|
767
788
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
|
|
768
789
|
this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
769
|
-
this.debugLog(
|
|
790
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
770
791
|
}
|
|
771
792
|
}
|
|
772
|
-
this.debugLog(
|
|
793
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Door On: ${this.On}`);
|
|
773
794
|
}
|
|
774
795
|
else if (this.device.bot?.deviceType === 'window') {
|
|
775
796
|
if (this.On === undefined) {
|
|
776
|
-
this.debugLog(
|
|
797
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
777
798
|
}
|
|
778
799
|
else {
|
|
779
800
|
if (this.On) {
|
|
780
801
|
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
|
|
781
802
|
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
|
|
782
803
|
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
783
|
-
this.debugLog(
|
|
804
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
784
805
|
}
|
|
785
806
|
else {
|
|
786
807
|
this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
|
|
787
808
|
this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
|
|
788
809
|
this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
789
|
-
this.debugLog(
|
|
810
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
790
811
|
}
|
|
791
812
|
}
|
|
792
|
-
this.debugLog(
|
|
813
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window On: ${this.On}`);
|
|
793
814
|
}
|
|
794
815
|
else if (this.device.bot?.deviceType === 'windowcovering') {
|
|
795
816
|
if (this.On === undefined) {
|
|
796
|
-
this.debugLog(
|
|
817
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
797
818
|
}
|
|
798
819
|
else {
|
|
799
820
|
if (this.On) {
|
|
800
821
|
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
|
|
801
822
|
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
|
|
802
823
|
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
803
|
-
this.debugLog(
|
|
824
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
|
|
804
825
|
}
|
|
805
826
|
else {
|
|
806
827
|
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
|
|
807
828
|
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
|
|
808
829
|
this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
|
|
809
|
-
this.debugLog(
|
|
830
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
|
|
810
831
|
}
|
|
811
832
|
}
|
|
812
|
-
this.debugLog(
|
|
833
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window Covering On: ${this.On}`);
|
|
813
834
|
}
|
|
814
835
|
else if (this.device.bot?.deviceType === 'lock') {
|
|
815
836
|
if (this.On === undefined) {
|
|
816
|
-
this.debugLog(
|
|
837
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
817
838
|
}
|
|
818
839
|
else {
|
|
819
840
|
if (this.On) {
|
|
820
841
|
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, this.platform.Characteristic.LockTargetState.UNSECURED);
|
|
821
842
|
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState, this.platform.Characteristic.LockCurrentState.UNSECURED);
|
|
822
|
-
this.debugLog(
|
|
843
|
+
this.debugLog(`${this.device.deviceType}: `
|
|
844
|
+
+ `${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`);
|
|
823
845
|
}
|
|
824
846
|
else {
|
|
825
847
|
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, this.platform.Characteristic.LockTargetState.SECURED);
|
|
826
848
|
this.lockService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState, this.platform.Characteristic.LockCurrentState.SECURED);
|
|
827
|
-
this.debugLog(
|
|
849
|
+
this.debugLog(`${this.device.deviceType}: `
|
|
850
|
+
+ `${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`);
|
|
828
851
|
}
|
|
829
852
|
}
|
|
830
|
-
this.debugLog(
|
|
853
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.On}`);
|
|
831
854
|
}
|
|
832
855
|
else if (this.device.bot?.deviceType === 'faucet') {
|
|
833
856
|
if (this.On === undefined) {
|
|
834
|
-
this.debugLog(
|
|
857
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
835
858
|
}
|
|
836
859
|
else {
|
|
837
860
|
if (this.On) {
|
|
838
861
|
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE);
|
|
839
|
-
this.debugLog(
|
|
862
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
840
863
|
}
|
|
841
864
|
else {
|
|
842
865
|
this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.INACTIVE);
|
|
843
|
-
this.debugLog(
|
|
866
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
|
|
844
867
|
}
|
|
845
868
|
}
|
|
846
|
-
this.debugLog(
|
|
869
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Faucet On: ${this.On}`);
|
|
847
870
|
}
|
|
848
871
|
else if (this.device.bot?.deviceType === 'fan') {
|
|
849
872
|
if (this.On === undefined) {
|
|
850
|
-
this.debugLog(
|
|
873
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
851
874
|
}
|
|
852
875
|
else {
|
|
853
876
|
if (this.On) {
|
|
854
877
|
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
855
|
-
this.debugLog(
|
|
878
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
856
879
|
}
|
|
857
880
|
else {
|
|
858
881
|
this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
859
|
-
this.debugLog(
|
|
882
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
860
883
|
}
|
|
861
884
|
}
|
|
862
|
-
this.debugLog(
|
|
885
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Fan On: ${this.On}`);
|
|
863
886
|
}
|
|
864
887
|
else if (this.device.bot?.deviceType === 'stateful') {
|
|
865
888
|
if (this.On === undefined) {
|
|
866
|
-
this.debugLog(
|
|
889
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
867
890
|
}
|
|
868
891
|
else {
|
|
869
892
|
if (this.On) {
|
|
870
893
|
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
871
894
|
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 1);
|
|
872
|
-
this.debugLog(
|
|
895
|
+
this.debugLog(`${this.device.deviceType}: `
|
|
896
|
+
+ `${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`);
|
|
873
897
|
}
|
|
874
898
|
else {
|
|
875
899
|
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent, this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
876
900
|
this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 0);
|
|
877
|
-
this.debugLog(
|
|
901
|
+
this.debugLog(`${this.device.deviceType}: `
|
|
902
|
+
+ `${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`);
|
|
878
903
|
}
|
|
879
904
|
}
|
|
880
|
-
this.debugLog(
|
|
905
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
|
|
881
906
|
}
|
|
882
907
|
else if (this.device.bot?.deviceType === 'switch') {
|
|
883
908
|
if (this.On === undefined) {
|
|
884
|
-
this.debugLog(
|
|
909
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
885
910
|
}
|
|
886
911
|
else {
|
|
887
912
|
this.switchService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
888
|
-
this.debugLog(
|
|
913
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
889
914
|
}
|
|
890
915
|
}
|
|
891
916
|
else {
|
|
892
917
|
if (this.On === undefined) {
|
|
893
|
-
this.debugLog(
|
|
918
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
894
919
|
}
|
|
895
920
|
else {
|
|
896
921
|
this.outletService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
897
|
-
this.debugLog(
|
|
922
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
898
923
|
}
|
|
899
924
|
}
|
|
900
925
|
this.accessory.context.On = this.On;
|
|
901
926
|
if (this.device.ble) {
|
|
902
927
|
if (this.BatteryLevel === undefined) {
|
|
903
|
-
this.debugLog(
|
|
928
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
904
929
|
}
|
|
905
930
|
else {
|
|
906
931
|
this.accessory.context.BatteryLevel = this.BatteryLevel;
|
|
907
932
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
908
|
-
this.debugLog(
|
|
933
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
909
934
|
}
|
|
910
935
|
if (this.StatusLowBattery === undefined) {
|
|
911
|
-
this.debugLog(
|
|
936
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
912
937
|
}
|
|
913
938
|
else {
|
|
914
939
|
this.accessory.context.StatusLowBattery = this.StatusLowBattery;
|
|
915
940
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
916
|
-
this.debugLog(
|
|
941
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
917
942
|
}
|
|
918
943
|
}
|
|
919
944
|
}
|
|
@@ -967,31 +992,31 @@ class Bot {
|
|
|
967
992
|
async statusCode({ res }) {
|
|
968
993
|
switch (res.statusCode) {
|
|
969
994
|
case 151:
|
|
970
|
-
this.errorLog(
|
|
995
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
971
996
|
break;
|
|
972
997
|
case 152:
|
|
973
|
-
this.errorLog(
|
|
998
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device not found.`);
|
|
974
999
|
break;
|
|
975
1000
|
case 160:
|
|
976
|
-
this.errorLog(
|
|
1001
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command is not supported.`);
|
|
977
1002
|
break;
|
|
978
1003
|
case 161:
|
|
979
|
-
this.errorLog(
|
|
1004
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
|
|
980
1005
|
this.offlineOff();
|
|
981
1006
|
break;
|
|
982
1007
|
case 171:
|
|
983
|
-
this.errorLog(
|
|
1008
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
984
1009
|
this.offlineOff();
|
|
985
1010
|
break;
|
|
986
1011
|
case 190:
|
|
987
|
-
this.errorLog(
|
|
1012
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
|
|
988
1013
|
` Or command: ${(0, super_stringify_1.default)(res)} format is invalid`);
|
|
989
1014
|
break;
|
|
990
1015
|
case 100:
|
|
991
|
-
this.debugLog(
|
|
1016
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
992
1017
|
break;
|
|
993
1018
|
default:
|
|
994
|
-
this.debugLog(
|
|
1019
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode.`);
|
|
995
1020
|
}
|
|
996
1021
|
}
|
|
997
1022
|
async offlineOff() {
|
|
@@ -1010,7 +1035,7 @@ class Bot {
|
|
|
1010
1035
|
*/
|
|
1011
1036
|
async handleOnSet(value) {
|
|
1012
1037
|
if (this.device.bot?.deviceType === 'garagedoor') {
|
|
1013
|
-
this.debugLog(
|
|
1038
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} TargetDoorState: ${value}`);
|
|
1014
1039
|
if (value === this.platform.Characteristic.TargetDoorState.CLOSED) {
|
|
1015
1040
|
this.On = false;
|
|
1016
1041
|
}
|
|
@@ -1021,7 +1046,7 @@ class Bot {
|
|
|
1021
1046
|
else if (this.device.bot?.deviceType === 'door' ||
|
|
1022
1047
|
this.device.bot?.deviceType === 'window' ||
|
|
1023
1048
|
this.device.bot?.deviceType === 'windowcovering') {
|
|
1024
|
-
this.debugLog(
|
|
1049
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} TargetPosition: ${value}`);
|
|
1025
1050
|
if (value === 0) {
|
|
1026
1051
|
this.On = false;
|
|
1027
1052
|
}
|
|
@@ -1030,7 +1055,7 @@ class Bot {
|
|
|
1030
1055
|
}
|
|
1031
1056
|
}
|
|
1032
1057
|
else if (this.device.bot?.deviceType === 'lock') {
|
|
1033
|
-
this.debugLog(
|
|
1058
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LockTargetState: ${value}`);
|
|
1034
1059
|
if (value === this.platform.Characteristic.LockTargetState.SECURED) {
|
|
1035
1060
|
this.On = false;
|
|
1036
1061
|
}
|
|
@@ -1039,7 +1064,7 @@ class Bot {
|
|
|
1039
1064
|
}
|
|
1040
1065
|
}
|
|
1041
1066
|
else if (this.device.bot?.deviceType === 'faucet') {
|
|
1042
|
-
this.debugLog(
|
|
1067
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${value}`);
|
|
1043
1068
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
1044
1069
|
this.On = false;
|
|
1045
1070
|
}
|
|
@@ -1048,7 +1073,7 @@ class Bot {
|
|
|
1048
1073
|
}
|
|
1049
1074
|
}
|
|
1050
1075
|
else if (this.device.bot?.deviceType === 'stateful') {
|
|
1051
|
-
this.debugLog(
|
|
1076
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ProgrammableSwitchOutputState: ${value}`);
|
|
1052
1077
|
if (value === 0) {
|
|
1053
1078
|
this.On = false;
|
|
1054
1079
|
}
|
|
@@ -1057,7 +1082,7 @@ class Bot {
|
|
|
1057
1082
|
}
|
|
1058
1083
|
}
|
|
1059
1084
|
else {
|
|
1060
|
-
this.debugLog(
|
|
1085
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${value}`);
|
|
1061
1086
|
this.On = value;
|
|
1062
1087
|
}
|
|
1063
1088
|
this.doBotUpdate.next();
|
|
@@ -1091,6 +1116,9 @@ class Bot {
|
|
|
1091
1116
|
if (device.ble) {
|
|
1092
1117
|
config['ble'] = device.ble;
|
|
1093
1118
|
}
|
|
1119
|
+
if (device.openAPI !== undefined) {
|
|
1120
|
+
config['openAPI'] = device.openAPI;
|
|
1121
|
+
}
|
|
1094
1122
|
if (device.logging !== undefined) {
|
|
1095
1123
|
config['logging'] = device.logging;
|
|
1096
1124
|
}
|
|
@@ -1104,56 +1132,66 @@ class Bot {
|
|
|
1104
1132
|
config['offline'] = device.offline;
|
|
1105
1133
|
}
|
|
1106
1134
|
if (Object.entries(config).length !== 0) {
|
|
1107
|
-
this.infoLog(
|
|
1135
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${(0, super_stringify_1.default)(config)}`);
|
|
1108
1136
|
}
|
|
1109
1137
|
}
|
|
1110
1138
|
async refreshRate(device) {
|
|
1111
1139
|
if (device.refreshRate) {
|
|
1112
1140
|
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
1113
|
-
this.debugLog(
|
|
1141
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
1114
1142
|
}
|
|
1115
1143
|
else if (this.platform.config.options.refreshRate) {
|
|
1116
1144
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
|
|
1117
|
-
this.debugLog(
|
|
1145
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
async openAPI() {
|
|
1149
|
+
if (!this.device.openAPI) {
|
|
1150
|
+
this.OpenAPI = true;
|
|
1151
|
+
}
|
|
1152
|
+
else {
|
|
1153
|
+
this.OpenAPI = this.device.openAPI;
|
|
1118
1154
|
}
|
|
1155
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
|
|
1119
1156
|
}
|
|
1120
1157
|
async scan(device) {
|
|
1121
1158
|
if (device.scanDuration) {
|
|
1122
1159
|
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
1123
1160
|
if (device.ble) {
|
|
1124
|
-
this.debugLog(
|
|
1161
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
1125
1162
|
}
|
|
1126
1163
|
}
|
|
1127
1164
|
else {
|
|
1128
1165
|
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
1129
1166
|
if (this.device.ble) {
|
|
1130
|
-
this.debugLog(
|
|
1167
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
1131
1168
|
}
|
|
1132
1169
|
}
|
|
1133
1170
|
}
|
|
1134
1171
|
async logs(device) {
|
|
1135
1172
|
if (this.platform.debugMode) {
|
|
1136
1173
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
1137
|
-
this.debugLog(
|
|
1174
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
1138
1175
|
}
|
|
1139
1176
|
else if (device.logging) {
|
|
1140
1177
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
1141
|
-
this.debugLog(
|
|
1178
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
1142
1179
|
}
|
|
1143
1180
|
else if (this.platform.config.options?.logging) {
|
|
1144
1181
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
1145
|
-
this.debugLog(
|
|
1182
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
1146
1183
|
}
|
|
1147
1184
|
else {
|
|
1148
1185
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
1149
|
-
this.debugLog(
|
|
1186
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
1150
1187
|
}
|
|
1151
1188
|
}
|
|
1152
1189
|
FirmwareRevision(accessory, device) {
|
|
1153
1190
|
let FirmwareRevision;
|
|
1154
|
-
this.debugLog(
|
|
1155
|
-
|
|
1156
|
-
this.debugLog(
|
|
1191
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
1192
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
1193
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
1194
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
1157
1195
|
if (accessory.context.FirmwareRevision) {
|
|
1158
1196
|
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1159
1197
|
}
|
|
@@ -1168,19 +1206,19 @@ class Bot {
|
|
|
1168
1206
|
async PressOrSwitch(device) {
|
|
1169
1207
|
if (!device.bot?.mode) {
|
|
1170
1208
|
this.botMode = 'switch';
|
|
1171
|
-
this.warnLog(
|
|
1172
|
-
this.warnLog(
|
|
1209
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
|
|
1210
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
|
|
1173
1211
|
}
|
|
1174
1212
|
else if (device.bot?.mode === 'switch') {
|
|
1175
1213
|
this.botMode = 'switch';
|
|
1176
|
-
this.debugLog(
|
|
1214
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
|
|
1177
1215
|
}
|
|
1178
1216
|
else if (device.bot?.mode === 'press') {
|
|
1179
1217
|
this.botMode = 'press';
|
|
1180
|
-
this.debugLog(
|
|
1218
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
|
|
1181
1219
|
}
|
|
1182
1220
|
else {
|
|
1183
|
-
throw new Error(
|
|
1221
|
+
throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
|
|
1184
1222
|
}
|
|
1185
1223
|
}
|
|
1186
1224
|
async allowPushChanges(device) {
|
|
@@ -1190,13 +1228,13 @@ class Bot {
|
|
|
1190
1228
|
else {
|
|
1191
1229
|
this.allowPush = false;
|
|
1192
1230
|
}
|
|
1193
|
-
this.debugLog(
|
|
1231
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Allowing Push Changes: ${this.allowPush}`);
|
|
1194
1232
|
}
|
|
1195
1233
|
async removeOutletService(accessory) {
|
|
1196
1234
|
// If outletService still pressent, then remove first
|
|
1197
1235
|
this.outletService = this.accessory.getService(this.platform.Service.Outlet);
|
|
1198
1236
|
if (this.outletService) {
|
|
1199
|
-
this.warnLog(
|
|
1237
|
+
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
1200
1238
|
}
|
|
1201
1239
|
accessory.removeService(this.outletService);
|
|
1202
1240
|
}
|
|
@@ -1204,7 +1242,7 @@ class Bot {
|
|
|
1204
1242
|
// If garageDoorService still pressent, then remove first
|
|
1205
1243
|
this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
|
|
1206
1244
|
if (this.garageDoorService) {
|
|
1207
|
-
this.warnLog(
|
|
1245
|
+
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
1208
1246
|
}
|
|
1209
1247
|
accessory.removeService(this.garageDoorService);
|
|
1210
1248
|
}
|
|
@@ -1212,7 +1250,7 @@ class Bot {
|
|
|
1212
1250
|
// If doorService still pressent, then remove first
|
|
1213
1251
|
this.doorService = this.accessory.getService(this.platform.Service.Door);
|
|
1214
1252
|
if (this.doorService) {
|
|
1215
|
-
this.warnLog(
|
|
1253
|
+
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
1216
1254
|
}
|
|
1217
1255
|
accessory.removeService(this.doorService);
|
|
1218
1256
|
}
|
|
@@ -1220,7 +1258,7 @@ class Bot {
|
|
|
1220
1258
|
// If lockService still pressent, then remove first
|
|
1221
1259
|
this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
|
|
1222
1260
|
if (this.lockService) {
|
|
1223
|
-
this.warnLog(
|
|
1261
|
+
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
1224
1262
|
}
|
|
1225
1263
|
accessory.removeService(this.lockService);
|
|
1226
1264
|
}
|
|
@@ -1228,7 +1266,7 @@ class Bot {
|
|
|
1228
1266
|
// If faucetService still pressent, then remove first
|
|
1229
1267
|
this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
|
|
1230
1268
|
if (this.faucetService) {
|
|
1231
|
-
this.warnLog(
|
|
1269
|
+
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
1232
1270
|
}
|
|
1233
1271
|
accessory.removeService(this.faucetService);
|
|
1234
1272
|
}
|
|
@@ -1236,7 +1274,7 @@ class Bot {
|
|
|
1236
1274
|
// If fanService still pressent, then remove first
|
|
1237
1275
|
this.fanService = this.accessory.getService(this.platform.Service.Fan);
|
|
1238
1276
|
if (this.fanService) {
|
|
1239
|
-
this.warnLog(
|
|
1277
|
+
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
1240
1278
|
}
|
|
1241
1279
|
accessory.removeService(this.fanService);
|
|
1242
1280
|
}
|
|
@@ -1244,7 +1282,7 @@ class Bot {
|
|
|
1244
1282
|
// If windowService still pressent, then remove first
|
|
1245
1283
|
this.windowService = this.accessory.getService(this.platform.Service.Window);
|
|
1246
1284
|
if (this.windowService) {
|
|
1247
|
-
this.warnLog(
|
|
1285
|
+
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
1248
1286
|
}
|
|
1249
1287
|
accessory.removeService(this.windowService);
|
|
1250
1288
|
}
|
|
@@ -1252,7 +1290,7 @@ class Bot {
|
|
|
1252
1290
|
// If windowCoveringService still pressent, then remove first
|
|
1253
1291
|
this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
|
|
1254
1292
|
if (this.windowCoveringService) {
|
|
1255
|
-
this.warnLog(
|
|
1293
|
+
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
1256
1294
|
}
|
|
1257
1295
|
accessory.removeService(this.windowCoveringService);
|
|
1258
1296
|
}
|
|
@@ -1260,7 +1298,7 @@ class Bot {
|
|
|
1260
1298
|
// If statefulProgrammableSwitchService still pressent, then remove first
|
|
1261
1299
|
this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
|
|
1262
1300
|
if (this.statefulProgrammableSwitchService) {
|
|
1263
|
-
this.warnLog(
|
|
1301
|
+
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
1264
1302
|
}
|
|
1265
1303
|
accessory.removeService(this.statefulProgrammableSwitchService);
|
|
1266
1304
|
}
|
|
@@ -1268,7 +1306,7 @@ class Bot {
|
|
|
1268
1306
|
// If switchService still pressent, then remove first
|
|
1269
1307
|
this.switchService = this.accessory.getService(this.platform.Service.Switch);
|
|
1270
1308
|
if (this.switchService) {
|
|
1271
|
-
this.warnLog(
|
|
1309
|
+
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
1272
1310
|
}
|
|
1273
1311
|
accessory.removeService(this.switchService);
|
|
1274
1312
|
}
|