@switchbot/homebridge-switchbot 2.2.1-beta.1 → 2.2.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/dist/device/bot.js +1 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +3 -0
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +14 -10
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +1 -1
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.js +1 -1
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.js +1 -1
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.js +1 -1
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.js +1 -1
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.js +1 -1
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js +1 -1
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.js +1 -1
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.js +1 -1
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.js +1 -1
- package/dist/device/striplight.js.map +1 -1
- package/dist/platform.js +66 -67
- package/dist/platform.js.map +1 -1
- package/package.json +2 -2
- package/src/device/bot.ts +1 -1
- package/src/device/ceilinglight.ts +14 -9
- package/src/device/colorbulb.ts +1 -1
- package/src/device/contact.ts +1 -1
- package/src/device/curtain.ts +1 -1
- package/src/device/humidifier.ts +1 -1
- package/src/device/lock.ts +1 -1
- package/src/device/meter.ts +1 -1
- package/src/device/meterplus.ts +1 -1
- package/src/device/motion.ts +1 -1
- package/src/device/plug.ts +1 -1
- package/src/device/striplight.ts +1 -1
- package/src/platform.ts +75 -75
package/src/platform.ts
CHANGED
|
@@ -285,91 +285,91 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
285
285
|
this.debugLog(`d: ${d}`);
|
|
286
286
|
});
|
|
287
287
|
res.on('end', () => {
|
|
288
|
-
try {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
this.createDevice(device);
|
|
288
|
+
// try {
|
|
289
|
+
const devicesAPI = JSON.parse(rawData);
|
|
290
|
+
this.debugLog(`devicesAPI: ${superStringify(devicesAPI.body)}`);
|
|
291
|
+
// SwitchBot Devices
|
|
292
|
+
if (devicesAPI.body.deviceList.length !== 0) {
|
|
293
|
+
this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
294
|
+
} else {
|
|
295
|
+
this.debugLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
296
|
+
}
|
|
297
|
+
const deviceLists = devicesAPI.body.deviceList;
|
|
298
|
+
if (!this.config.options?.devices) {
|
|
299
|
+
this.debugLog(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
300
|
+
const devices = deviceLists.map((v: any) => v);
|
|
301
|
+
for (const device of devices) {
|
|
302
|
+
if (device.deviceType) {
|
|
303
|
+
if (device.configDeviceName) {
|
|
304
|
+
device.deviceName = device.configDeviceName;
|
|
307
305
|
}
|
|
306
|
+
this.createDevice(device);
|
|
308
307
|
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
this.createDevice(device);
|
|
308
|
+
}
|
|
309
|
+
} else if (this.config.credentials?.token && this.config.options.devices) {
|
|
310
|
+
this.debugLog(`SwitchBot Device Config Set: ${superStringify(this.config.options?.devices)}`);
|
|
311
|
+
const deviceConfigs = this.config.options?.devices;
|
|
312
|
+
|
|
313
|
+
const mergeBydeviceId = (a1: { deviceId: string }[], a2: any[]) =>
|
|
314
|
+
a1.map((itm: { deviceId: string }) => ({
|
|
315
|
+
...a2.find(
|
|
316
|
+
(item: { deviceId: string }) =>
|
|
317
|
+
item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item,
|
|
318
|
+
),
|
|
319
|
+
...itm,
|
|
320
|
+
}));
|
|
321
|
+
|
|
322
|
+
const devices = mergeBydeviceId(deviceLists, deviceConfigs);
|
|
323
|
+
this.debugLog(`SwitchBot Devices: ${superStringify(devices)}`);
|
|
324
|
+
for (const device of devices) {
|
|
325
|
+
if (device.deviceType) {
|
|
326
|
+
if (device.configDeviceName) {
|
|
327
|
+
device.deviceName = device.configDeviceName;
|
|
330
328
|
}
|
|
329
|
+
this.createDevice(device);
|
|
331
330
|
}
|
|
332
|
-
} else {
|
|
333
|
-
this.errorLog('SwitchBot Token Supplied, Issue with Auth.');
|
|
334
331
|
}
|
|
332
|
+
} else {
|
|
333
|
+
this.errorLog('SwitchBot Token Supplied, Issue with Auth.');
|
|
334
|
+
}
|
|
335
335
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
this.createIRDevice(device);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
} else {
|
|
352
|
-
this.debugLog(`IR Device Config Set: ${superStringify(this.config.options?.irdevices)}`);
|
|
353
|
-
const irDeviceConfig = this.config.options?.irdevices;
|
|
354
|
-
|
|
355
|
-
const mergeIRBydeviceId = (a1: { deviceId: string }[], a2: any[]) =>
|
|
356
|
-
a1.map((itm: { deviceId: string }) => ({
|
|
357
|
-
...a2.find(
|
|
358
|
-
(item: { deviceId: string }) =>
|
|
359
|
-
item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item,
|
|
360
|
-
),
|
|
361
|
-
...itm,
|
|
362
|
-
}));
|
|
363
|
-
|
|
364
|
-
const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
|
|
365
|
-
this.debugLog(`IR Devices: ${superStringify(devices)}`);
|
|
366
|
-
for (const device of devices) {
|
|
336
|
+
// IR Devices
|
|
337
|
+
if (devicesAPI.body.infraredRemoteList.length !== 0) {
|
|
338
|
+
this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
339
|
+
} else {
|
|
340
|
+
this.debugLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
341
|
+
}
|
|
342
|
+
const irDeviceLists = devicesAPI.body.infraredRemoteList;
|
|
343
|
+
if (!this.config.options?.irdevices) {
|
|
344
|
+
this.debugLog(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
|
|
345
|
+
const devices = irDeviceLists.map((v: any) => v);
|
|
346
|
+
for (const device of devices) {
|
|
347
|
+
if (device.remoteType) {
|
|
367
348
|
this.createIRDevice(device);
|
|
368
349
|
}
|
|
369
350
|
}
|
|
370
|
-
}
|
|
371
|
-
this.
|
|
351
|
+
} else {
|
|
352
|
+
this.debugLog(`IR Device Config Set: ${superStringify(this.config.options?.irdevices)}`);
|
|
353
|
+
const irDeviceConfig = this.config.options?.irdevices;
|
|
354
|
+
|
|
355
|
+
const mergeIRBydeviceId = (a1: { deviceId: string }[], a2: any[]) =>
|
|
356
|
+
a1.map((itm: { deviceId: string }) => ({
|
|
357
|
+
...a2.find(
|
|
358
|
+
(item: { deviceId: string }) =>
|
|
359
|
+
item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item,
|
|
360
|
+
),
|
|
361
|
+
...itm,
|
|
362
|
+
}));
|
|
363
|
+
|
|
364
|
+
const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
|
|
365
|
+
this.debugLog(`IR Devices: ${superStringify(devices)}`);
|
|
366
|
+
for (const device of devices) {
|
|
367
|
+
this.createIRDevice(device);
|
|
368
|
+
}
|
|
372
369
|
}
|
|
370
|
+
//} catch (e:any) {
|
|
371
|
+
// this.errorLog(`API Request: ${e}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
372
|
+
// }
|
|
373
373
|
});
|
|
374
374
|
});
|
|
375
375
|
req.on('error', (e: any) => {
|