@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/src/device/motion.ts
CHANGED
|
@@ -41,6 +41,7 @@ export class Motion {
|
|
|
41
41
|
lightLevel!: serviceData['lightLevel'];
|
|
42
42
|
|
|
43
43
|
// Config
|
|
44
|
+
OpenAPI?: boolean;
|
|
44
45
|
set_minLux!: number;
|
|
45
46
|
set_maxLux!: number;
|
|
46
47
|
scanDuration!: number;
|
|
@@ -54,6 +55,7 @@ export class Motion {
|
|
|
54
55
|
constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
|
|
55
56
|
// default placeholders
|
|
56
57
|
this.logs(device);
|
|
58
|
+
this.openAPI();
|
|
57
59
|
this.scan(device);
|
|
58
60
|
this.refreshRate(device);
|
|
59
61
|
this.config(device);
|
|
@@ -94,33 +96,33 @@ export class Motion {
|
|
|
94
96
|
|
|
95
97
|
// Light Sensor Service
|
|
96
98
|
if (device.motion?.hide_lightsensor) {
|
|
97
|
-
this.debugLog(
|
|
99
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Light Sensor Service`);
|
|
98
100
|
this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor);
|
|
99
101
|
accessory.removeService(this.lightSensorService!);
|
|
100
102
|
} else if (!this.lightSensorService) {
|
|
101
|
-
this.debugLog(
|
|
103
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Light Sensor Service`);
|
|
102
104
|
(this.lightSensorService =
|
|
103
105
|
this.accessory.getService(this.platform.Service.LightSensor) || this.accessory.addService(this.platform.Service.LightSensor)),
|
|
104
106
|
`${accessory.displayName} Light Sensor`;
|
|
105
107
|
|
|
106
108
|
this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
|
|
107
109
|
} else {
|
|
108
|
-
this.debugLog(
|
|
110
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Light Sensor Service Not Added`);
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
// Battery Service
|
|
112
114
|
if (!device.ble) {
|
|
113
|
-
this.debugLog(
|
|
115
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
|
|
114
116
|
this.batteryService = this.accessory.getService(this.platform.Service.Battery);
|
|
115
117
|
accessory.removeService(this.batteryService!);
|
|
116
118
|
} else if (device.ble && !this.batteryService) {
|
|
117
|
-
this.debugLog(
|
|
119
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
|
|
118
120
|
(this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
|
|
119
121
|
`${accessory.displayName} Battery`;
|
|
120
122
|
|
|
121
123
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
122
124
|
} else {
|
|
123
|
-
this.debugLog(
|
|
125
|
+
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
// Retrieve initial values and updateHomekit
|
|
@@ -146,10 +148,10 @@ export class Motion {
|
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
async BLEparseStatus(): Promise<void> {
|
|
149
|
-
this.debugLog(
|
|
151
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE parseStatus`);
|
|
150
152
|
// Movement
|
|
151
153
|
this.MotionDetected = this.movement!;
|
|
152
|
-
this.debugLog(
|
|
154
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
|
|
153
155
|
// Light Level
|
|
154
156
|
if (!this.device.motion?.hide_lightsensor) {
|
|
155
157
|
this.set_minLux = this.minLux();
|
|
@@ -163,7 +165,7 @@ export class Motion {
|
|
|
163
165
|
this.CurrentAmbientLightLevel = this.set_maxLux;
|
|
164
166
|
}
|
|
165
167
|
this.debugLog(
|
|
166
|
-
|
|
168
|
+
`${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel},` +
|
|
167
169
|
` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
|
|
168
170
|
);
|
|
169
171
|
}
|
|
@@ -177,7 +179,8 @@ export class Motion {
|
|
|
177
179
|
} else {
|
|
178
180
|
this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
|
179
181
|
}
|
|
180
|
-
this.debugLog(
|
|
182
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
183
|
+
+` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
async openAPIparseStatus(): Promise<void> {
|
|
@@ -185,10 +188,10 @@ export class Motion {
|
|
|
185
188
|
this.SwitchToOpenAPI = false;
|
|
186
189
|
}
|
|
187
190
|
if (this.platform.config.credentials?.token) {
|
|
188
|
-
this.debugLog(
|
|
191
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI parseStatus`);
|
|
189
192
|
// Motion State
|
|
190
193
|
this.MotionDetected = this.moveDetected!;
|
|
191
|
-
this.debugLog(
|
|
194
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
|
|
192
195
|
// Light Level
|
|
193
196
|
if (!this.device.motion?.hide_lightsensor) {
|
|
194
197
|
this.set_minLux = this.minLux();
|
|
@@ -201,7 +204,7 @@ export class Motion {
|
|
|
201
204
|
default:
|
|
202
205
|
this.CurrentAmbientLightLevel = this.set_maxLux;
|
|
203
206
|
}
|
|
204
|
-
this.debugLog(
|
|
207
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
205
208
|
}
|
|
206
209
|
}
|
|
207
210
|
}
|
|
@@ -218,7 +221,7 @@ export class Motion {
|
|
|
218
221
|
}
|
|
219
222
|
|
|
220
223
|
async BLERefreshStatus(): Promise<void> {
|
|
221
|
-
this.debugLog(
|
|
224
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE RefreshStatus`);
|
|
222
225
|
const switchbot = await this.platform.connectBLE();
|
|
223
226
|
// Convert to BLE Address
|
|
224
227
|
this.device.bleMac =
|
|
@@ -227,7 +230,7 @@ export class Motion {
|
|
|
227
230
|
.deviceId!.match(/.{1,2}/g)!
|
|
228
231
|
.join(':')
|
|
229
232
|
.toLowerCase();
|
|
230
|
-
this.debugLog(
|
|
233
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
231
234
|
|
|
232
235
|
this.getCustomBLEAddress(switchbot);
|
|
233
236
|
// Start to monitor advertisement packets
|
|
@@ -244,25 +247,25 @@ export class Motion {
|
|
|
244
247
|
if (this.deviceLogging.includes('debug')) {
|
|
245
248
|
this.infoLog(this.address);
|
|
246
249
|
this.infoLog(this.device.bleMac);
|
|
247
|
-
this.infoLog(
|
|
248
|
-
this.infoLog(
|
|
250
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
|
|
251
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
|
|
249
252
|
}
|
|
250
253
|
this.serviceData = ad.serviceData;
|
|
251
254
|
this.movement = ad.serviceData.movement;
|
|
252
255
|
this.battery = ad.serviceData.battery;
|
|
253
256
|
this.lightLevel = ad.serviceData.lightLevel;
|
|
254
|
-
this.debugLog(
|
|
257
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
|
|
255
258
|
this.debugLog(
|
|
256
|
-
|
|
259
|
+
`${this.device.deviceType}: ${this.accessory.displayName} movement: ${ad.serviceData.movement}, lightLevel: ` +
|
|
257
260
|
`${ad.serviceData.lightLevel}, battery: ${ad.serviceData.battery}`,
|
|
258
261
|
);
|
|
259
262
|
|
|
260
263
|
if (this.serviceData) {
|
|
261
264
|
this.connected = true;
|
|
262
|
-
this.debugLog(
|
|
265
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
263
266
|
} else {
|
|
264
267
|
this.connected = false;
|
|
265
|
-
this.debugLog(
|
|
268
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
266
269
|
}
|
|
267
270
|
};
|
|
268
271
|
// Wait 10 seconds
|
|
@@ -279,15 +282,15 @@ export class Motion {
|
|
|
279
282
|
}
|
|
280
283
|
})
|
|
281
284
|
.catch(async (e: any) => {
|
|
282
|
-
this.errorLog(
|
|
285
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
283
286
|
if (this.deviceLogging.includes('debug')) {
|
|
284
287
|
this.errorLog(
|
|
285
|
-
|
|
288
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` +
|
|
286
289
|
` Error Message: ${superStringify(e.message)}`,
|
|
287
290
|
);
|
|
288
291
|
}
|
|
289
292
|
if (this.platform.config.credentials?.token) {
|
|
290
|
-
this.warnLog(
|
|
293
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
291
294
|
this.SwitchToOpenAPI = true;
|
|
292
295
|
await this.openAPIRefreshStatus();
|
|
293
296
|
}
|
|
@@ -307,7 +310,7 @@ export class Motion {
|
|
|
307
310
|
});
|
|
308
311
|
// Set an event handler
|
|
309
312
|
switchbot.onadvertisement = (ad: any) => {
|
|
310
|
-
this.warnLog(
|
|
313
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${superStringify(ad, null, ' ')}`);
|
|
311
314
|
};
|
|
312
315
|
await switchbot.wait(10000);
|
|
313
316
|
// Stop to monitor
|
|
@@ -317,24 +320,24 @@ export class Motion {
|
|
|
317
320
|
}
|
|
318
321
|
|
|
319
322
|
async BLEconnection(switchbot: any): Promise<void> {
|
|
320
|
-
this.errorLog(
|
|
323
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
|
|
321
324
|
if (this.platform.config.credentials?.token) {
|
|
322
|
-
this.warnLog(
|
|
325
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
323
326
|
this.SwitchToOpenAPI = true;
|
|
324
327
|
await this.openAPIRefreshStatus();
|
|
325
328
|
}
|
|
326
329
|
}
|
|
327
330
|
|
|
328
331
|
async openAPIRefreshStatus(): Promise<void> {
|
|
329
|
-
if (this.platform.config.credentials?.token) {
|
|
330
|
-
this.debugLog(
|
|
332
|
+
if (this.platform.config.credentials?.token && this.OpenAPI) {
|
|
333
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI RefreshStatus`);
|
|
331
334
|
try {
|
|
332
335
|
const t = Date.now();
|
|
333
336
|
const nonce = 'requestID';
|
|
334
337
|
const data = this.platform.config.credentials?.token + t + nonce;
|
|
335
338
|
const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
|
|
336
339
|
const sign = signTerm.toString('base64');
|
|
337
|
-
this.debugLog(
|
|
340
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
338
341
|
const options = {
|
|
339
342
|
hostname: HostDomain,
|
|
340
343
|
port: 443,
|
|
@@ -349,39 +352,41 @@ export class Motion {
|
|
|
349
352
|
},
|
|
350
353
|
};
|
|
351
354
|
const req = https.request(options, (res) => {
|
|
352
|
-
this.debugLog(
|
|
355
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
|
|
353
356
|
let rawData = '';
|
|
354
357
|
res.on('data', (d) => {
|
|
355
358
|
rawData += d;
|
|
356
|
-
this.debugLog(
|
|
359
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
|
|
357
360
|
});
|
|
358
361
|
res.on('end', () => {
|
|
359
362
|
try {
|
|
360
363
|
this.deviceStatus = JSON.parse(rawData);
|
|
361
|
-
this.debugLog(
|
|
364
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${superStringify(this.deviceStatus)}`);
|
|
362
365
|
this.moveDetected = this.deviceStatus.body.moveDetected;
|
|
363
366
|
this.brightness = this.deviceStatus.body.brightness;
|
|
364
367
|
this.parseStatus();
|
|
365
368
|
this.updateHomeKitCharacteristics();
|
|
366
369
|
} catch (e: any) {
|
|
367
|
-
this.errorLog(
|
|
370
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
368
371
|
}
|
|
369
372
|
});
|
|
370
373
|
});
|
|
371
374
|
req.on('error', (e: any) => {
|
|
372
|
-
this.errorLog(
|
|
375
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
373
376
|
});
|
|
374
377
|
req.end();
|
|
375
378
|
} catch (e: any) {
|
|
376
|
-
this.errorLog(
|
|
379
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
377
380
|
if (this.deviceLogging.includes('debug')) {
|
|
378
381
|
this.errorLog(
|
|
379
|
-
|
|
382
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
|
|
380
383
|
` Error Message: ${superStringify(e.message)}`,
|
|
381
384
|
);
|
|
382
385
|
}
|
|
383
386
|
this.apiError(e);
|
|
384
387
|
}
|
|
388
|
+
} else {
|
|
389
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI is disabled, commands will not be sent.`);
|
|
385
390
|
}
|
|
386
391
|
}
|
|
387
392
|
|
|
@@ -390,30 +395,31 @@ export class Motion {
|
|
|
390
395
|
*/
|
|
391
396
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
392
397
|
if (this.MotionDetected === undefined) {
|
|
393
|
-
this.debugLog(
|
|
398
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MotionDetected: ${this.MotionDetected}`);
|
|
394
399
|
} else {
|
|
395
400
|
this.motionSensorService.updateCharacteristic(this.platform.Characteristic.MotionDetected, this.MotionDetected);
|
|
396
|
-
this.debugLog(
|
|
401
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic MotionDetected: ${this.MotionDetected}`);
|
|
397
402
|
}
|
|
398
403
|
if (this.device.ble) {
|
|
399
404
|
if (this.BatteryLevel === undefined) {
|
|
400
|
-
this.debugLog(
|
|
405
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
|
|
401
406
|
} else {
|
|
402
407
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
|
|
403
|
-
this.debugLog(
|
|
408
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
|
|
404
409
|
}
|
|
405
410
|
if (this.StatusLowBattery === undefined) {
|
|
406
|
-
this.debugLog(
|
|
411
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
|
|
407
412
|
} else {
|
|
408
413
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
409
|
-
this.debugLog(
|
|
414
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
410
415
|
}
|
|
411
416
|
if (this.CurrentAmbientLightLevel === undefined) {
|
|
412
|
-
this.debugLog(
|
|
417
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
|
|
413
418
|
} else {
|
|
414
419
|
this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
|
|
415
420
|
this.debugLog(
|
|
416
|
-
|
|
421
|
+
`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
422
|
+
+ ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
|
|
417
423
|
);
|
|
418
424
|
}
|
|
419
425
|
}
|
|
@@ -437,6 +443,9 @@ export class Motion {
|
|
|
437
443
|
if (device.ble !== undefined) {
|
|
438
444
|
config['ble'] = device.ble;
|
|
439
445
|
}
|
|
446
|
+
if (device.openAPI !== undefined) {
|
|
447
|
+
config['openAPI'] = device.openAPI;
|
|
448
|
+
}
|
|
440
449
|
if (device.logging !== undefined) {
|
|
441
450
|
config['logging'] = device.logging;
|
|
442
451
|
}
|
|
@@ -450,30 +459,39 @@ export class Motion {
|
|
|
450
459
|
config['offline'] = device.offline;
|
|
451
460
|
}
|
|
452
461
|
if (Object.entries(config).length !== 0) {
|
|
453
|
-
this.infoLog(
|
|
462
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
|
|
454
463
|
}
|
|
455
464
|
}
|
|
456
465
|
|
|
457
466
|
async refreshRate(device: device & devicesConfig): Promise<void> {
|
|
458
467
|
if (device.refreshRate) {
|
|
459
468
|
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
460
|
-
this.debugLog(
|
|
469
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
461
470
|
} else if (this.platform.config.options!.refreshRate) {
|
|
462
471
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
463
|
-
this.debugLog(
|
|
472
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
async openAPI() {
|
|
477
|
+
if (!this.device.openAPI) {
|
|
478
|
+
this.OpenAPI = true;
|
|
479
|
+
} else {
|
|
480
|
+
this.OpenAPI = this.device.openAPI;
|
|
464
481
|
}
|
|
482
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
|
|
465
483
|
}
|
|
466
484
|
|
|
467
485
|
async scan(device: device & devicesConfig): Promise<void> {
|
|
468
486
|
if (device.scanDuration) {
|
|
469
487
|
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
470
488
|
if (device.ble) {
|
|
471
|
-
this.debugLog(
|
|
489
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
472
490
|
}
|
|
473
491
|
} else {
|
|
474
492
|
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
475
493
|
if (this.device.ble) {
|
|
476
|
-
this.debugLog(
|
|
494
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
477
495
|
}
|
|
478
496
|
}
|
|
479
497
|
}
|
|
@@ -481,24 +499,25 @@ export class Motion {
|
|
|
481
499
|
async logs(device: device & devicesConfig): Promise<void> {
|
|
482
500
|
if (this.platform.debugMode) {
|
|
483
501
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
484
|
-
this.debugLog(
|
|
502
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
485
503
|
} else if (device.logging) {
|
|
486
504
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
487
|
-
this.debugLog(
|
|
505
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
488
506
|
} else if (this.platform.config.options?.logging) {
|
|
489
507
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
490
|
-
this.debugLog(
|
|
508
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
491
509
|
} else {
|
|
492
510
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
493
|
-
this.debugLog(
|
|
511
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
494
512
|
}
|
|
495
513
|
}
|
|
496
514
|
|
|
497
515
|
FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
498
516
|
let FirmwareRevision: string;
|
|
499
|
-
this.debugLog(
|
|
500
|
-
|
|
501
|
-
this.debugLog(
|
|
517
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
518
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
519
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
520
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
502
521
|
if (accessory.context.FirmwareRevision) {
|
|
503
522
|
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
504
523
|
} else if (device.firmware) {
|