@switchbot/homebridge-switchbot 3.5.1-beta.12 → 3.5.1-beta.3
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/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +9 -6
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +3 -7
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.js +9 -9
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +3 -5
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +3 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +103 -44
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -0
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +49 -18
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +9 -9
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +19 -19
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +10 -22
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +67 -89
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +17 -15
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +76 -76
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +35 -35
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +9 -9
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +9 -9
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +12 -14
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +245 -245
- package/dist/platform.js.map +1 -1
- package/dist/types/devicewebhookstatus.d.ts +1 -1
- package/dist/types/devicewebhookstatus.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +1 -1
- package/src/device/bot.ts +1 -1
- package/src/device/ceilinglight.ts +15 -7
- package/src/device/colorbulb.ts +11 -8
- package/src/device/curtain.ts +1 -1
- package/src/device/device.ts +9 -9
- package/src/device/fan.ts +1 -1
- package/src/device/waterdetector.ts +3 -5
- package/src/irdevice/airconditioner.ts +97 -53
- package/src/irdevice/airpurifier.ts +45 -23
- package/src/irdevice/camera.ts +9 -9
- package/src/irdevice/fan.ts +19 -19
- package/src/irdevice/irdevice.ts +68 -92
- package/src/irdevice/light.ts +17 -15
- package/src/irdevice/other.ts +76 -76
- package/src/irdevice/tv.ts +35 -35
- package/src/irdevice/vacuumcleaner.ts +9 -9
- package/src/irdevice/waterheater.ts +9 -9
- package/src/platform.ts +247 -247
- package/src/types/devicewebhookstatus.ts +1 -1
package/dist/platform.js
CHANGED
|
@@ -32,13 +32,13 @@ import { AirConditioner } from './irdevice/airconditioner.js';
|
|
|
32
32
|
import { Buffer } from 'buffer';
|
|
33
33
|
import { request } from 'undici';
|
|
34
34
|
import asyncmqtt from 'async-mqtt';
|
|
35
|
+
import { isBlindTiltDevice, isCurtainDevice, sleep } from './utils.js';
|
|
35
36
|
import { createServer } from 'http';
|
|
36
37
|
import { queueScheduler } from 'rxjs';
|
|
37
38
|
import fakegato from 'fakegato-history';
|
|
38
39
|
import crypto, { randomUUID } from 'crypto';
|
|
39
40
|
import { readFileSync, writeFileSync } from 'fs';
|
|
40
41
|
import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
|
|
41
|
-
import { isBlindTiltDevice, isCurtainDevice, sleep } from './utils.js';
|
|
42
42
|
import { PLATFORM_NAME, PLUGIN_NAME, Devices, setupWebhook, updateWebhook, deleteWebhook, queryWebhook } from './settings.js';
|
|
43
43
|
/**
|
|
44
44
|
* HomebridgePlatform
|
|
@@ -61,7 +61,7 @@ export class SwitchBotPlatform {
|
|
|
61
61
|
mqttClient = null;
|
|
62
62
|
fakegatoAPI;
|
|
63
63
|
eve;
|
|
64
|
-
webhookEventHandler
|
|
64
|
+
webhookEventHandler;
|
|
65
65
|
constructor(log, config, api) {
|
|
66
66
|
// initialize
|
|
67
67
|
this.accessories = [];
|
|
@@ -117,7 +117,7 @@ export class SwitchBotPlatform {
|
|
|
117
117
|
}
|
|
118
118
|
catch (e) {
|
|
119
119
|
this.errorLog(`Failed to Discover, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
120
|
-
|
|
120
|
+
this.debugErrorLog(`Failed to Discover, Error: ${e}`);
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
this.setupMqtt();
|
|
@@ -128,29 +128,29 @@ export class SwitchBotPlatform {
|
|
|
128
128
|
try {
|
|
129
129
|
const { connectAsync } = asyncmqtt;
|
|
130
130
|
this.mqttClient = await connectAsync(this.config.options?.mqttURL, this.config.options.mqttOptions || {});
|
|
131
|
-
|
|
132
|
-
this.mqttClient.on('error',
|
|
133
|
-
|
|
131
|
+
this.debugLog('MQTT connection has been established successfully.');
|
|
132
|
+
this.mqttClient.on('error', (e) => {
|
|
133
|
+
this.errorLog(`Failed to publish MQTT messages. ${e}`);
|
|
134
134
|
});
|
|
135
135
|
if (!this.config.options?.webhookURL) {
|
|
136
136
|
// receive webhook events via MQTT
|
|
137
|
-
|
|
137
|
+
this.infoLog(`Webhook is configured to be received through ${this.config.options.mqttURL}/homebridge-switchbot/webhook.`);
|
|
138
138
|
this.mqttClient.subscribe('homebridge-switchbot/webhook/+');
|
|
139
139
|
this.mqttClient.on('message', async (topic, message) => {
|
|
140
140
|
try {
|
|
141
|
-
|
|
141
|
+
this.debugLog(`Received Webhook via MQTT: ${topic}=${message}`);
|
|
142
142
|
const context = JSON.parse(message.toString());
|
|
143
143
|
this.webhookEventHandler[context.deviceMac]?.(context);
|
|
144
144
|
}
|
|
145
145
|
catch (e) {
|
|
146
|
-
|
|
146
|
+
this.errorLog(`Failed to handle webhook event. Error:${e}`);
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
catch (e) {
|
|
152
152
|
this.mqttClient = null;
|
|
153
|
-
|
|
153
|
+
this.errorLog(`Failed to establish MQTT connection. ${e}`);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -168,7 +168,7 @@ export class SwitchBotPlatform {
|
|
|
168
168
|
request.on('data', async (data) => {
|
|
169
169
|
try {
|
|
170
170
|
const body = JSON.parse(data);
|
|
171
|
-
|
|
171
|
+
this.debugLog(`Received Webhook: ${JSON.stringify(body)}`);
|
|
172
172
|
if (this.config.options?.mqttURL) {
|
|
173
173
|
const mac = body.context.deviceMac
|
|
174
174
|
?.toLowerCase()
|
|
@@ -211,9 +211,9 @@ export class SwitchBotPlatform {
|
|
|
211
211
|
}),
|
|
212
212
|
});
|
|
213
213
|
const response = await body.json();
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
this.debugLog(`setupWebhook: url:${url}`);
|
|
215
|
+
this.debugLog(`setupWebhook: body:${JSON.stringify(response)}`);
|
|
216
|
+
this.debugLog(`setupWebhook: statusCode:${statusCode}`);
|
|
217
217
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
218
218
|
this.errorLog(`Failed to configure webhook. Existing webhook well be overridden. HTTP:${statusCode} API:${response?.statusCode} `
|
|
219
219
|
+ `message:${response?.message}`);
|
|
@@ -233,9 +233,9 @@ export class SwitchBotPlatform {
|
|
|
233
233
|
}),
|
|
234
234
|
});
|
|
235
235
|
const response = await body.json();
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
this.debugLog(`updateWebhook: url:${url}`);
|
|
237
|
+
this.debugLog(`updateWebhook: body:${JSON.stringify(response)}`);
|
|
238
|
+
this.debugLog(`updateWebhook: statusCode:${statusCode}`);
|
|
239
239
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
240
240
|
this.errorLog(`Failed to update webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
241
241
|
}
|
|
@@ -252,8 +252,8 @@ export class SwitchBotPlatform {
|
|
|
252
252
|
}),
|
|
253
253
|
});
|
|
254
254
|
const response = await body.json();
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
this.debugLog(`queryWebhook: body:${JSON.stringify(response)}`);
|
|
256
|
+
this.debugLog(`queryWebhook: statusCode:${statusCode}`);
|
|
257
257
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
258
258
|
this.errorLog(`Failed to query webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
259
259
|
}
|
|
@@ -275,7 +275,9 @@ export class SwitchBotPlatform {
|
|
|
275
275
|
}),
|
|
276
276
|
});
|
|
277
277
|
const response = await body.json();
|
|
278
|
-
|
|
278
|
+
this.debugLog(`deleteWebhook: url:${url}`);
|
|
279
|
+
this.debugLog(`deleteWebhook: body:${JSON.stringify(response)}`);
|
|
280
|
+
this.debugLog(`deleteWebhook: statusCode:${statusCode}`);
|
|
279
281
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
280
282
|
this.errorLog(`Failed to delete webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
281
283
|
}
|
|
@@ -293,8 +295,8 @@ export class SwitchBotPlatform {
|
|
|
293
295
|
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
|
294
296
|
* It should be used to setup event handlers for characteristics and update respective values.
|
|
295
297
|
*/
|
|
296
|
-
|
|
297
|
-
|
|
298
|
+
configureAccessory(accessory) {
|
|
299
|
+
this.debugLog(`Loading accessory from cache: ${accessory.displayName}`);
|
|
298
300
|
// add the restored accessory to the accessories cache so we can track if it has already been registered
|
|
299
301
|
this.accessories.push(accessory);
|
|
300
302
|
}
|
|
@@ -316,7 +318,7 @@ export class SwitchBotPlatform {
|
|
|
316
318
|
platformConfig['pushRate'] = this.config.options.pushRate;
|
|
317
319
|
}
|
|
318
320
|
if (Object.entries(platformConfig).length !== 0) {
|
|
319
|
-
|
|
321
|
+
this.debugWarnLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
|
|
320
322
|
}
|
|
321
323
|
if (this.config.options) {
|
|
322
324
|
// Device Config
|
|
@@ -431,7 +433,7 @@ export class SwitchBotPlatform {
|
|
|
431
433
|
if (pluginConfig.credentials.token) {
|
|
432
434
|
pluginConfig.credentials.openToken = undefined;
|
|
433
435
|
}
|
|
434
|
-
|
|
436
|
+
this.debugWarnLog(`token: ${pluginConfig.credentials.token}`);
|
|
435
437
|
// save the config, ensuring we maintain pretty json
|
|
436
438
|
writeFileSync(this.api.user.configPath(), JSON.stringify(currentConfig, null, 4));
|
|
437
439
|
this.verifyConfig();
|
|
@@ -471,29 +473,29 @@ export class SwitchBotPlatform {
|
|
|
471
473
|
let retryCount = 0;
|
|
472
474
|
const maxRetries = this.maxRetries; // Maximum number of retries
|
|
473
475
|
const delayBetweenRetries = this.delayBetweenRetries; // Delay between retries in milliseconds
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
476
|
+
this.debugWarnLog(`Retry Count: ${retryCount}`);
|
|
477
|
+
this.debugWarnLog(`Max Retries: ${maxRetries}`);
|
|
478
|
+
this.debugWarnLog(`Delay Between Retries: ${delayBetweenRetries}`);
|
|
477
479
|
while (retryCount < maxRetries) {
|
|
478
480
|
try {
|
|
479
481
|
const { body, statusCode } = await request(Devices, {
|
|
480
482
|
headers: this.generateHeaders(),
|
|
481
483
|
});
|
|
482
|
-
|
|
484
|
+
this.debugWarnLog(`statusCode: ${statusCode}`);
|
|
483
485
|
const devicesAPI = await body.json();
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
486
|
+
this.debugWarnLog(`devicesAPI: ${JSON.stringify(devicesAPI)}`);
|
|
487
|
+
this.debugWarnLog(`devicesAPI Body: ${JSON.stringify(devicesAPI.body)}`);
|
|
488
|
+
this.debugWarnLog(`devicesAPI StatusCode: ${devicesAPI.statusCode}`);
|
|
487
489
|
if ((statusCode === 200 || statusCode === 100) && (devicesAPI.statusCode === 200 || devicesAPI.statusCode === 100)) {
|
|
488
|
-
|
|
490
|
+
this.debugErrorLog(`statusCode: ${statusCode} & devicesAPI StatusCode: ${devicesAPI.statusCode}`);
|
|
489
491
|
// SwitchBot Devices
|
|
490
492
|
const deviceLists = devicesAPI.body.deviceList;
|
|
491
|
-
|
|
492
|
-
|
|
493
|
+
this.debugWarnLog(`DeviceLists: ${JSON.stringify(deviceLists)}`);
|
|
494
|
+
this.debugWarnLog(`DeviceLists Length: ${deviceLists.length}`);
|
|
493
495
|
if (!this.config.options?.devices) {
|
|
494
|
-
|
|
496
|
+
this.debugLog(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
495
497
|
if (deviceLists.length === 0) {
|
|
496
|
-
|
|
498
|
+
this.debugLog(`SwitchBot API Currently Doesn't Have Any Devices With Cloud Services Enabled: ${JSON.stringify(devicesAPI.body)}`);
|
|
497
499
|
}
|
|
498
500
|
else {
|
|
499
501
|
const devices = deviceLists.map((v) => v);
|
|
@@ -508,9 +510,9 @@ export class SwitchBotPlatform {
|
|
|
508
510
|
}
|
|
509
511
|
}
|
|
510
512
|
else if (this.config.credentials?.token && this.config.options.devices) {
|
|
511
|
-
|
|
513
|
+
this.debugLog(`SwitchBot Device Config Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
512
514
|
if (deviceLists.length === 0) {
|
|
513
|
-
|
|
515
|
+
this.debugLog(`SwitchBot API Currently Doesn't Have Any Devices With Cloud Services Enabled: ${JSON.stringify(devicesAPI.body)}`);
|
|
514
516
|
}
|
|
515
517
|
else {
|
|
516
518
|
const deviceConfigs = this.config.options?.devices;
|
|
@@ -519,7 +521,7 @@ export class SwitchBotPlatform {
|
|
|
519
521
|
...itm,
|
|
520
522
|
}));
|
|
521
523
|
const devices = mergeBydeviceId(deviceLists, deviceConfigs);
|
|
522
|
-
|
|
524
|
+
this.debugLog(`SwitchBot Devices: ${JSON.stringify(devices)}`);
|
|
523
525
|
for (const device of devices) {
|
|
524
526
|
if (!device.deviceType) {
|
|
525
527
|
device.deviceType = device.configDeviceType;
|
|
@@ -541,12 +543,12 @@ export class SwitchBotPlatform {
|
|
|
541
543
|
this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
542
544
|
}
|
|
543
545
|
else {
|
|
544
|
-
|
|
546
|
+
this.debugLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
545
547
|
}
|
|
546
548
|
// IR Devices
|
|
547
549
|
const irDeviceLists = devicesAPI.body.infraredRemoteList;
|
|
548
550
|
if (!this.config.options?.irdevices) {
|
|
549
|
-
|
|
551
|
+
this.debugLog(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
|
|
550
552
|
const devices = irDeviceLists.map((v) => v);
|
|
551
553
|
for (const device of devices) {
|
|
552
554
|
if (device.remoteType) {
|
|
@@ -555,14 +557,14 @@ export class SwitchBotPlatform {
|
|
|
555
557
|
}
|
|
556
558
|
}
|
|
557
559
|
else {
|
|
558
|
-
|
|
560
|
+
this.debugLog(`IR Device Config Set: ${JSON.stringify(this.config.options?.irdevices)}`);
|
|
559
561
|
const irDeviceConfig = this.config.options?.irdevices;
|
|
560
562
|
const mergeIRBydeviceId = (a1, a2) => a1.map((itm) => ({
|
|
561
563
|
...a2.find((item) => item.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') === itm.deviceId.toUpperCase().replace(/[^A-Z0-9]+/g, '') && item),
|
|
562
564
|
...itm,
|
|
563
565
|
}));
|
|
564
566
|
const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
|
|
565
|
-
|
|
567
|
+
this.debugLog(`IR Devices: ${JSON.stringify(devices)}`);
|
|
566
568
|
for (const device of devices) {
|
|
567
569
|
this.createIRDevice(device);
|
|
568
570
|
}
|
|
@@ -571,7 +573,7 @@ export class SwitchBotPlatform {
|
|
|
571
573
|
this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
572
574
|
}
|
|
573
575
|
else {
|
|
574
|
-
|
|
576
|
+
this.debugLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
575
577
|
}
|
|
576
578
|
break;
|
|
577
579
|
}
|
|
@@ -588,12 +590,12 @@ export class SwitchBotPlatform {
|
|
|
588
590
|
catch (e) {
|
|
589
591
|
retryCount++;
|
|
590
592
|
this.debugErrorLog(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
591
|
-
|
|
593
|
+
this.debugErrorLog(`Failed to Discover Devices, Error: ${e}`);
|
|
592
594
|
}
|
|
593
595
|
}
|
|
594
596
|
}
|
|
595
597
|
else if (!this.config.credentials?.token && this.config.options?.devices) {
|
|
596
|
-
|
|
598
|
+
this.debugLog(`SwitchBot Device Manual Config Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
597
599
|
const deviceConfigs = this.config.options?.devices;
|
|
598
600
|
const devices = deviceConfigs.map((v) => v);
|
|
599
601
|
for (const device of devices) {
|
|
@@ -608,73 +610,73 @@ export class SwitchBotPlatform {
|
|
|
608
610
|
this.errorLog('Neither SwitchBot Token or Device Config are not set.');
|
|
609
611
|
}
|
|
610
612
|
}
|
|
611
|
-
|
|
613
|
+
createDevice(device) {
|
|
612
614
|
switch (device.deviceType) {
|
|
613
615
|
case 'Humidifier':
|
|
614
|
-
|
|
616
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
615
617
|
this.createHumidifier(device);
|
|
616
618
|
break;
|
|
617
619
|
case 'Hub Mini':
|
|
618
|
-
|
|
620
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
619
621
|
break;
|
|
620
622
|
case 'Hub Plus':
|
|
621
|
-
|
|
623
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
622
624
|
break;
|
|
623
625
|
case 'Hub 2':
|
|
624
|
-
|
|
626
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
625
627
|
this.createHub2(device);
|
|
626
628
|
break;
|
|
627
629
|
case 'Bot':
|
|
628
|
-
|
|
630
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
629
631
|
this.createBot(device);
|
|
630
632
|
break;
|
|
631
633
|
case 'Meter':
|
|
632
|
-
|
|
634
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
633
635
|
this.createMeter(device);
|
|
634
636
|
break;
|
|
635
637
|
case 'MeterPlus':
|
|
636
638
|
case 'Meter Plus (JP)':
|
|
637
|
-
|
|
639
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
638
640
|
this.createMeterPlus(device);
|
|
639
641
|
break;
|
|
640
642
|
case 'WoIOSensor':
|
|
641
|
-
|
|
643
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
642
644
|
this.createIOSensor(device);
|
|
643
645
|
break;
|
|
644
646
|
case 'Water Detector':
|
|
645
|
-
|
|
647
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
646
648
|
this.createWaterDetector(device);
|
|
647
649
|
break;
|
|
648
650
|
case 'Motion Sensor':
|
|
649
|
-
|
|
651
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
650
652
|
this.createMotion(device);
|
|
651
653
|
break;
|
|
652
654
|
case 'Contact Sensor':
|
|
653
|
-
|
|
655
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
654
656
|
this.createContact(device);
|
|
655
657
|
break;
|
|
656
658
|
case 'Curtain':
|
|
657
659
|
case 'Curtain3':
|
|
658
|
-
|
|
660
|
+
this.debugLog(`Discovered ${device.deviceType} ${device.deviceName}: ${device.deviceId}`);
|
|
659
661
|
this.createCurtain(device);
|
|
660
662
|
break;
|
|
661
663
|
case 'Blind Tilt':
|
|
662
|
-
|
|
664
|
+
this.debugLog(`Discovered ${device.deviceType} ${device.deviceName}: ${device.deviceId}`);
|
|
663
665
|
this.createBlindTilt(device);
|
|
664
666
|
break;
|
|
665
667
|
case 'Plug':
|
|
666
668
|
case 'Plug Mini (US)':
|
|
667
669
|
case 'Plug Mini (JP)':
|
|
668
|
-
|
|
670
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
669
671
|
this.createPlug(device);
|
|
670
672
|
break;
|
|
671
673
|
case 'Smart Lock':
|
|
672
674
|
case 'Smart Lock Pro':
|
|
673
|
-
|
|
675
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
674
676
|
this.createLock(device);
|
|
675
677
|
break;
|
|
676
678
|
case 'Color Bulb':
|
|
677
|
-
|
|
679
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
678
680
|
this.createColorBulb(device);
|
|
679
681
|
break;
|
|
680
682
|
case 'K10+':
|
|
@@ -683,32 +685,32 @@ export class SwitchBotPlatform {
|
|
|
683
685
|
case 'Robot Vacuum Cleaner S1':
|
|
684
686
|
case 'Robot Vacuum Cleaner S1 Plus':
|
|
685
687
|
case 'Robot Vacuum Cleaner S10':
|
|
686
|
-
|
|
688
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
687
689
|
this.createRobotVacuumCleaner(device);
|
|
688
690
|
break;
|
|
689
691
|
case 'Ceiling Light':
|
|
690
692
|
case 'Ceiling Light Pro':
|
|
691
|
-
|
|
693
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
692
694
|
this.createCeilingLight(device);
|
|
693
695
|
break;
|
|
694
696
|
case 'Strip Light':
|
|
695
|
-
|
|
697
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
696
698
|
this.createStripLight(device);
|
|
697
699
|
break;
|
|
698
700
|
case 'Battery Circulator Fan':
|
|
699
|
-
|
|
701
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
700
702
|
this.createFan(device);
|
|
701
703
|
break;
|
|
702
704
|
case 'Remote':
|
|
703
705
|
case 'Indoor Cam':
|
|
704
706
|
case 'remote with screen+':
|
|
705
|
-
|
|
707
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}, is currently not supported, device: ${JSON.stringify(device)}`);
|
|
706
708
|
break;
|
|
707
709
|
default:
|
|
708
710
|
this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`, +`Submit Feature Requests Here: https://tinyurl.com/SwitchBotFeatureRequest, device: ${JSON.stringify(device)}`);
|
|
709
711
|
}
|
|
710
712
|
}
|
|
711
|
-
|
|
713
|
+
createIRDevice(device) {
|
|
712
714
|
if (device.connectionType === undefined) {
|
|
713
715
|
device.connectionType = 'OpenAPI';
|
|
714
716
|
}
|
|
@@ -725,7 +727,7 @@ export class SwitchBotPlatform {
|
|
|
725
727
|
case 'DIY DVD':
|
|
726
728
|
case 'Speaker':
|
|
727
729
|
case 'DIY Speaker':
|
|
728
|
-
|
|
730
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
729
731
|
if (device.external === undefined) {
|
|
730
732
|
device.external = true;
|
|
731
733
|
this.createTV(device);
|
|
@@ -736,45 +738,45 @@ export class SwitchBotPlatform {
|
|
|
736
738
|
break;
|
|
737
739
|
case 'Fan':
|
|
738
740
|
case 'DIY Fan':
|
|
739
|
-
|
|
741
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
740
742
|
this.createIRFan(device);
|
|
741
743
|
break;
|
|
742
744
|
case 'Air Conditioner':
|
|
743
745
|
case 'DIY Air Conditioner':
|
|
744
|
-
|
|
746
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
745
747
|
this.createAirConditioner(device);
|
|
746
748
|
break;
|
|
747
749
|
case 'Light':
|
|
748
750
|
case 'DIY Light':
|
|
749
|
-
|
|
751
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
750
752
|
this.createLight(device);
|
|
751
753
|
break;
|
|
752
754
|
case 'Air Purifier':
|
|
753
755
|
case 'DIY Air Purifier':
|
|
754
|
-
|
|
756
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
755
757
|
this.createAirPurifier(device);
|
|
756
758
|
break;
|
|
757
759
|
case 'Water Heater':
|
|
758
760
|
case 'DIY Water Heater':
|
|
759
|
-
|
|
761
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
760
762
|
this.createWaterHeater(device);
|
|
761
763
|
break;
|
|
762
764
|
case 'Vacuum Cleaner':
|
|
763
765
|
case 'DIY Vacuum Cleaner':
|
|
764
|
-
|
|
766
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
765
767
|
this.createVacuumCleaner(device);
|
|
766
768
|
break;
|
|
767
769
|
case 'Camera':
|
|
768
770
|
case 'DIY Camera':
|
|
769
|
-
|
|
771
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
770
772
|
this.createCamera(device);
|
|
771
773
|
break;
|
|
772
774
|
case 'Others':
|
|
773
|
-
|
|
775
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
774
776
|
this.createOthers(device);
|
|
775
777
|
break;
|
|
776
778
|
default:
|
|
777
|
-
|
|
779
|
+
this.debugLog(`Unsupported Device: ${JSON.stringify(device)}`);
|
|
778
780
|
this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`);
|
|
779
781
|
this.warnLog('Submit Feature Requests Here: ' + 'https://tinyurl.com/SwitchBotFeatureRequest');
|
|
780
782
|
}
|
|
@@ -801,7 +803,7 @@ export class SwitchBotPlatform {
|
|
|
801
803
|
// create the accessory handler for the restored accessory
|
|
802
804
|
// this is imported from `platformAccessory.ts`
|
|
803
805
|
new Humidifier(this, existingAccessory, device);
|
|
804
|
-
|
|
806
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
805
807
|
}
|
|
806
808
|
else {
|
|
807
809
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -827,13 +829,13 @@ export class SwitchBotPlatform {
|
|
|
827
829
|
// create the accessory handler for the newly create accessory
|
|
828
830
|
// this is imported from `platformAccessory.ts`
|
|
829
831
|
new Humidifier(this, accessory, device);
|
|
830
|
-
|
|
832
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
831
833
|
// publish device externally or link the accessory to your platform
|
|
832
834
|
this.externalOrPlatform(device, accessory);
|
|
833
835
|
this.accessories.push(accessory);
|
|
834
836
|
}
|
|
835
837
|
else {
|
|
836
|
-
|
|
838
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
837
839
|
}
|
|
838
840
|
}
|
|
839
841
|
async createBot(device) {
|
|
@@ -858,7 +860,7 @@ export class SwitchBotPlatform {
|
|
|
858
860
|
// create the accessory handler for the restored accessory
|
|
859
861
|
// this is imported from `platformAccessory.ts`
|
|
860
862
|
new Bot(this, existingAccessory, device);
|
|
861
|
-
|
|
863
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
862
864
|
}
|
|
863
865
|
else {
|
|
864
866
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -885,13 +887,13 @@ export class SwitchBotPlatform {
|
|
|
885
887
|
// create the accessory handler for the newly create accessory
|
|
886
888
|
// this is imported from `platformAccessory.ts`
|
|
887
889
|
new Bot(this, accessory, device);
|
|
888
|
-
|
|
890
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
889
891
|
// publish device externally or link the accessory to your platform
|
|
890
892
|
this.externalOrPlatform(device, accessory);
|
|
891
893
|
this.accessories.push(accessory);
|
|
892
894
|
}
|
|
893
895
|
else {
|
|
894
|
-
|
|
896
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
895
897
|
}
|
|
896
898
|
}
|
|
897
899
|
async createMeter(device) {
|
|
@@ -916,7 +918,7 @@ export class SwitchBotPlatform {
|
|
|
916
918
|
// create the accessory handler for the restored accessory
|
|
917
919
|
// this is imported from `platformAccessory.ts`
|
|
918
920
|
new Meter(this, existingAccessory, device);
|
|
919
|
-
|
|
921
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
920
922
|
}
|
|
921
923
|
else {
|
|
922
924
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -942,13 +944,13 @@ export class SwitchBotPlatform {
|
|
|
942
944
|
// create the accessory handler for the newly create accessory
|
|
943
945
|
// this is imported from `platformAccessory.ts`
|
|
944
946
|
new Meter(this, accessory, device);
|
|
945
|
-
|
|
947
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
946
948
|
// publish device externally or link the accessory to your platform
|
|
947
949
|
this.externalOrPlatform(device, accessory);
|
|
948
950
|
this.accessories.push(accessory);
|
|
949
951
|
}
|
|
950
952
|
else {
|
|
951
|
-
|
|
953
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
952
954
|
}
|
|
953
955
|
}
|
|
954
956
|
async createMeterPlus(device) {
|
|
@@ -974,7 +976,7 @@ export class SwitchBotPlatform {
|
|
|
974
976
|
// create the accessory handler for the restored accessory
|
|
975
977
|
// this is imported from `platformAccessory.ts`
|
|
976
978
|
new MeterPlus(this, existingAccessory, device);
|
|
977
|
-
|
|
979
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
978
980
|
}
|
|
979
981
|
else {
|
|
980
982
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1000,13 +1002,13 @@ export class SwitchBotPlatform {
|
|
|
1000
1002
|
// create the accessory handler for the newly create accessory
|
|
1001
1003
|
// this is imported from `platformAccessory.ts`
|
|
1002
1004
|
new MeterPlus(this, accessory, device);
|
|
1003
|
-
|
|
1005
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1004
1006
|
// publish device externally or link the accessory to your platform
|
|
1005
1007
|
this.externalOrPlatform(device, accessory);
|
|
1006
1008
|
this.accessories.push(accessory);
|
|
1007
1009
|
}
|
|
1008
1010
|
else {
|
|
1009
|
-
|
|
1011
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1010
1012
|
}
|
|
1011
1013
|
}
|
|
1012
1014
|
async createHub2(device) {
|
|
@@ -1032,7 +1034,7 @@ export class SwitchBotPlatform {
|
|
|
1032
1034
|
// create the accessory handler for the restored accessory
|
|
1033
1035
|
// this is imported from `platformAccessory.ts`
|
|
1034
1036
|
new Hub(this, existingAccessory, device);
|
|
1035
|
-
|
|
1037
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1036
1038
|
}
|
|
1037
1039
|
else {
|
|
1038
1040
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1058,13 +1060,13 @@ export class SwitchBotPlatform {
|
|
|
1058
1060
|
// create the accessory handler for the newly create accessory
|
|
1059
1061
|
// this is imported from `platformAccessory.ts`
|
|
1060
1062
|
new Hub(this, accessory, device);
|
|
1061
|
-
|
|
1063
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1062
1064
|
// publish device externally or link the accessory to your platform
|
|
1063
1065
|
this.externalOrPlatform(device, accessory);
|
|
1064
1066
|
this.accessories.push(accessory);
|
|
1065
1067
|
}
|
|
1066
1068
|
else {
|
|
1067
|
-
|
|
1069
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1068
1070
|
}
|
|
1069
1071
|
}
|
|
1070
1072
|
async createIOSensor(device) {
|
|
@@ -1089,7 +1091,7 @@ export class SwitchBotPlatform {
|
|
|
1089
1091
|
// create the accessory handler for the restored accessory
|
|
1090
1092
|
// this is imported from `platformAccessory.ts`
|
|
1091
1093
|
new IOSensor(this, existingAccessory, device);
|
|
1092
|
-
|
|
1094
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1093
1095
|
}
|
|
1094
1096
|
else {
|
|
1095
1097
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1115,13 +1117,13 @@ export class SwitchBotPlatform {
|
|
|
1115
1117
|
// create the accessory handler for the newly create accessory
|
|
1116
1118
|
// this is imported from `platformAccessory.ts`
|
|
1117
1119
|
new IOSensor(this, accessory, device);
|
|
1118
|
-
|
|
1120
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1119
1121
|
// publish device externally or link the accessory to your platform
|
|
1120
1122
|
this.externalOrPlatform(device, accessory);
|
|
1121
1123
|
this.accessories.push(accessory);
|
|
1122
1124
|
}
|
|
1123
1125
|
else {
|
|
1124
|
-
|
|
1126
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1125
1127
|
}
|
|
1126
1128
|
}
|
|
1127
1129
|
async createWaterDetector(device) {
|
|
@@ -1146,7 +1148,7 @@ export class SwitchBotPlatform {
|
|
|
1146
1148
|
// create the accessory handler for the restored accessory
|
|
1147
1149
|
// this is imported from `platformAccessory.ts`
|
|
1148
1150
|
new WaterDetector(this, existingAccessory, device);
|
|
1149
|
-
|
|
1151
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1150
1152
|
}
|
|
1151
1153
|
else {
|
|
1152
1154
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1172,13 +1174,13 @@ export class SwitchBotPlatform {
|
|
|
1172
1174
|
// create the accessory handler for the newly create accessory
|
|
1173
1175
|
// this is imported from `platformAccessory.ts`
|
|
1174
1176
|
new WaterDetector(this, accessory, device);
|
|
1175
|
-
|
|
1177
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1176
1178
|
// publish device externally or link the accessory to your platform
|
|
1177
1179
|
this.externalOrPlatform(device, accessory);
|
|
1178
1180
|
this.accessories.push(accessory);
|
|
1179
1181
|
}
|
|
1180
1182
|
else {
|
|
1181
|
-
|
|
1183
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1182
1184
|
}
|
|
1183
1185
|
}
|
|
1184
1186
|
async createMotion(device) {
|
|
@@ -1203,7 +1205,7 @@ export class SwitchBotPlatform {
|
|
|
1203
1205
|
// create the accessory handler for the restored accessory
|
|
1204
1206
|
// this is imported from `platformAccessory.ts`
|
|
1205
1207
|
new Motion(this, existingAccessory, device);
|
|
1206
|
-
|
|
1208
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1207
1209
|
}
|
|
1208
1210
|
else {
|
|
1209
1211
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1229,13 +1231,13 @@ export class SwitchBotPlatform {
|
|
|
1229
1231
|
// create the accessory handler for the newly create accessory
|
|
1230
1232
|
// this is imported from `platformAccessory.ts`
|
|
1231
1233
|
new Motion(this, accessory, device);
|
|
1232
|
-
|
|
1234
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1233
1235
|
// publish device externally or link the accessory to your platform
|
|
1234
1236
|
this.externalOrPlatform(device, accessory);
|
|
1235
1237
|
this.accessories.push(accessory);
|
|
1236
1238
|
}
|
|
1237
1239
|
else {
|
|
1238
|
-
|
|
1240
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1239
1241
|
}
|
|
1240
1242
|
}
|
|
1241
1243
|
async createContact(device) {
|
|
@@ -1260,7 +1262,7 @@ export class SwitchBotPlatform {
|
|
|
1260
1262
|
// create the accessory handler for the restored accessory
|
|
1261
1263
|
// this is imported from `platformAccessory.ts`
|
|
1262
1264
|
new Contact(this, existingAccessory, device);
|
|
1263
|
-
|
|
1265
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1264
1266
|
}
|
|
1265
1267
|
else {
|
|
1266
1268
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1286,13 +1288,13 @@ export class SwitchBotPlatform {
|
|
|
1286
1288
|
// create the accessory handler for the newly create accessory
|
|
1287
1289
|
// this is imported from `platformAccessory.ts`
|
|
1288
1290
|
new Contact(this, accessory, device);
|
|
1289
|
-
|
|
1291
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1290
1292
|
// publish device externally or link the accessory to your platform
|
|
1291
1293
|
this.externalOrPlatform(device, accessory);
|
|
1292
1294
|
this.accessories.push(accessory);
|
|
1293
1295
|
}
|
|
1294
1296
|
else {
|
|
1295
|
-
|
|
1297
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1296
1298
|
}
|
|
1297
1299
|
}
|
|
1298
1300
|
async createBlindTilt(device) {
|
|
@@ -1317,7 +1319,7 @@ export class SwitchBotPlatform {
|
|
|
1317
1319
|
// create the accessory handler for the restored accessory
|
|
1318
1320
|
// this is imported from `platformAccessory.ts`
|
|
1319
1321
|
new BlindTilt(this, existingAccessory, device);
|
|
1320
|
-
|
|
1322
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1321
1323
|
}
|
|
1322
1324
|
else {
|
|
1323
1325
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1357,13 +1359,13 @@ export class SwitchBotPlatform {
|
|
|
1357
1359
|
// create the accessory handler for the newly create accessory
|
|
1358
1360
|
// this is imported from `platformAccessory.ts`
|
|
1359
1361
|
new BlindTilt(this, accessory, device);
|
|
1360
|
-
|
|
1362
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1361
1363
|
// publish device externally or link the accessory to your platform
|
|
1362
1364
|
this.externalOrPlatform(device, accessory);
|
|
1363
1365
|
this.accessories.push(accessory);
|
|
1364
1366
|
}
|
|
1365
1367
|
else {
|
|
1366
|
-
|
|
1368
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1367
1369
|
}
|
|
1368
1370
|
}
|
|
1369
1371
|
async createCurtain(device) {
|
|
@@ -1388,7 +1390,7 @@ export class SwitchBotPlatform {
|
|
|
1388
1390
|
// create the accessory handler for the restored accessory
|
|
1389
1391
|
// this is imported from `platformAccessory.ts`
|
|
1390
1392
|
new Curtain(this, existingAccessory, device);
|
|
1391
|
-
|
|
1393
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1392
1394
|
}
|
|
1393
1395
|
else {
|
|
1394
1396
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1428,13 +1430,13 @@ export class SwitchBotPlatform {
|
|
|
1428
1430
|
// create the accessory handler for the newly create accessory
|
|
1429
1431
|
// this is imported from `platformAccessory.ts`
|
|
1430
1432
|
new Curtain(this, accessory, device);
|
|
1431
|
-
|
|
1433
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1432
1434
|
// publish device externally or link the accessory to your platform
|
|
1433
1435
|
this.externalOrPlatform(device, accessory);
|
|
1434
1436
|
this.accessories.push(accessory);
|
|
1435
1437
|
}
|
|
1436
1438
|
else {
|
|
1437
|
-
|
|
1439
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1438
1440
|
}
|
|
1439
1441
|
}
|
|
1440
1442
|
async createPlug(device) {
|
|
@@ -1459,7 +1461,7 @@ export class SwitchBotPlatform {
|
|
|
1459
1461
|
// create the accessory handler for the restored accessory
|
|
1460
1462
|
// this is imported from `platformAccessory.ts`
|
|
1461
1463
|
new Plug(this, existingAccessory, device);
|
|
1462
|
-
|
|
1464
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1463
1465
|
}
|
|
1464
1466
|
else {
|
|
1465
1467
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1485,13 +1487,13 @@ export class SwitchBotPlatform {
|
|
|
1485
1487
|
// create the accessory handler for the newly create accessory
|
|
1486
1488
|
// this is imported from `platformAccessory.ts`
|
|
1487
1489
|
new Plug(this, accessory, device);
|
|
1488
|
-
|
|
1490
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1489
1491
|
// publish device externally or link the accessory to your platform
|
|
1490
1492
|
this.externalOrPlatform(device, accessory);
|
|
1491
1493
|
this.accessories.push(accessory);
|
|
1492
1494
|
}
|
|
1493
1495
|
else {
|
|
1494
|
-
|
|
1496
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1495
1497
|
}
|
|
1496
1498
|
}
|
|
1497
1499
|
async createLock(device) {
|
|
@@ -1516,7 +1518,7 @@ export class SwitchBotPlatform {
|
|
|
1516
1518
|
// create the accessory handler for the restored accessory
|
|
1517
1519
|
// this is imported from `platformAccessory.ts`
|
|
1518
1520
|
new Lock(this, existingAccessory, device);
|
|
1519
|
-
|
|
1521
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1520
1522
|
}
|
|
1521
1523
|
else {
|
|
1522
1524
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1542,13 +1544,13 @@ export class SwitchBotPlatform {
|
|
|
1542
1544
|
// create the accessory handler for the newly create accessory
|
|
1543
1545
|
// this is imported from `platformAccessory.ts`
|
|
1544
1546
|
new Lock(this, accessory, device);
|
|
1545
|
-
|
|
1547
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1546
1548
|
// publish device externally or link the accessory to your platform
|
|
1547
1549
|
this.externalOrPlatform(device, accessory);
|
|
1548
1550
|
this.accessories.push(accessory);
|
|
1549
1551
|
}
|
|
1550
1552
|
else {
|
|
1551
|
-
|
|
1553
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1552
1554
|
}
|
|
1553
1555
|
}
|
|
1554
1556
|
async createColorBulb(device) {
|
|
@@ -1573,7 +1575,7 @@ export class SwitchBotPlatform {
|
|
|
1573
1575
|
// create the accessory handler for the restored accessory
|
|
1574
1576
|
// this is imported from `platformAccessory.ts`
|
|
1575
1577
|
new ColorBulb(this, existingAccessory, device);
|
|
1576
|
-
|
|
1578
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1577
1579
|
}
|
|
1578
1580
|
else {
|
|
1579
1581
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1599,13 +1601,13 @@ export class SwitchBotPlatform {
|
|
|
1599
1601
|
// create the accessory handler for the newly create accessory
|
|
1600
1602
|
// this is imported from `platformAccessory.ts`
|
|
1601
1603
|
new ColorBulb(this, accessory, device);
|
|
1602
|
-
|
|
1604
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1603
1605
|
// publish device externally or link the accessory to your platform
|
|
1604
1606
|
this.externalOrPlatform(device, accessory);
|
|
1605
1607
|
this.accessories.push(accessory);
|
|
1606
1608
|
}
|
|
1607
1609
|
else {
|
|
1608
|
-
|
|
1610
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1609
1611
|
}
|
|
1610
1612
|
}
|
|
1611
1613
|
async createCeilingLight(device) {
|
|
@@ -1630,7 +1632,7 @@ export class SwitchBotPlatform {
|
|
|
1630
1632
|
// create the accessory handler for the restored accessory
|
|
1631
1633
|
// this is imported from `platformAccessory.ts`
|
|
1632
1634
|
new CeilingLight(this, existingAccessory, device);
|
|
1633
|
-
|
|
1635
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1634
1636
|
}
|
|
1635
1637
|
else {
|
|
1636
1638
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1656,13 +1658,13 @@ export class SwitchBotPlatform {
|
|
|
1656
1658
|
// create the accessory handler for the newly create accessory
|
|
1657
1659
|
// this is imported from `platformAccessory.ts`
|
|
1658
1660
|
new CeilingLight(this, accessory, device);
|
|
1659
|
-
|
|
1661
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1660
1662
|
// publish device externally or link the accessory to your platform
|
|
1661
1663
|
this.externalOrPlatform(device, accessory);
|
|
1662
1664
|
this.accessories.push(accessory);
|
|
1663
1665
|
}
|
|
1664
1666
|
else {
|
|
1665
|
-
|
|
1667
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1666
1668
|
}
|
|
1667
1669
|
}
|
|
1668
1670
|
async createStripLight(device) {
|
|
@@ -1687,7 +1689,7 @@ export class SwitchBotPlatform {
|
|
|
1687
1689
|
// create the accessory handler for the restored accessory
|
|
1688
1690
|
// this is imported from `platformAccessory.ts`
|
|
1689
1691
|
new StripLight(this, existingAccessory, device);
|
|
1690
|
-
|
|
1692
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1691
1693
|
}
|
|
1692
1694
|
else {
|
|
1693
1695
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1713,13 +1715,13 @@ export class SwitchBotPlatform {
|
|
|
1713
1715
|
// create the accessory handler for the newly create accessory
|
|
1714
1716
|
// this is imported from `platformAccessory.ts`
|
|
1715
1717
|
new StripLight(this, accessory, device);
|
|
1716
|
-
|
|
1718
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1717
1719
|
// publish device externally or link the accessory to your platform
|
|
1718
1720
|
this.externalOrPlatform(device, accessory);
|
|
1719
1721
|
this.accessories.push(accessory);
|
|
1720
1722
|
}
|
|
1721
1723
|
else {
|
|
1722
|
-
|
|
1724
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1723
1725
|
}
|
|
1724
1726
|
}
|
|
1725
1727
|
async createFan(device) {
|
|
@@ -1744,7 +1746,7 @@ export class SwitchBotPlatform {
|
|
|
1744
1746
|
// create the accessory handler for the restored accessory
|
|
1745
1747
|
// this is imported from `platformAccessory.ts`
|
|
1746
1748
|
new Fan(this, existingAccessory, device);
|
|
1747
|
-
|
|
1749
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1748
1750
|
}
|
|
1749
1751
|
else {
|
|
1750
1752
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1770,13 +1772,13 @@ export class SwitchBotPlatform {
|
|
|
1770
1772
|
// create the accessory handler for the newly create accessory
|
|
1771
1773
|
// this is imported from `platformAccessory.ts`
|
|
1772
1774
|
new Fan(this, accessory, device);
|
|
1773
|
-
|
|
1775
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1774
1776
|
// publish device externally or link the accessory to your platform
|
|
1775
1777
|
this.externalOrPlatform(device, accessory);
|
|
1776
1778
|
this.accessories.push(accessory);
|
|
1777
1779
|
}
|
|
1778
1780
|
else {
|
|
1779
|
-
|
|
1781
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1780
1782
|
}
|
|
1781
1783
|
}
|
|
1782
1784
|
async createRobotVacuumCleaner(device) {
|
|
@@ -1801,7 +1803,7 @@ export class SwitchBotPlatform {
|
|
|
1801
1803
|
// create the accessory handler for the restored accessory
|
|
1802
1804
|
// this is imported from `platformAccessory.ts`
|
|
1803
1805
|
new RobotVacuumCleaner(this, existingAccessory, device);
|
|
1804
|
-
|
|
1806
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1805
1807
|
}
|
|
1806
1808
|
else {
|
|
1807
1809
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1827,13 +1829,13 @@ export class SwitchBotPlatform {
|
|
|
1827
1829
|
// create the accessory handler for the newly create accessory
|
|
1828
1830
|
// this is imported from `platformAccessory.ts`
|
|
1829
1831
|
new RobotVacuumCleaner(this, accessory, device);
|
|
1830
|
-
|
|
1832
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1831
1833
|
// publish device externally or link the accessory to your platform
|
|
1832
1834
|
this.externalOrPlatform(device, accessory);
|
|
1833
1835
|
this.accessories.push(accessory);
|
|
1834
1836
|
}
|
|
1835
1837
|
else {
|
|
1836
|
-
|
|
1838
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1837
1839
|
}
|
|
1838
1840
|
}
|
|
1839
1841
|
async createTV(device) {
|
|
@@ -1853,7 +1855,7 @@ export class SwitchBotPlatform {
|
|
|
1853
1855
|
// create the accessory handler for the restored accessory
|
|
1854
1856
|
// this is imported from `platformAccessory.ts`
|
|
1855
1857
|
new TV(this, existingAccessory, device);
|
|
1856
|
-
|
|
1858
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1857
1859
|
}
|
|
1858
1860
|
else if (!device.hide_device && device.hubDeviceId) {
|
|
1859
1861
|
// the accessory does not yet exist, so we need to create it
|
|
@@ -1875,12 +1877,12 @@ export class SwitchBotPlatform {
|
|
|
1875
1877
|
// create the accessory handler for the newly create accessory
|
|
1876
1878
|
// this is imported from `platformAccessory.ts`
|
|
1877
1879
|
new TV(this, accessory, device);
|
|
1878
|
-
|
|
1880
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1879
1881
|
this.externalOrPlatformIR(device, accessory);
|
|
1880
1882
|
this.accessories.push(accessory);
|
|
1881
1883
|
}
|
|
1882
1884
|
else {
|
|
1883
|
-
|
|
1885
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1884
1886
|
}
|
|
1885
1887
|
}
|
|
1886
1888
|
async createIRFan(device) {
|
|
@@ -1905,7 +1907,7 @@ export class SwitchBotPlatform {
|
|
|
1905
1907
|
// create the accessory handler for the restored accessory
|
|
1906
1908
|
// this is imported from `platformAccessory.ts`
|
|
1907
1909
|
new IRFan(this, existingAccessory, device);
|
|
1908
|
-
|
|
1910
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1909
1911
|
}
|
|
1910
1912
|
else {
|
|
1911
1913
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1931,13 +1933,13 @@ export class SwitchBotPlatform {
|
|
|
1931
1933
|
// create the accessory handler for the newly create accessory
|
|
1932
1934
|
// this is imported from `platformAccessory.ts`
|
|
1933
1935
|
new IRFan(this, accessory, device);
|
|
1934
|
-
|
|
1936
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1935
1937
|
// publish device externally or link the accessory to your platform
|
|
1936
1938
|
this.externalOrPlatformIR(device, accessory);
|
|
1937
1939
|
this.accessories.push(accessory);
|
|
1938
1940
|
}
|
|
1939
1941
|
else {
|
|
1940
|
-
|
|
1942
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1941
1943
|
}
|
|
1942
1944
|
}
|
|
1943
1945
|
async createLight(device) {
|
|
@@ -1962,7 +1964,7 @@ export class SwitchBotPlatform {
|
|
|
1962
1964
|
// create the accessory handler for the restored accessory
|
|
1963
1965
|
// this is imported from `platformAccessory.ts`
|
|
1964
1966
|
new Light(this, existingAccessory, device);
|
|
1965
|
-
|
|
1967
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1966
1968
|
}
|
|
1967
1969
|
else {
|
|
1968
1970
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -1988,13 +1990,13 @@ export class SwitchBotPlatform {
|
|
|
1988
1990
|
// create the accessory handler for the newly create accessory
|
|
1989
1991
|
// this is imported from `platformAccessory.ts`
|
|
1990
1992
|
new Light(this, accessory, device);
|
|
1991
|
-
|
|
1993
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1992
1994
|
// publish device externally or link the accessory to your platform
|
|
1993
1995
|
this.externalOrPlatformIR(device, accessory);
|
|
1994
1996
|
this.accessories.push(accessory);
|
|
1995
1997
|
}
|
|
1996
1998
|
else {
|
|
1997
|
-
|
|
1999
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1998
2000
|
}
|
|
1999
2001
|
}
|
|
2000
2002
|
async createAirConditioner(device) {
|
|
@@ -2019,7 +2021,7 @@ export class SwitchBotPlatform {
|
|
|
2019
2021
|
// create the accessory handler for the restored accessory
|
|
2020
2022
|
// this is imported from `platformAccessory.ts`
|
|
2021
2023
|
new AirConditioner(this, existingAccessory, device);
|
|
2022
|
-
|
|
2024
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2023
2025
|
}
|
|
2024
2026
|
else {
|
|
2025
2027
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -2045,13 +2047,13 @@ export class SwitchBotPlatform {
|
|
|
2045
2047
|
// create the accessory handler for the newly create accessory
|
|
2046
2048
|
// this is imported from `platformAccessory.ts`
|
|
2047
2049
|
new AirConditioner(this, accessory, device);
|
|
2048
|
-
|
|
2050
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2049
2051
|
// publish device externally or link the accessory to your platform
|
|
2050
2052
|
this.externalOrPlatformIR(device, accessory);
|
|
2051
2053
|
this.accessories.push(accessory);
|
|
2052
2054
|
}
|
|
2053
2055
|
else {
|
|
2054
|
-
|
|
2056
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2055
2057
|
}
|
|
2056
2058
|
}
|
|
2057
2059
|
async createAirPurifier(device) {
|
|
@@ -2076,7 +2078,7 @@ export class SwitchBotPlatform {
|
|
|
2076
2078
|
// create the accessory handler for the restored accessory
|
|
2077
2079
|
// this is imported from `platformAccessory.ts`
|
|
2078
2080
|
new AirPurifier(this, existingAccessory, device);
|
|
2079
|
-
|
|
2081
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2080
2082
|
}
|
|
2081
2083
|
else {
|
|
2082
2084
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -2102,13 +2104,13 @@ export class SwitchBotPlatform {
|
|
|
2102
2104
|
// create the accessory handler for the newly create accessory
|
|
2103
2105
|
// this is imported from `platformAccessory.ts`
|
|
2104
2106
|
new AirPurifier(this, accessory, device);
|
|
2105
|
-
|
|
2107
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2106
2108
|
// publish device externally or link the accessory to your platform
|
|
2107
2109
|
this.externalOrPlatformIR(device, accessory);
|
|
2108
2110
|
this.accessories.push(accessory);
|
|
2109
2111
|
}
|
|
2110
2112
|
else {
|
|
2111
|
-
|
|
2113
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2112
2114
|
}
|
|
2113
2115
|
}
|
|
2114
2116
|
async createWaterHeater(device) {
|
|
@@ -2133,7 +2135,7 @@ export class SwitchBotPlatform {
|
|
|
2133
2135
|
// create the accessory handler for the restored accessory
|
|
2134
2136
|
// this is imported from `platformAccessory.ts`
|
|
2135
2137
|
new WaterHeater(this, existingAccessory, device);
|
|
2136
|
-
|
|
2138
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2137
2139
|
}
|
|
2138
2140
|
else {
|
|
2139
2141
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -2159,13 +2161,13 @@ export class SwitchBotPlatform {
|
|
|
2159
2161
|
// create the accessory handler for the newly create accessory
|
|
2160
2162
|
// this is imported from `platformAccessory.ts`
|
|
2161
2163
|
new WaterHeater(this, accessory, device);
|
|
2162
|
-
|
|
2164
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2163
2165
|
// publish device externally or link the accessory to your platform
|
|
2164
2166
|
this.externalOrPlatformIR(device, accessory);
|
|
2165
2167
|
this.accessories.push(accessory);
|
|
2166
2168
|
}
|
|
2167
2169
|
else {
|
|
2168
|
-
|
|
2170
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2169
2171
|
}
|
|
2170
2172
|
}
|
|
2171
2173
|
async createVacuumCleaner(device) {
|
|
@@ -2190,7 +2192,7 @@ export class SwitchBotPlatform {
|
|
|
2190
2192
|
// create the accessory handler for the restored accessory
|
|
2191
2193
|
// this is imported from `platformAccessory.ts`
|
|
2192
2194
|
new VacuumCleaner(this, existingAccessory, device);
|
|
2193
|
-
|
|
2195
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2194
2196
|
}
|
|
2195
2197
|
else {
|
|
2196
2198
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -2216,13 +2218,13 @@ export class SwitchBotPlatform {
|
|
|
2216
2218
|
// create the accessory handler for the newly create accessory
|
|
2217
2219
|
// this is imported from `platformAccessory.ts`
|
|
2218
2220
|
new VacuumCleaner(this, accessory, device);
|
|
2219
|
-
|
|
2221
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2220
2222
|
// publish device externally or link the accessory to your platform
|
|
2221
2223
|
this.externalOrPlatformIR(device, accessory);
|
|
2222
2224
|
this.accessories.push(accessory);
|
|
2223
2225
|
}
|
|
2224
2226
|
else {
|
|
2225
|
-
|
|
2227
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2226
2228
|
}
|
|
2227
2229
|
}
|
|
2228
2230
|
async createCamera(device) {
|
|
@@ -2247,7 +2249,7 @@ export class SwitchBotPlatform {
|
|
|
2247
2249
|
// create the accessory handler for the restored accessory
|
|
2248
2250
|
// this is imported from `platformAccessory.ts`
|
|
2249
2251
|
new Camera(this, existingAccessory, device);
|
|
2250
|
-
|
|
2252
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2251
2253
|
}
|
|
2252
2254
|
else {
|
|
2253
2255
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -2273,13 +2275,13 @@ export class SwitchBotPlatform {
|
|
|
2273
2275
|
// create the accessory handler for the newly create accessory
|
|
2274
2276
|
// this is imported from `platformAccessory.ts`
|
|
2275
2277
|
new Camera(this, accessory, device);
|
|
2276
|
-
|
|
2278
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2277
2279
|
// publish device externally or link the accessory to your platform
|
|
2278
2280
|
this.externalOrPlatformIR(device, accessory);
|
|
2279
2281
|
this.accessories.push(accessory);
|
|
2280
2282
|
}
|
|
2281
2283
|
else {
|
|
2282
|
-
|
|
2284
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2283
2285
|
}
|
|
2284
2286
|
}
|
|
2285
2287
|
async createOthers(device) {
|
|
@@ -2304,7 +2306,7 @@ export class SwitchBotPlatform {
|
|
|
2304
2306
|
// create the accessory handler for the restored accessory
|
|
2305
2307
|
// this is imported from `platformAccessory.ts`
|
|
2306
2308
|
new Others(this, existingAccessory, device);
|
|
2307
|
-
|
|
2309
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2308
2310
|
}
|
|
2309
2311
|
else {
|
|
2310
2312
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
@@ -2330,13 +2332,13 @@ export class SwitchBotPlatform {
|
|
|
2330
2332
|
// create the accessory handler for the newly create accessory
|
|
2331
2333
|
// this is imported from `platformAccessory.ts`
|
|
2332
2334
|
new Others(this, accessory, device);
|
|
2333
|
-
|
|
2335
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2334
2336
|
// publish device externally or link the accessory to your platform
|
|
2335
2337
|
this.externalOrPlatformIR(device, accessory);
|
|
2336
2338
|
this.accessories.push(accessory);
|
|
2337
2339
|
}
|
|
2338
2340
|
else {
|
|
2339
|
-
|
|
2341
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2340
2342
|
}
|
|
2341
2343
|
}
|
|
2342
2344
|
async registerCurtains(device) {
|
|
@@ -2349,13 +2351,12 @@ export class SwitchBotPlatform {
|
|
|
2349
2351
|
}*/
|
|
2350
2352
|
let registerWindowCovering;
|
|
2351
2353
|
if (isCurtainDevice(device)) {
|
|
2352
|
-
|
|
2353
|
-
+
|
|
2354
|
-
+ ` connectionType: ${device.connectionType}`);
|
|
2354
|
+
this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds}, master: `
|
|
2355
|
+
+ `${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}, connectionType: ${device.connectionType}`);
|
|
2355
2356
|
registerWindowCovering = await this.registerWindowCovering(device);
|
|
2356
2357
|
}
|
|
2357
2358
|
else if (isBlindTiltDevice(device)) {
|
|
2358
|
-
|
|
2359
|
+
this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, blindTiltDevicesIds: ${device.blindTiltDevicesIds},`
|
|
2359
2360
|
+ ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group},`
|
|
2360
2361
|
+ ` connectionType: ${device.connectionType}`);
|
|
2361
2362
|
registerWindowCovering = await this.registerWindowCovering(device);
|
|
@@ -2366,42 +2367,42 @@ export class SwitchBotPlatform {
|
|
|
2366
2367
|
return registerWindowCovering;
|
|
2367
2368
|
}
|
|
2368
2369
|
async registerWindowCovering(device) {
|
|
2369
|
-
|
|
2370
|
+
this.debugLog(device.master);
|
|
2370
2371
|
let registerCurtain;
|
|
2371
2372
|
if (device.master && device.group) {
|
|
2372
2373
|
// OpenAPI: Master Curtains/Blind Tilt in Group
|
|
2373
2374
|
registerCurtain = true;
|
|
2374
|
-
|
|
2375
|
-
+ `
|
|
2376
|
-
|
|
2375
|
+
this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, device.group: ${device.group}`
|
|
2376
|
+
+ ` connectionType; ${device.connectionType}`);
|
|
2377
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
|
|
2377
2378
|
}
|
|
2378
2379
|
else if (!device.master && device.curtain?.disable_group) {
|
|
2379
2380
|
//!device.group && device.connectionType === 'BLE'
|
|
2380
2381
|
// OpenAPI: Non-Master Curtains/Blind Tilts that has Disable Grouping Checked
|
|
2381
2382
|
registerCurtain = true;
|
|
2382
|
-
|
|
2383
|
+
this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, disable_group: `
|
|
2383
2384
|
+ `${device.curtain?.disable_group}, connectionType; ${device.connectionType}`);
|
|
2384
|
-
|
|
2385
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
|
|
2385
2386
|
}
|
|
2386
2387
|
else if (device.master && !device.group) {
|
|
2387
2388
|
// OpenAPI: Master Curtains/Blind Tilts not in Group
|
|
2388
2389
|
registerCurtain = true;
|
|
2389
|
-
|
|
2390
|
-
+ `
|
|
2391
|
-
|
|
2390
|
+
this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, device.group: ${device.group}`
|
|
2391
|
+
+ ` connectionType; ${device.connectionType}`);
|
|
2392
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
|
|
2392
2393
|
}
|
|
2393
2394
|
else if (device.connectionType === 'BLE') {
|
|
2394
2395
|
// BLE: Curtains/Blind Tilt
|
|
2395
2396
|
registerCurtain = true;
|
|
2396
|
-
|
|
2397
|
+
this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] connectionType: ${device.connectionType}, `
|
|
2397
2398
|
+ ` group: ${device.group}`);
|
|
2398
|
-
|
|
2399
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
|
|
2399
2400
|
}
|
|
2400
2401
|
else {
|
|
2401
2402
|
registerCurtain = false;
|
|
2402
|
-
|
|
2403
|
+
this.debugErrorLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] disable_group: ${device.curtain?.disable_group},`
|
|
2403
2404
|
+ ` device.master: ${device.master}, device.group: ${device.group}`);
|
|
2404
|
-
|
|
2405
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}, device.connectionType: ${device.connectionType}`);
|
|
2405
2406
|
}
|
|
2406
2407
|
return registerCurtain;
|
|
2407
2408
|
}
|
|
@@ -2424,17 +2425,17 @@ export class SwitchBotPlatform {
|
|
|
2424
2425
|
case 'Curtain3':
|
|
2425
2426
|
case 'Blind Tilt':
|
|
2426
2427
|
registerDevice = await this.registerCurtains(device);
|
|
2427
|
-
|
|
2428
|
+
this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
|
|
2428
2429
|
break;
|
|
2429
2430
|
default:
|
|
2430
2431
|
registerDevice = true;
|
|
2431
|
-
|
|
2432
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2432
2433
|
}
|
|
2433
2434
|
if (registerDevice === true) {
|
|
2434
|
-
|
|
2435
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
|
|
2435
2436
|
}
|
|
2436
2437
|
else {
|
|
2437
|
-
|
|
2438
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2438
2439
|
}
|
|
2439
2440
|
}
|
|
2440
2441
|
else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName && device.connectionType === 'BLE') {
|
|
@@ -2443,17 +2444,17 @@ export class SwitchBotPlatform {
|
|
|
2443
2444
|
case 'Curtain3':
|
|
2444
2445
|
case 'Blind Tilt':
|
|
2445
2446
|
registerDevice = await this.registerCurtains(device);
|
|
2446
|
-
|
|
2447
|
+
this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
|
|
2447
2448
|
break;
|
|
2448
2449
|
default:
|
|
2449
2450
|
registerDevice = true;
|
|
2450
|
-
|
|
2451
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2451
2452
|
}
|
|
2452
2453
|
if (registerDevice === true) {
|
|
2453
|
-
|
|
2454
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
|
|
2454
2455
|
}
|
|
2455
2456
|
else {
|
|
2456
|
-
|
|
2457
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2457
2458
|
}
|
|
2458
2459
|
}
|
|
2459
2460
|
else if (!device.hide_device && device.connectionType === 'OpenAPI') {
|
|
@@ -2462,17 +2463,17 @@ export class SwitchBotPlatform {
|
|
|
2462
2463
|
case 'Curtain3':
|
|
2463
2464
|
case 'Blind Tilt':
|
|
2464
2465
|
registerDevice = await this.registerCurtains(device);
|
|
2465
|
-
|
|
2466
|
+
this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
|
|
2466
2467
|
break;
|
|
2467
2468
|
default:
|
|
2468
2469
|
registerDevice = true;
|
|
2469
|
-
|
|
2470
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2470
2471
|
}
|
|
2471
2472
|
if (registerDevice === true) {
|
|
2472
|
-
|
|
2473
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
|
|
2473
2474
|
}
|
|
2474
2475
|
else {
|
|
2475
|
-
|
|
2476
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2476
2477
|
}
|
|
2477
2478
|
}
|
|
2478
2479
|
else if (!device.hide_device && device.connectionType === 'Disabled') {
|
|
@@ -2481,25 +2482,25 @@ export class SwitchBotPlatform {
|
|
|
2481
2482
|
case 'Curtain3':
|
|
2482
2483
|
case 'Blind Tilt':
|
|
2483
2484
|
registerDevice = await this.registerCurtains(device);
|
|
2484
|
-
|
|
2485
|
+
this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
|
|
2485
2486
|
break;
|
|
2486
2487
|
default:
|
|
2487
2488
|
registerDevice = true;
|
|
2488
|
-
|
|
2489
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2489
2490
|
}
|
|
2490
|
-
|
|
2491
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will continue to display in HomeKit`);
|
|
2491
2492
|
}
|
|
2492
2493
|
else if (!device.connectionType && !device.hide_device) {
|
|
2493
2494
|
registerDevice = false;
|
|
2494
|
-
|
|
2495
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2495
2496
|
}
|
|
2496
2497
|
else if (device.hide_device) {
|
|
2497
2498
|
registerDevice = false;
|
|
2498
|
-
|
|
2499
|
+
this.debugErrorLog(`Device: ${device.deviceName} hide_device: ${device.hide_device}, will not display in HomeKit`);
|
|
2499
2500
|
}
|
|
2500
2501
|
else {
|
|
2501
2502
|
registerDevice = false;
|
|
2502
|
-
|
|
2503
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, hide_device: `
|
|
2503
2504
|
+ `${device.hide_device}, will not display in HomeKit`);
|
|
2504
2505
|
}
|
|
2505
2506
|
return registerDevice;
|
|
@@ -2511,21 +2512,21 @@ export class SwitchBotPlatform {
|
|
|
2511
2512
|
* publish your TV as an external accessory.
|
|
2512
2513
|
*/
|
|
2513
2514
|
if (device.external) {
|
|
2514
|
-
|
|
2515
|
+
this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
|
|
2515
2516
|
this.externalAccessory(accessory);
|
|
2516
2517
|
}
|
|
2517
2518
|
else {
|
|
2518
|
-
|
|
2519
|
+
this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
|
|
2519
2520
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
2520
2521
|
}
|
|
2521
2522
|
}
|
|
2522
2523
|
async externalOrPlatform(device, accessory) {
|
|
2523
2524
|
if (device.external) {
|
|
2524
|
-
|
|
2525
|
-
|
|
2525
|
+
this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
|
|
2526
|
+
this.externalAccessory(accessory);
|
|
2526
2527
|
}
|
|
2527
2528
|
else {
|
|
2528
|
-
|
|
2529
|
+
this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
|
|
2529
2530
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
2530
2531
|
}
|
|
2531
2532
|
}
|
|
@@ -2540,67 +2541,67 @@ export class SwitchBotPlatform {
|
|
|
2540
2541
|
async statusCode(statusCode) {
|
|
2541
2542
|
switch (statusCode) {
|
|
2542
2543
|
case 151:
|
|
2543
|
-
|
|
2544
|
+
this.errorLog(`Command not supported by this device type, statusCode: ${statusCode}, Submit Feature Request Here: ` +
|
|
2544
2545
|
'https://tinyurl.com/SwitchBotFeatureRequest');
|
|
2545
2546
|
break;
|
|
2546
2547
|
case 152:
|
|
2547
|
-
|
|
2548
|
+
this.errorLog(`Device not found, statusCode: ${statusCode}`);
|
|
2548
2549
|
break;
|
|
2549
2550
|
case 160:
|
|
2550
|
-
|
|
2551
|
+
this.errorLog(`Command is not supported, statusCode: ${statusCode}, Submit Bugs Here: https://tinyurl.com/SwitchBotBug`);
|
|
2551
2552
|
break;
|
|
2552
2553
|
case 161:
|
|
2553
|
-
|
|
2554
|
+
this.errorLog(`Device is offline, statusCode: ${statusCode}`);
|
|
2554
2555
|
break;
|
|
2555
2556
|
case 171:
|
|
2556
|
-
|
|
2557
|
+
this.errorLog(`is offline, statusCode: ${statusCode}`);
|
|
2557
2558
|
break;
|
|
2558
2559
|
case 190:
|
|
2559
|
-
|
|
2560
|
+
this.errorLog(`Requests reached the daily limit, statusCode: ${statusCode}`);
|
|
2560
2561
|
break;
|
|
2561
2562
|
case 100:
|
|
2562
|
-
|
|
2563
|
+
this.debugLog(`Command successfully sent, statusCode: ${statusCode}`);
|
|
2563
2564
|
break;
|
|
2564
2565
|
case 200:
|
|
2565
|
-
|
|
2566
|
+
this.debugLog(`Request successful, statusCode: ${statusCode}`);
|
|
2566
2567
|
break;
|
|
2567
2568
|
case 400:
|
|
2568
|
-
|
|
2569
|
+
this.errorLog('Bad Request, The client has issued an invalid request. This is commonly used to specify validation errors in a request '
|
|
2569
2570
|
+ `payload, statusCode: ${statusCode}`);
|
|
2570
2571
|
break;
|
|
2571
2572
|
case 401:
|
|
2572
|
-
|
|
2573
|
+
this.errorLog('Unauthorized, Authorization for the API is required, but the request has not been authenticated, '
|
|
2573
2574
|
+ `statusCode: ${statusCode}`);
|
|
2574
2575
|
break;
|
|
2575
2576
|
case 403:
|
|
2576
|
-
|
|
2577
|
+
this.errorLog('Forbidden, The request has been authenticated but does not have appropriate permissions, or a requested resource is not '
|
|
2577
2578
|
+ `found, statusCode: ${statusCode}`);
|
|
2578
2579
|
break;
|
|
2579
2580
|
case 404:
|
|
2580
|
-
|
|
2581
|
+
this.errorLog(`Not Found, Specifies the requested path does not exist, statusCode: ${statusCode}`);
|
|
2581
2582
|
break;
|
|
2582
2583
|
case 406:
|
|
2583
|
-
|
|
2584
|
+
this.errorLog('Not Acceptable, The client has requested a MIME type via the Accept header for a value not supported by the server, '
|
|
2584
2585
|
+ `statusCode: ${statusCode}`);
|
|
2585
2586
|
break;
|
|
2586
2587
|
case 415:
|
|
2587
|
-
|
|
2588
|
+
this.errorLog('Unsupported Media Type, The client has defined a contentType header that is not supported by the server, '
|
|
2588
2589
|
+ `statusCode: ${statusCode}`);
|
|
2589
2590
|
break;
|
|
2590
2591
|
case 422:
|
|
2591
|
-
|
|
2592
|
+
this.errorLog('Unprocessable Entity, The client has made a valid request, but the server cannot process it. This is often used for '
|
|
2592
2593
|
+ `APIs for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
2593
2594
|
break;
|
|
2594
2595
|
case 429:
|
|
2595
|
-
|
|
2596
|
+
this.errorLog('Too Many Requests, The client has exceeded the number of requests allowed for a given time window, '
|
|
2596
2597
|
+ `statusCode: ${statusCode}`);
|
|
2597
2598
|
break;
|
|
2598
2599
|
case 500:
|
|
2599
|
-
|
|
2600
|
+
this.errorLog('Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare, '
|
|
2600
2601
|
+ `statusCode: ${statusCode}`);
|
|
2601
2602
|
break;
|
|
2602
2603
|
default:
|
|
2603
|
-
|
|
2604
|
+
this.errorLog(`Unknown statusCode, statusCode: ${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
|
|
2604
2605
|
}
|
|
2605
2606
|
}
|
|
2606
2607
|
async retryRequest(deviceMaxRetries, deviceDelayBetweenRetries, url, options) {
|
|
@@ -2614,14 +2615,14 @@ export class SwitchBotPlatform {
|
|
|
2614
2615
|
return { body, statusCode };
|
|
2615
2616
|
}
|
|
2616
2617
|
else {
|
|
2617
|
-
|
|
2618
|
+
this.debugLog(`Received status code: ${statusCode}`);
|
|
2618
2619
|
}
|
|
2619
2620
|
}
|
|
2620
2621
|
catch (error) {
|
|
2621
|
-
|
|
2622
|
+
this.errorLog(`Error making request: ${error.message}`);
|
|
2622
2623
|
}
|
|
2623
2624
|
retryCount++;
|
|
2624
|
-
|
|
2625
|
+
this.debugLog(`Retry attempt ${retryCount} of ${maxRetries}`);
|
|
2625
2626
|
await sleep(delayBetweenRetries);
|
|
2626
2627
|
}
|
|
2627
2628
|
return { body: null, statusCode: -1 };
|
|
@@ -2632,17 +2633,16 @@ export class SwitchBotPlatform {
|
|
|
2632
2633
|
try {
|
|
2633
2634
|
const SwitchBot = (await import('node-switchbot')).SwitchBot;
|
|
2634
2635
|
queueScheduler.schedule(() => (switchbot = new SwitchBot()));
|
|
2635
|
-
await await this.debugLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}`);
|
|
2636
2636
|
}
|
|
2637
2637
|
catch (e) {
|
|
2638
2638
|
switchbot = false;
|
|
2639
|
-
|
|
2639
|
+
this.errorLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}, Error: ${e}`);
|
|
2640
2640
|
}
|
|
2641
2641
|
return switchbot;
|
|
2642
2642
|
}
|
|
2643
2643
|
async getVersion() {
|
|
2644
2644
|
const json = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
|
|
2645
|
-
|
|
2645
|
+
this.debugLog(`Plugin Version: ${json.version}`);
|
|
2646
2646
|
this.version = json.version;
|
|
2647
2647
|
}
|
|
2648
2648
|
async getPlatformConfigSettings() {
|
|
@@ -2679,7 +2679,7 @@ export class SwitchBotPlatform {
|
|
|
2679
2679
|
platformConfig.delayBetweenRetries = this.delayBetweenRetries / 1000;
|
|
2680
2680
|
}
|
|
2681
2681
|
if (Object.entries(platformConfig).length !== 0) {
|
|
2682
|
-
|
|
2682
|
+
this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
|
|
2683
2683
|
}
|
|
2684
2684
|
this.platformConfig = platformConfig;
|
|
2685
2685
|
}
|
|
@@ -2688,64 +2688,64 @@ export class SwitchBotPlatform {
|
|
|
2688
2688
|
this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
|
|
2689
2689
|
if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
|
|
2690
2690
|
this.platformLogging = this.config.options.logging;
|
|
2691
|
-
|
|
2691
|
+
this.debugWarnLog(`Using Config Logging: ${this.platformLogging}`);
|
|
2692
2692
|
}
|
|
2693
2693
|
else if (this.debugMode) {
|
|
2694
2694
|
this.platformLogging = 'debugMode';
|
|
2695
|
-
|
|
2695
|
+
this.debugWarnLog(`Using ${this.platformLogging} Logging`);
|
|
2696
2696
|
}
|
|
2697
2697
|
else {
|
|
2698
2698
|
this.platformLogging = 'standard';
|
|
2699
|
-
|
|
2699
|
+
this.debugWarnLog(`Using ${this.platformLogging} Logging`);
|
|
2700
2700
|
}
|
|
2701
2701
|
}
|
|
2702
2702
|
/**
|
|
2703
2703
|
* If device level logging is turned on, log to log.warn
|
|
2704
2704
|
* Otherwise send debug logs to log.debug
|
|
2705
2705
|
*/
|
|
2706
|
-
|
|
2707
|
-
if (
|
|
2706
|
+
infoLog(...log) {
|
|
2707
|
+
if (this.enablingPlatformLogging()) {
|
|
2708
2708
|
this.log.info(String(...log));
|
|
2709
2709
|
}
|
|
2710
2710
|
}
|
|
2711
|
-
|
|
2712
|
-
if (
|
|
2711
|
+
successLog(...log) {
|
|
2712
|
+
if (this.enablingPlatformLogging()) {
|
|
2713
2713
|
this.log.success(String(...log));
|
|
2714
2714
|
}
|
|
2715
2715
|
}
|
|
2716
|
-
|
|
2717
|
-
if (
|
|
2716
|
+
debugSuccessLog(...log) {
|
|
2717
|
+
if (this.enablingPlatformLogging()) {
|
|
2718
2718
|
if (this.platformLogging?.includes('debug')) {
|
|
2719
2719
|
this.log.success('[DEBUG]', String(...log));
|
|
2720
2720
|
}
|
|
2721
2721
|
}
|
|
2722
2722
|
}
|
|
2723
|
-
|
|
2724
|
-
if (
|
|
2723
|
+
warnLog(...log) {
|
|
2724
|
+
if (this.enablingPlatformLogging()) {
|
|
2725
2725
|
this.log.warn(String(...log));
|
|
2726
2726
|
}
|
|
2727
2727
|
}
|
|
2728
|
-
|
|
2729
|
-
if (
|
|
2728
|
+
debugWarnLog(...log) {
|
|
2729
|
+
if (this.enablingPlatformLogging()) {
|
|
2730
2730
|
if (this.platformLogging?.includes('debug')) {
|
|
2731
2731
|
this.log.warn('[DEBUG]', String(...log));
|
|
2732
2732
|
}
|
|
2733
2733
|
}
|
|
2734
2734
|
}
|
|
2735
|
-
|
|
2736
|
-
if (
|
|
2735
|
+
errorLog(...log) {
|
|
2736
|
+
if (this.enablingPlatformLogging()) {
|
|
2737
2737
|
this.log.error(String(...log));
|
|
2738
2738
|
}
|
|
2739
2739
|
}
|
|
2740
|
-
|
|
2741
|
-
if (
|
|
2740
|
+
debugErrorLog(...log) {
|
|
2741
|
+
if (this.enablingPlatformLogging()) {
|
|
2742
2742
|
if (this.platformLogging?.includes('debug')) {
|
|
2743
2743
|
this.log.error('[DEBUG]', String(...log));
|
|
2744
2744
|
}
|
|
2745
2745
|
}
|
|
2746
2746
|
}
|
|
2747
|
-
|
|
2748
|
-
if (
|
|
2747
|
+
debugLog(...log) {
|
|
2748
|
+
if (this.enablingPlatformLogging()) {
|
|
2749
2749
|
if (this.platformLogging === 'debugMode') {
|
|
2750
2750
|
this.log.debug(String(...log));
|
|
2751
2751
|
}
|
|
@@ -2754,7 +2754,7 @@ export class SwitchBotPlatform {
|
|
|
2754
2754
|
}
|
|
2755
2755
|
}
|
|
2756
2756
|
}
|
|
2757
|
-
|
|
2757
|
+
enablingPlatformLogging() {
|
|
2758
2758
|
return this.platformLogging?.includes('debug') || this.platformLogging === 'standard';
|
|
2759
2759
|
}
|
|
2760
2760
|
}
|