@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/src/platform.ts
CHANGED
|
@@ -34,23 +34,23 @@ import { AirConditioner } from './irdevice/airconditioner.js';
|
|
|
34
34
|
import { Buffer } from 'buffer';
|
|
35
35
|
import { request } from 'undici';
|
|
36
36
|
import asyncmqtt from 'async-mqtt';
|
|
37
|
+
import { isBlindTiltDevice, isCurtainDevice, sleep } from './utils.js';
|
|
37
38
|
import { createServer } from 'http';
|
|
38
39
|
import { queueScheduler } from 'rxjs';
|
|
39
40
|
import fakegato from 'fakegato-history';
|
|
40
41
|
import crypto, { randomUUID } from 'crypto';
|
|
41
42
|
import { readFileSync, writeFileSync } from 'fs';
|
|
42
43
|
import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
|
|
43
|
-
import { isBlindTiltDevice, isCurtainDevice, sleep } from './utils.js';
|
|
44
44
|
import { PLATFORM_NAME, PLUGIN_NAME, Devices, setupWebhook, updateWebhook, deleteWebhook, queryWebhook } from './settings.js';
|
|
45
45
|
|
|
46
46
|
import type { UrlObject } from 'url';
|
|
47
47
|
import type { MqttClient } from 'mqtt';
|
|
48
48
|
import type { Dispatcher } from 'undici';
|
|
49
|
-
import type { irdevice } from './types/irdevicelist.js';
|
|
50
49
|
import type { Server, IncomingMessage, ServerResponse } from 'http';
|
|
51
|
-
import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js';
|
|
52
50
|
import type { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
|
|
53
51
|
import type { SwitchBotPlatformConfig, devicesConfig, irDevicesConfig } from './settings.js';
|
|
52
|
+
import type { irdevice } from './types/irdevicelist.js';
|
|
53
|
+
import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js';
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* HomebridgePlatform
|
|
@@ -76,7 +76,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
76
76
|
|
|
77
77
|
public readonly fakegatoAPI: any;
|
|
78
78
|
public readonly eve: any;
|
|
79
|
-
public readonly webhookEventHandler
|
|
79
|
+
public readonly webhookEventHandler;
|
|
80
80
|
|
|
81
81
|
constructor(
|
|
82
82
|
log: Logging,
|
|
@@ -141,7 +141,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
141
141
|
}
|
|
142
142
|
} catch (e: any) {
|
|
143
143
|
this.errorLog(`Failed to Discover, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
144
|
-
|
|
144
|
+
this.debugErrorLog(`Failed to Discover, Error: ${e}`);
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
147
|
|
|
@@ -154,27 +154,27 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
154
154
|
try {
|
|
155
155
|
const { connectAsync } = asyncmqtt;
|
|
156
156
|
this.mqttClient = await connectAsync(this.config.options?.mqttURL, this.config.options.mqttOptions || {});
|
|
157
|
-
|
|
158
|
-
this.mqttClient.on('error',
|
|
159
|
-
|
|
157
|
+
this.debugLog('MQTT connection has been established successfully.');
|
|
158
|
+
this.mqttClient.on('error', (e: Error) => {
|
|
159
|
+
this.errorLog(`Failed to publish MQTT messages. ${e}`);
|
|
160
160
|
});
|
|
161
161
|
if (!this.config.options?.webhookURL) {
|
|
162
162
|
// receive webhook events via MQTT
|
|
163
|
-
|
|
163
|
+
this.infoLog(`Webhook is configured to be received through ${this.config.options.mqttURL}/homebridge-switchbot/webhook.`);
|
|
164
164
|
this.mqttClient.subscribe('homebridge-switchbot/webhook/+');
|
|
165
165
|
this.mqttClient.on('message', async (topic: string, message) => {
|
|
166
166
|
try {
|
|
167
|
-
|
|
167
|
+
this.debugLog(`Received Webhook via MQTT: ${topic}=${message}`);
|
|
168
168
|
const context = JSON.parse(message.toString());
|
|
169
169
|
this.webhookEventHandler[context.deviceMac]?.(context);
|
|
170
170
|
} catch (e: any) {
|
|
171
|
-
|
|
171
|
+
this.errorLog(`Failed to handle webhook event. Error:${e}`);
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
} catch (e) {
|
|
176
176
|
this.mqttClient = null;
|
|
177
|
-
|
|
177
|
+
this.errorLog(`Failed to establish MQTT connection. ${e}`);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
}
|
|
@@ -194,7 +194,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
194
194
|
request.on('data', async (data) => {
|
|
195
195
|
try {
|
|
196
196
|
const body = JSON.parse(data);
|
|
197
|
-
|
|
197
|
+
this.debugLog(`Received Webhook: ${JSON.stringify(body)}`);
|
|
198
198
|
if (this.config.options?.mqttURL) {
|
|
199
199
|
const mac = body.context.deviceMac
|
|
200
200
|
?.toLowerCase()
|
|
@@ -235,9 +235,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
235
235
|
}),
|
|
236
236
|
});
|
|
237
237
|
const response: any = await body.json();
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
this.debugLog(`setupWebhook: url:${url}`);
|
|
239
|
+
this.debugLog(`setupWebhook: body:${JSON.stringify(response)}`);
|
|
240
|
+
this.debugLog(`setupWebhook: statusCode:${statusCode}`);
|
|
241
241
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
242
242
|
this.errorLog(`Failed to configure webhook. Existing webhook well be overridden. HTTP:${statusCode} API:${response?.statusCode} `
|
|
243
243
|
+ `message:${response?.message}`);
|
|
@@ -257,9 +257,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
257
257
|
}),
|
|
258
258
|
});
|
|
259
259
|
const response: any = await body.json();
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
this.debugLog(`updateWebhook: url:${url}`);
|
|
261
|
+
this.debugLog(`updateWebhook: body:${JSON.stringify(response)}`);
|
|
262
|
+
this.debugLog(`updateWebhook: statusCode:${statusCode}`);
|
|
263
263
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
264
264
|
this.errorLog(`Failed to update webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
265
265
|
}
|
|
@@ -276,8 +276,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
276
276
|
}),
|
|
277
277
|
});
|
|
278
278
|
const response: any = await body.json();
|
|
279
|
-
|
|
280
|
-
|
|
279
|
+
this.debugLog(`queryWebhook: body:${JSON.stringify(response)}`);
|
|
280
|
+
this.debugLog(`queryWebhook: statusCode:${statusCode}`);
|
|
281
281
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
282
282
|
this.errorLog(`Failed to query webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
283
283
|
} else {
|
|
@@ -298,7 +298,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
298
298
|
}),
|
|
299
299
|
});
|
|
300
300
|
const response: any = await body.json();
|
|
301
|
-
|
|
301
|
+
this.debugLog(`deleteWebhook: url:${url}`);
|
|
302
|
+
this.debugLog(`deleteWebhook: body:${JSON.stringify(response)}`);
|
|
303
|
+
this.debugLog(`deleteWebhook: statusCode:${statusCode}`);
|
|
302
304
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
303
305
|
this.errorLog(`Failed to delete webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
304
306
|
} else {
|
|
@@ -315,8 +317,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
315
317
|
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
|
316
318
|
* It should be used to setup event handlers for characteristics and update respective values.
|
|
317
319
|
*/
|
|
318
|
-
|
|
319
|
-
|
|
320
|
+
configureAccessory(accessory: PlatformAccessory) {
|
|
321
|
+
this.debugLog(`Loading accessory from cache: ${accessory.displayName}`);
|
|
320
322
|
|
|
321
323
|
// add the restored accessory to the accessories cache so we can track if it has already been registered
|
|
322
324
|
this.accessories.push(accessory);
|
|
@@ -341,7 +343,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
341
343
|
platformConfig['pushRate'] = this.config.options.pushRate;
|
|
342
344
|
}
|
|
343
345
|
if (Object.entries(platformConfig).length !== 0) {
|
|
344
|
-
|
|
346
|
+
this.debugWarnLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
|
|
345
347
|
}
|
|
346
348
|
|
|
347
349
|
if (this.config.options) {
|
|
@@ -468,7 +470,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
468
470
|
pluginConfig.credentials.openToken = undefined;
|
|
469
471
|
}
|
|
470
472
|
|
|
471
|
-
|
|
473
|
+
this.debugWarnLog(`token: ${pluginConfig.credentials.token}`);
|
|
472
474
|
|
|
473
475
|
// save the config, ensuring we maintain pretty json
|
|
474
476
|
writeFileSync(this.api.user.configPath(), JSON.stringify(currentConfig, null, 4));
|
|
@@ -511,29 +513,29 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
511
513
|
let retryCount = 0;
|
|
512
514
|
const maxRetries = this.maxRetries; // Maximum number of retries
|
|
513
515
|
const delayBetweenRetries = this.delayBetweenRetries; // Delay between retries in milliseconds
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
516
|
+
this.debugWarnLog(`Retry Count: ${retryCount}`);
|
|
517
|
+
this.debugWarnLog(`Max Retries: ${maxRetries}`);
|
|
518
|
+
this.debugWarnLog(`Delay Between Retries: ${delayBetweenRetries}`);
|
|
517
519
|
while (retryCount < maxRetries) {
|
|
518
520
|
try {
|
|
519
521
|
const { body, statusCode } = await request(Devices, {
|
|
520
522
|
headers: this.generateHeaders(),
|
|
521
523
|
});
|
|
522
|
-
|
|
524
|
+
this.debugWarnLog(`statusCode: ${statusCode}`);
|
|
523
525
|
const devicesAPI: any = await body.json();
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
526
|
+
this.debugWarnLog(`devicesAPI: ${JSON.stringify(devicesAPI)}`);
|
|
527
|
+
this.debugWarnLog(`devicesAPI Body: ${JSON.stringify(devicesAPI.body)}`);
|
|
528
|
+
this.debugWarnLog(`devicesAPI StatusCode: ${devicesAPI.statusCode}`);
|
|
527
529
|
if ((statusCode === 200 || statusCode === 100) && (devicesAPI.statusCode === 200 || devicesAPI.statusCode === 100)) {
|
|
528
|
-
|
|
530
|
+
this.debugErrorLog(`statusCode: ${statusCode} & devicesAPI StatusCode: ${devicesAPI.statusCode}`);
|
|
529
531
|
// SwitchBot Devices
|
|
530
532
|
const deviceLists = devicesAPI.body.deviceList;
|
|
531
|
-
|
|
532
|
-
|
|
533
|
+
this.debugWarnLog(`DeviceLists: ${JSON.stringify(deviceLists)}`);
|
|
534
|
+
this.debugWarnLog(`DeviceLists Length: ${deviceLists.length}`);
|
|
533
535
|
if (!this.config.options?.devices) {
|
|
534
|
-
|
|
536
|
+
this.debugLog(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
535
537
|
if (deviceLists.length === 0) {
|
|
536
|
-
|
|
538
|
+
this.debugLog(`SwitchBot API Currently Doesn't Have Any Devices With Cloud Services Enabled: ${JSON.stringify(devicesAPI.body)}`);
|
|
537
539
|
} else {
|
|
538
540
|
const devices = deviceLists.map((v: any) => v);
|
|
539
541
|
for (const device of devices) {
|
|
@@ -546,9 +548,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
546
548
|
}
|
|
547
549
|
}
|
|
548
550
|
} else if (this.config.credentials?.token && this.config.options.devices) {
|
|
549
|
-
|
|
551
|
+
this.debugLog(`SwitchBot Device Config Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
550
552
|
if (deviceLists.length === 0) {
|
|
551
|
-
|
|
553
|
+
this.debugLog(`SwitchBot API Currently Doesn't Have Any Devices With Cloud Services Enabled: ${JSON.stringify(devicesAPI.body)}`);
|
|
552
554
|
} else {
|
|
553
555
|
const deviceConfigs = this.config.options?.devices;
|
|
554
556
|
|
|
@@ -562,7 +564,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
562
564
|
}));
|
|
563
565
|
|
|
564
566
|
const devices = mergeBydeviceId(deviceLists, deviceConfigs);
|
|
565
|
-
|
|
567
|
+
this.debugLog(`SwitchBot Devices: ${JSON.stringify(devices)}`);
|
|
566
568
|
for (const device of devices) {
|
|
567
569
|
if (!device.deviceType) {
|
|
568
570
|
device.deviceType = device.configDeviceType;
|
|
@@ -582,13 +584,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
582
584
|
if (devicesAPI.body.deviceList.length !== 0) {
|
|
583
585
|
this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
584
586
|
} else {
|
|
585
|
-
|
|
587
|
+
this.debugLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
586
588
|
}
|
|
587
589
|
|
|
588
590
|
// IR Devices
|
|
589
591
|
const irDeviceLists = devicesAPI.body.infraredRemoteList;
|
|
590
592
|
if (!this.config.options?.irdevices) {
|
|
591
|
-
|
|
593
|
+
this.debugLog(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
|
|
592
594
|
const devices = irDeviceLists.map((v: any) => v);
|
|
593
595
|
for (const device of devices) {
|
|
594
596
|
if (device.remoteType) {
|
|
@@ -596,7 +598,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
596
598
|
}
|
|
597
599
|
}
|
|
598
600
|
} else {
|
|
599
|
-
|
|
601
|
+
this.debugLog(`IR Device Config Set: ${JSON.stringify(this.config.options?.irdevices)}`);
|
|
600
602
|
const irDeviceConfig = this.config.options?.irdevices;
|
|
601
603
|
|
|
602
604
|
const mergeIRBydeviceId = (a1: { deviceId: string }[], a2: any[]) =>
|
|
@@ -609,7 +611,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
609
611
|
}));
|
|
610
612
|
|
|
611
613
|
const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
|
|
612
|
-
|
|
614
|
+
this.debugLog(`IR Devices: ${JSON.stringify(devices)}`);
|
|
613
615
|
for (const device of devices) {
|
|
614
616
|
this.createIRDevice(device);
|
|
615
617
|
}
|
|
@@ -617,7 +619,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
617
619
|
if (devicesAPI.body.infraredRemoteList.length !== 0) {
|
|
618
620
|
this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
619
621
|
} else {
|
|
620
|
-
|
|
622
|
+
this.debugLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
621
623
|
}
|
|
622
624
|
break;
|
|
623
625
|
} else {
|
|
@@ -633,11 +635,11 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
633
635
|
retryCount++;
|
|
634
636
|
this.debugErrorLog(
|
|
635
637
|
`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
636
|
-
|
|
638
|
+
this.debugErrorLog(`Failed to Discover Devices, Error: ${e}`);
|
|
637
639
|
}
|
|
638
640
|
}
|
|
639
641
|
} else if (!this.config.credentials?.token && this.config.options?.devices) {
|
|
640
|
-
|
|
642
|
+
this.debugLog(`SwitchBot Device Manual Config Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
641
643
|
const deviceConfigs = this.config.options?.devices;
|
|
642
644
|
const devices = deviceConfigs.map((v: any) => v);
|
|
643
645
|
for (const device of devices) {
|
|
@@ -652,73 +654,73 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
652
654
|
}
|
|
653
655
|
}
|
|
654
656
|
|
|
655
|
-
private
|
|
657
|
+
private createDevice(device: device & devicesConfig) {
|
|
656
658
|
switch (device.deviceType!) {
|
|
657
659
|
case 'Humidifier':
|
|
658
|
-
|
|
660
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
659
661
|
this.createHumidifier(device);
|
|
660
662
|
break;
|
|
661
663
|
case 'Hub Mini':
|
|
662
|
-
|
|
664
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
663
665
|
break;
|
|
664
666
|
case 'Hub Plus':
|
|
665
|
-
|
|
667
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
666
668
|
break;
|
|
667
669
|
case 'Hub 2':
|
|
668
|
-
|
|
670
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
669
671
|
this.createHub2(device);
|
|
670
672
|
break;
|
|
671
673
|
case 'Bot':
|
|
672
|
-
|
|
674
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
673
675
|
this.createBot(device);
|
|
674
676
|
break;
|
|
675
677
|
case 'Meter':
|
|
676
|
-
|
|
678
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
677
679
|
this.createMeter(device);
|
|
678
680
|
break;
|
|
679
681
|
case 'MeterPlus':
|
|
680
682
|
case 'Meter Plus (JP)':
|
|
681
|
-
|
|
683
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
682
684
|
this.createMeterPlus(device);
|
|
683
685
|
break;
|
|
684
686
|
case 'WoIOSensor':
|
|
685
|
-
|
|
687
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
686
688
|
this.createIOSensor(device);
|
|
687
689
|
break;
|
|
688
690
|
case 'Water Detector':
|
|
689
|
-
|
|
691
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
690
692
|
this.createWaterDetector(device);
|
|
691
693
|
break;
|
|
692
694
|
case 'Motion Sensor':
|
|
693
|
-
|
|
695
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
694
696
|
this.createMotion(device);
|
|
695
697
|
break;
|
|
696
698
|
case 'Contact Sensor':
|
|
697
|
-
|
|
699
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
698
700
|
this.createContact(device);
|
|
699
701
|
break;
|
|
700
702
|
case 'Curtain':
|
|
701
703
|
case 'Curtain3':
|
|
702
|
-
|
|
704
|
+
this.debugLog(`Discovered ${device.deviceType} ${device.deviceName}: ${device.deviceId}`);
|
|
703
705
|
this.createCurtain(device);
|
|
704
706
|
break;
|
|
705
707
|
case 'Blind Tilt':
|
|
706
|
-
|
|
708
|
+
this.debugLog(`Discovered ${device.deviceType} ${device.deviceName}: ${device.deviceId}`);
|
|
707
709
|
this.createBlindTilt(device);
|
|
708
710
|
break;
|
|
709
711
|
case 'Plug':
|
|
710
712
|
case 'Plug Mini (US)':
|
|
711
713
|
case 'Plug Mini (JP)':
|
|
712
|
-
|
|
714
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
713
715
|
this.createPlug(device);
|
|
714
716
|
break;
|
|
715
717
|
case 'Smart Lock':
|
|
716
718
|
case 'Smart Lock Pro':
|
|
717
|
-
|
|
719
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
718
720
|
this.createLock(device);
|
|
719
721
|
break;
|
|
720
722
|
case 'Color Bulb':
|
|
721
|
-
|
|
723
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
722
724
|
this.createColorBulb(device);
|
|
723
725
|
break;
|
|
724
726
|
case 'K10+':
|
|
@@ -727,26 +729,26 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
727
729
|
case 'Robot Vacuum Cleaner S1':
|
|
728
730
|
case 'Robot Vacuum Cleaner S1 Plus':
|
|
729
731
|
case 'Robot Vacuum Cleaner S10':
|
|
730
|
-
|
|
732
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
731
733
|
this.createRobotVacuumCleaner(device);
|
|
732
734
|
break;
|
|
733
735
|
case 'Ceiling Light':
|
|
734
736
|
case 'Ceiling Light Pro':
|
|
735
|
-
|
|
737
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
736
738
|
this.createCeilingLight(device);
|
|
737
739
|
break;
|
|
738
740
|
case 'Strip Light':
|
|
739
|
-
|
|
741
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
740
742
|
this.createStripLight(device);
|
|
741
743
|
break;
|
|
742
744
|
case 'Battery Circulator Fan':
|
|
743
|
-
|
|
745
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
744
746
|
this.createFan(device);
|
|
745
747
|
break;
|
|
746
748
|
case 'Remote':
|
|
747
749
|
case 'Indoor Cam':
|
|
748
750
|
case 'remote with screen+':
|
|
749
|
-
|
|
751
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}, is currently not supported, device: ${JSON.stringify(device)}`);
|
|
750
752
|
break;
|
|
751
753
|
default:
|
|
752
754
|
this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`,
|
|
@@ -754,7 +756,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
754
756
|
}
|
|
755
757
|
}
|
|
756
758
|
|
|
757
|
-
private
|
|
759
|
+
private createIRDevice(device: irdevice & devicesConfig) {
|
|
758
760
|
if (device.connectionType === undefined) {
|
|
759
761
|
device.connectionType = 'OpenAPI';
|
|
760
762
|
}
|
|
@@ -771,7 +773,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
771
773
|
case 'DIY DVD':
|
|
772
774
|
case 'Speaker':
|
|
773
775
|
case 'DIY Speaker':
|
|
774
|
-
|
|
776
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
775
777
|
if (device.external === undefined) {
|
|
776
778
|
device.external = true;
|
|
777
779
|
this.createTV(device);
|
|
@@ -781,45 +783,45 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
781
783
|
break;
|
|
782
784
|
case 'Fan':
|
|
783
785
|
case 'DIY Fan':
|
|
784
|
-
|
|
786
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
785
787
|
this.createIRFan(device);
|
|
786
788
|
break;
|
|
787
789
|
case 'Air Conditioner':
|
|
788
790
|
case 'DIY Air Conditioner':
|
|
789
|
-
|
|
791
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
790
792
|
this.createAirConditioner(device);
|
|
791
793
|
break;
|
|
792
794
|
case 'Light':
|
|
793
795
|
case 'DIY Light':
|
|
794
|
-
|
|
796
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
795
797
|
this.createLight(device);
|
|
796
798
|
break;
|
|
797
799
|
case 'Air Purifier':
|
|
798
800
|
case 'DIY Air Purifier':
|
|
799
|
-
|
|
801
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
800
802
|
this.createAirPurifier(device);
|
|
801
803
|
break;
|
|
802
804
|
case 'Water Heater':
|
|
803
805
|
case 'DIY Water Heater':
|
|
804
|
-
|
|
806
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
805
807
|
this.createWaterHeater(device);
|
|
806
808
|
break;
|
|
807
809
|
case 'Vacuum Cleaner':
|
|
808
810
|
case 'DIY Vacuum Cleaner':
|
|
809
|
-
|
|
811
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
810
812
|
this.createVacuumCleaner(device);
|
|
811
813
|
break;
|
|
812
814
|
case 'Camera':
|
|
813
815
|
case 'DIY Camera':
|
|
814
|
-
|
|
816
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
815
817
|
this.createCamera(device);
|
|
816
818
|
break;
|
|
817
819
|
case 'Others':
|
|
818
|
-
|
|
820
|
+
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
819
821
|
this.createOthers(device);
|
|
820
822
|
break;
|
|
821
823
|
default:
|
|
822
|
-
|
|
824
|
+
this.debugLog(`Unsupported Device: ${JSON.stringify(device)}`);
|
|
823
825
|
this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`);
|
|
824
826
|
this.warnLog('Submit Feature Requests Here: ' + 'https://tinyurl.com/SwitchBotFeatureRequest');
|
|
825
827
|
}
|
|
@@ -849,7 +851,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
849
851
|
// create the accessory handler for the restored accessory
|
|
850
852
|
// this is imported from `platformAccessory.ts`
|
|
851
853
|
new Humidifier(this, existingAccessory, device);
|
|
852
|
-
|
|
854
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
853
855
|
} else {
|
|
854
856
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
855
857
|
}
|
|
@@ -875,13 +877,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
875
877
|
// create the accessory handler for the newly create accessory
|
|
876
878
|
// this is imported from `platformAccessory.ts`
|
|
877
879
|
new Humidifier(this, accessory, device);
|
|
878
|
-
|
|
880
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
879
881
|
|
|
880
882
|
// publish device externally or link the accessory to your platform
|
|
881
883
|
this.externalOrPlatform(device, accessory);
|
|
882
884
|
this.accessories.push(accessory);
|
|
883
885
|
} else {
|
|
884
|
-
|
|
886
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
885
887
|
}
|
|
886
888
|
}
|
|
887
889
|
|
|
@@ -909,7 +911,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
909
911
|
// create the accessory handler for the restored accessory
|
|
910
912
|
// this is imported from `platformAccessory.ts`
|
|
911
913
|
new Bot(this, existingAccessory, device);
|
|
912
|
-
|
|
914
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
913
915
|
} else {
|
|
914
916
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
915
917
|
}
|
|
@@ -936,13 +938,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
936
938
|
// create the accessory handler for the newly create accessory
|
|
937
939
|
// this is imported from `platformAccessory.ts`
|
|
938
940
|
new Bot(this, accessory, device);
|
|
939
|
-
|
|
941
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
940
942
|
|
|
941
943
|
// publish device externally or link the accessory to your platform
|
|
942
944
|
this.externalOrPlatform(device, accessory);
|
|
943
945
|
this.accessories.push(accessory);
|
|
944
946
|
} else {
|
|
945
|
-
|
|
947
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
946
948
|
}
|
|
947
949
|
}
|
|
948
950
|
|
|
@@ -970,7 +972,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
970
972
|
// create the accessory handler for the restored accessory
|
|
971
973
|
// this is imported from `platformAccessory.ts`
|
|
972
974
|
new Meter(this, existingAccessory, device);
|
|
973
|
-
|
|
975
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
974
976
|
} else {
|
|
975
977
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
976
978
|
}
|
|
@@ -996,13 +998,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
996
998
|
// create the accessory handler for the newly create accessory
|
|
997
999
|
// this is imported from `platformAccessory.ts`
|
|
998
1000
|
new Meter(this, accessory, device);
|
|
999
|
-
|
|
1001
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1000
1002
|
|
|
1001
1003
|
// publish device externally or link the accessory to your platform
|
|
1002
1004
|
this.externalOrPlatform(device, accessory);
|
|
1003
1005
|
this.accessories.push(accessory);
|
|
1004
1006
|
} else {
|
|
1005
|
-
|
|
1007
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1006
1008
|
}
|
|
1007
1009
|
}
|
|
1008
1010
|
|
|
@@ -1031,7 +1033,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1031
1033
|
// create the accessory handler for the restored accessory
|
|
1032
1034
|
// this is imported from `platformAccessory.ts`
|
|
1033
1035
|
new MeterPlus(this, existingAccessory, device);
|
|
1034
|
-
|
|
1036
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1035
1037
|
} else {
|
|
1036
1038
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1037
1039
|
}
|
|
@@ -1057,13 +1059,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1057
1059
|
// create the accessory handler for the newly create accessory
|
|
1058
1060
|
// this is imported from `platformAccessory.ts`
|
|
1059
1061
|
new MeterPlus(this, accessory, device);
|
|
1060
|
-
|
|
1062
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1061
1063
|
|
|
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
|
} else {
|
|
1066
|
-
|
|
1068
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1067
1069
|
}
|
|
1068
1070
|
}
|
|
1069
1071
|
|
|
@@ -1092,7 +1094,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1092
1094
|
// create the accessory handler for the restored accessory
|
|
1093
1095
|
// this is imported from `platformAccessory.ts`
|
|
1094
1096
|
new Hub(this, existingAccessory, device);
|
|
1095
|
-
|
|
1097
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1096
1098
|
} else {
|
|
1097
1099
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1098
1100
|
}
|
|
@@ -1118,13 +1120,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1118
1120
|
// create the accessory handler for the newly create accessory
|
|
1119
1121
|
// this is imported from `platformAccessory.ts`
|
|
1120
1122
|
new Hub(this, accessory, device);
|
|
1121
|
-
|
|
1123
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1122
1124
|
|
|
1123
1125
|
// publish device externally or link the accessory to your platform
|
|
1124
1126
|
this.externalOrPlatform(device, accessory);
|
|
1125
1127
|
this.accessories.push(accessory);
|
|
1126
1128
|
} else {
|
|
1127
|
-
|
|
1129
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1128
1130
|
}
|
|
1129
1131
|
}
|
|
1130
1132
|
|
|
@@ -1152,7 +1154,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1152
1154
|
// create the accessory handler for the restored accessory
|
|
1153
1155
|
// this is imported from `platformAccessory.ts`
|
|
1154
1156
|
new IOSensor(this, existingAccessory, device);
|
|
1155
|
-
|
|
1157
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1156
1158
|
} else {
|
|
1157
1159
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1158
1160
|
}
|
|
@@ -1178,13 +1180,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1178
1180
|
// create the accessory handler for the newly create accessory
|
|
1179
1181
|
// this is imported from `platformAccessory.ts`
|
|
1180
1182
|
new IOSensor(this, accessory, device);
|
|
1181
|
-
|
|
1183
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1182
1184
|
|
|
1183
1185
|
// publish device externally or link the accessory to your platform
|
|
1184
1186
|
this.externalOrPlatform(device, accessory);
|
|
1185
1187
|
this.accessories.push(accessory);
|
|
1186
1188
|
} else {
|
|
1187
|
-
|
|
1189
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1188
1190
|
}
|
|
1189
1191
|
}
|
|
1190
1192
|
|
|
@@ -1212,7 +1214,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1212
1214
|
// create the accessory handler for the restored accessory
|
|
1213
1215
|
// this is imported from `platformAccessory.ts`
|
|
1214
1216
|
new WaterDetector(this, existingAccessory, device);
|
|
1215
|
-
|
|
1217
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1216
1218
|
} else {
|
|
1217
1219
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1218
1220
|
}
|
|
@@ -1238,13 +1240,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1238
1240
|
// create the accessory handler for the newly create accessory
|
|
1239
1241
|
// this is imported from `platformAccessory.ts`
|
|
1240
1242
|
new WaterDetector(this, accessory, device);
|
|
1241
|
-
|
|
1243
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1242
1244
|
|
|
1243
1245
|
// publish device externally or link the accessory to your platform
|
|
1244
1246
|
this.externalOrPlatform(device, accessory);
|
|
1245
1247
|
this.accessories.push(accessory);
|
|
1246
1248
|
} else {
|
|
1247
|
-
|
|
1249
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1248
1250
|
}
|
|
1249
1251
|
}
|
|
1250
1252
|
|
|
@@ -1272,7 +1274,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1272
1274
|
// create the accessory handler for the restored accessory
|
|
1273
1275
|
// this is imported from `platformAccessory.ts`
|
|
1274
1276
|
new Motion(this, existingAccessory, device);
|
|
1275
|
-
|
|
1277
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1276
1278
|
} else {
|
|
1277
1279
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1278
1280
|
}
|
|
@@ -1298,13 +1300,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1298
1300
|
// create the accessory handler for the newly create accessory
|
|
1299
1301
|
// this is imported from `platformAccessory.ts`
|
|
1300
1302
|
new Motion(this, accessory, device);
|
|
1301
|
-
|
|
1303
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1302
1304
|
|
|
1303
1305
|
// publish device externally or link the accessory to your platform
|
|
1304
1306
|
this.externalOrPlatform(device, accessory);
|
|
1305
1307
|
this.accessories.push(accessory);
|
|
1306
1308
|
} else {
|
|
1307
|
-
|
|
1309
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1308
1310
|
}
|
|
1309
1311
|
}
|
|
1310
1312
|
|
|
@@ -1332,7 +1334,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1332
1334
|
// create the accessory handler for the restored accessory
|
|
1333
1335
|
// this is imported from `platformAccessory.ts`
|
|
1334
1336
|
new Contact(this, existingAccessory, device);
|
|
1335
|
-
|
|
1337
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1336
1338
|
} else {
|
|
1337
1339
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1338
1340
|
}
|
|
@@ -1358,13 +1360,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1358
1360
|
// create the accessory handler for the newly create accessory
|
|
1359
1361
|
// this is imported from `platformAccessory.ts`
|
|
1360
1362
|
new Contact(this, accessory, device);
|
|
1361
|
-
|
|
1363
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1362
1364
|
|
|
1363
1365
|
// publish device externally or link the accessory to your platform
|
|
1364
1366
|
this.externalOrPlatform(device, accessory);
|
|
1365
1367
|
this.accessories.push(accessory);
|
|
1366
1368
|
} else {
|
|
1367
|
-
|
|
1369
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1368
1370
|
}
|
|
1369
1371
|
}
|
|
1370
1372
|
|
|
@@ -1392,7 +1394,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1392
1394
|
// create the accessory handler for the restored accessory
|
|
1393
1395
|
// this is imported from `platformAccessory.ts`
|
|
1394
1396
|
new BlindTilt(this, existingAccessory, device);
|
|
1395
|
-
|
|
1397
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1396
1398
|
} else {
|
|
1397
1399
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1398
1400
|
}
|
|
@@ -1432,13 +1434,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1432
1434
|
// create the accessory handler for the newly create accessory
|
|
1433
1435
|
// this is imported from `platformAccessory.ts`
|
|
1434
1436
|
new BlindTilt(this, accessory, device);
|
|
1435
|
-
|
|
1437
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1436
1438
|
|
|
1437
1439
|
// publish device externally or link the accessory to your platform
|
|
1438
1440
|
this.externalOrPlatform(device, accessory);
|
|
1439
1441
|
this.accessories.push(accessory);
|
|
1440
1442
|
} else {
|
|
1441
|
-
|
|
1443
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1442
1444
|
}
|
|
1443
1445
|
}
|
|
1444
1446
|
|
|
@@ -1466,7 +1468,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1466
1468
|
// create the accessory handler for the restored accessory
|
|
1467
1469
|
// this is imported from `platformAccessory.ts`
|
|
1468
1470
|
new Curtain(this, existingAccessory, device);
|
|
1469
|
-
|
|
1471
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1470
1472
|
} else {
|
|
1471
1473
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1472
1474
|
}
|
|
@@ -1507,13 +1509,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1507
1509
|
// create the accessory handler for the newly create accessory
|
|
1508
1510
|
// this is imported from `platformAccessory.ts`
|
|
1509
1511
|
new Curtain(this, accessory, device);
|
|
1510
|
-
|
|
1512
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1511
1513
|
|
|
1512
1514
|
// publish device externally or link the accessory to your platform
|
|
1513
1515
|
this.externalOrPlatform(device, accessory);
|
|
1514
1516
|
this.accessories.push(accessory);
|
|
1515
1517
|
} else {
|
|
1516
|
-
|
|
1518
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1517
1519
|
}
|
|
1518
1520
|
}
|
|
1519
1521
|
|
|
@@ -1541,7 +1543,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1541
1543
|
// create the accessory handler for the restored accessory
|
|
1542
1544
|
// this is imported from `platformAccessory.ts`
|
|
1543
1545
|
new Plug(this, existingAccessory, device);
|
|
1544
|
-
|
|
1546
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1545
1547
|
} else {
|
|
1546
1548
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1547
1549
|
}
|
|
@@ -1567,13 +1569,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1567
1569
|
// create the accessory handler for the newly create accessory
|
|
1568
1570
|
// this is imported from `platformAccessory.ts`
|
|
1569
1571
|
new Plug(this, accessory, device);
|
|
1570
|
-
|
|
1572
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1571
1573
|
|
|
1572
1574
|
// publish device externally or link the accessory to your platform
|
|
1573
1575
|
this.externalOrPlatform(device, accessory);
|
|
1574
1576
|
this.accessories.push(accessory);
|
|
1575
1577
|
} else {
|
|
1576
|
-
|
|
1578
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1577
1579
|
}
|
|
1578
1580
|
}
|
|
1579
1581
|
|
|
@@ -1601,7 +1603,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1601
1603
|
// create the accessory handler for the restored accessory
|
|
1602
1604
|
// this is imported from `platformAccessory.ts`
|
|
1603
1605
|
new Lock(this, existingAccessory, device);
|
|
1604
|
-
|
|
1606
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1605
1607
|
} else {
|
|
1606
1608
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1607
1609
|
}
|
|
@@ -1627,13 +1629,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1627
1629
|
// create the accessory handler for the newly create accessory
|
|
1628
1630
|
// this is imported from `platformAccessory.ts`
|
|
1629
1631
|
new Lock(this, accessory, device);
|
|
1630
|
-
|
|
1632
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1631
1633
|
|
|
1632
1634
|
// publish device externally or link the accessory to your platform
|
|
1633
1635
|
this.externalOrPlatform(device, accessory);
|
|
1634
1636
|
this.accessories.push(accessory);
|
|
1635
1637
|
} else {
|
|
1636
|
-
|
|
1638
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1637
1639
|
}
|
|
1638
1640
|
}
|
|
1639
1641
|
|
|
@@ -1661,7 +1663,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1661
1663
|
// create the accessory handler for the restored accessory
|
|
1662
1664
|
// this is imported from `platformAccessory.ts`
|
|
1663
1665
|
new ColorBulb(this, existingAccessory, device);
|
|
1664
|
-
|
|
1666
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1665
1667
|
} else {
|
|
1666
1668
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1667
1669
|
}
|
|
@@ -1687,13 +1689,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1687
1689
|
// create the accessory handler for the newly create accessory
|
|
1688
1690
|
// this is imported from `platformAccessory.ts`
|
|
1689
1691
|
new ColorBulb(this, accessory, device);
|
|
1690
|
-
|
|
1692
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1691
1693
|
|
|
1692
1694
|
// publish device externally or link the accessory to your platform
|
|
1693
1695
|
this.externalOrPlatform(device, accessory);
|
|
1694
1696
|
this.accessories.push(accessory);
|
|
1695
1697
|
} else {
|
|
1696
|
-
|
|
1698
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1697
1699
|
}
|
|
1698
1700
|
}
|
|
1699
1701
|
|
|
@@ -1721,7 +1723,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1721
1723
|
// create the accessory handler for the restored accessory
|
|
1722
1724
|
// this is imported from `platformAccessory.ts`
|
|
1723
1725
|
new CeilingLight(this, existingAccessory, device);
|
|
1724
|
-
|
|
1726
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1725
1727
|
} else {
|
|
1726
1728
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1727
1729
|
}
|
|
@@ -1747,13 +1749,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1747
1749
|
// create the accessory handler for the newly create accessory
|
|
1748
1750
|
// this is imported from `platformAccessory.ts`
|
|
1749
1751
|
new CeilingLight(this, accessory, device);
|
|
1750
|
-
|
|
1752
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1751
1753
|
|
|
1752
1754
|
// publish device externally or link the accessory to your platform
|
|
1753
1755
|
this.externalOrPlatform(device, accessory);
|
|
1754
1756
|
this.accessories.push(accessory);
|
|
1755
1757
|
} else {
|
|
1756
|
-
|
|
1758
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1757
1759
|
}
|
|
1758
1760
|
}
|
|
1759
1761
|
|
|
@@ -1781,7 +1783,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1781
1783
|
// create the accessory handler for the restored accessory
|
|
1782
1784
|
// this is imported from `platformAccessory.ts`
|
|
1783
1785
|
new StripLight(this, existingAccessory, device);
|
|
1784
|
-
|
|
1786
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1785
1787
|
} else {
|
|
1786
1788
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1787
1789
|
}
|
|
@@ -1807,13 +1809,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1807
1809
|
// create the accessory handler for the newly create accessory
|
|
1808
1810
|
// this is imported from `platformAccessory.ts`
|
|
1809
1811
|
new StripLight(this, accessory, device);
|
|
1810
|
-
|
|
1812
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1811
1813
|
|
|
1812
1814
|
// publish device externally or link the accessory to your platform
|
|
1813
1815
|
this.externalOrPlatform(device, accessory);
|
|
1814
1816
|
this.accessories.push(accessory);
|
|
1815
1817
|
} else {
|
|
1816
|
-
|
|
1818
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1817
1819
|
}
|
|
1818
1820
|
}
|
|
1819
1821
|
|
|
@@ -1841,7 +1843,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1841
1843
|
// create the accessory handler for the restored accessory
|
|
1842
1844
|
// this is imported from `platformAccessory.ts`
|
|
1843
1845
|
new Fan(this, existingAccessory, device);
|
|
1844
|
-
|
|
1846
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1845
1847
|
} else {
|
|
1846
1848
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1847
1849
|
}
|
|
@@ -1867,13 +1869,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1867
1869
|
// create the accessory handler for the newly create accessory
|
|
1868
1870
|
// this is imported from `platformAccessory.ts`
|
|
1869
1871
|
new Fan(this, accessory, device);
|
|
1870
|
-
|
|
1872
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1871
1873
|
|
|
1872
1874
|
// publish device externally or link the accessory to your platform
|
|
1873
1875
|
this.externalOrPlatform(device, accessory);
|
|
1874
1876
|
this.accessories.push(accessory);
|
|
1875
1877
|
} else {
|
|
1876
|
-
|
|
1878
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1877
1879
|
}
|
|
1878
1880
|
}
|
|
1879
1881
|
|
|
@@ -1901,7 +1903,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1901
1903
|
// create the accessory handler for the restored accessory
|
|
1902
1904
|
// this is imported from `platformAccessory.ts`
|
|
1903
1905
|
new RobotVacuumCleaner(this, existingAccessory, device);
|
|
1904
|
-
|
|
1906
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1905
1907
|
} else {
|
|
1906
1908
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
1907
1909
|
}
|
|
@@ -1927,13 +1929,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1927
1929
|
// create the accessory handler for the newly create accessory
|
|
1928
1930
|
// this is imported from `platformAccessory.ts`
|
|
1929
1931
|
new RobotVacuumCleaner(this, accessory, device);
|
|
1930
|
-
|
|
1932
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1931
1933
|
|
|
1932
1934
|
// publish device externally or link the accessory to your platform
|
|
1933
1935
|
this.externalOrPlatform(device, accessory);
|
|
1934
1936
|
this.accessories.push(accessory);
|
|
1935
1937
|
} else {
|
|
1936
|
-
|
|
1938
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1937
1939
|
}
|
|
1938
1940
|
}
|
|
1939
1941
|
|
|
@@ -1956,7 +1958,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1956
1958
|
// create the accessory handler for the restored accessory
|
|
1957
1959
|
// this is imported from `platformAccessory.ts`
|
|
1958
1960
|
new TV(this, existingAccessory, device);
|
|
1959
|
-
|
|
1961
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1960
1962
|
} else if (!device.hide_device && device.hubDeviceId) {
|
|
1961
1963
|
// the accessory does not yet exist, so we need to create it
|
|
1962
1964
|
if (!device.external) {
|
|
@@ -1979,12 +1981,12 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1979
1981
|
// create the accessory handler for the newly create accessory
|
|
1980
1982
|
// this is imported from `platformAccessory.ts`
|
|
1981
1983
|
new TV(this, accessory, device);
|
|
1982
|
-
|
|
1984
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
1983
1985
|
|
|
1984
1986
|
this.externalOrPlatformIR(device, accessory);
|
|
1985
1987
|
this.accessories.push(accessory);
|
|
1986
1988
|
} else {
|
|
1987
|
-
|
|
1989
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1988
1990
|
}
|
|
1989
1991
|
}
|
|
1990
1992
|
|
|
@@ -2012,7 +2014,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2012
2014
|
// create the accessory handler for the restored accessory
|
|
2013
2015
|
// this is imported from `platformAccessory.ts`
|
|
2014
2016
|
new IRFan(this, existingAccessory, device);
|
|
2015
|
-
|
|
2017
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2016
2018
|
} else {
|
|
2017
2019
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
2018
2020
|
}
|
|
@@ -2038,13 +2040,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2038
2040
|
// create the accessory handler for the newly create accessory
|
|
2039
2041
|
// this is imported from `platformAccessory.ts`
|
|
2040
2042
|
new IRFan(this, accessory, device);
|
|
2041
|
-
|
|
2043
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2042
2044
|
|
|
2043
2045
|
// publish device externally or link the accessory to your platform
|
|
2044
2046
|
this.externalOrPlatformIR(device, accessory);
|
|
2045
2047
|
this.accessories.push(accessory);
|
|
2046
2048
|
} else {
|
|
2047
|
-
|
|
2049
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2048
2050
|
}
|
|
2049
2051
|
}
|
|
2050
2052
|
|
|
@@ -2072,7 +2074,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2072
2074
|
// create the accessory handler for the restored accessory
|
|
2073
2075
|
// this is imported from `platformAccessory.ts`
|
|
2074
2076
|
new Light(this, existingAccessory, device);
|
|
2075
|
-
|
|
2077
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2076
2078
|
} else {
|
|
2077
2079
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
2078
2080
|
}
|
|
@@ -2098,13 +2100,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2098
2100
|
// create the accessory handler for the newly create accessory
|
|
2099
2101
|
// this is imported from `platformAccessory.ts`
|
|
2100
2102
|
new Light(this, accessory, device);
|
|
2101
|
-
|
|
2103
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2102
2104
|
|
|
2103
2105
|
// publish device externally or link the accessory to your platform
|
|
2104
2106
|
this.externalOrPlatformIR(device, accessory);
|
|
2105
2107
|
this.accessories.push(accessory);
|
|
2106
2108
|
} else {
|
|
2107
|
-
|
|
2109
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2108
2110
|
}
|
|
2109
2111
|
}
|
|
2110
2112
|
|
|
@@ -2132,7 +2134,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2132
2134
|
// create the accessory handler for the restored accessory
|
|
2133
2135
|
// this is imported from `platformAccessory.ts`
|
|
2134
2136
|
new AirConditioner(this, existingAccessory, device);
|
|
2135
|
-
|
|
2137
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2136
2138
|
} else {
|
|
2137
2139
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
2138
2140
|
}
|
|
@@ -2158,13 +2160,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2158
2160
|
// create the accessory handler for the newly create accessory
|
|
2159
2161
|
// this is imported from `platformAccessory.ts`
|
|
2160
2162
|
new AirConditioner(this, accessory, device);
|
|
2161
|
-
|
|
2163
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2162
2164
|
|
|
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
|
} else {
|
|
2167
|
-
|
|
2169
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2168
2170
|
}
|
|
2169
2171
|
}
|
|
2170
2172
|
|
|
@@ -2192,7 +2194,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2192
2194
|
// create the accessory handler for the restored accessory
|
|
2193
2195
|
// this is imported from `platformAccessory.ts`
|
|
2194
2196
|
new AirPurifier(this, existingAccessory, device);
|
|
2195
|
-
|
|
2197
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2196
2198
|
} else {
|
|
2197
2199
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
2198
2200
|
}
|
|
@@ -2218,13 +2220,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2218
2220
|
// create the accessory handler for the newly create accessory
|
|
2219
2221
|
// this is imported from `platformAccessory.ts`
|
|
2220
2222
|
new AirPurifier(this, accessory, device);
|
|
2221
|
-
|
|
2223
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2222
2224
|
|
|
2223
2225
|
// publish device externally or link the accessory to your platform
|
|
2224
2226
|
this.externalOrPlatformIR(device, accessory);
|
|
2225
2227
|
this.accessories.push(accessory);
|
|
2226
2228
|
} else {
|
|
2227
|
-
|
|
2229
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2228
2230
|
}
|
|
2229
2231
|
}
|
|
2230
2232
|
|
|
@@ -2252,7 +2254,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2252
2254
|
// create the accessory handler for the restored accessory
|
|
2253
2255
|
// this is imported from `platformAccessory.ts`
|
|
2254
2256
|
new WaterHeater(this, existingAccessory, device);
|
|
2255
|
-
|
|
2257
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2256
2258
|
} else {
|
|
2257
2259
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
2258
2260
|
}
|
|
@@ -2278,13 +2280,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2278
2280
|
// create the accessory handler for the newly create accessory
|
|
2279
2281
|
// this is imported from `platformAccessory.ts`
|
|
2280
2282
|
new WaterHeater(this, accessory, device);
|
|
2281
|
-
|
|
2283
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2282
2284
|
|
|
2283
2285
|
// publish device externally or link the accessory to your platform
|
|
2284
2286
|
this.externalOrPlatformIR(device, accessory);
|
|
2285
2287
|
this.accessories.push(accessory);
|
|
2286
2288
|
} else {
|
|
2287
|
-
|
|
2289
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2288
2290
|
}
|
|
2289
2291
|
}
|
|
2290
2292
|
|
|
@@ -2312,7 +2314,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2312
2314
|
// create the accessory handler for the restored accessory
|
|
2313
2315
|
// this is imported from `platformAccessory.ts`
|
|
2314
2316
|
new VacuumCleaner(this, existingAccessory, device);
|
|
2315
|
-
|
|
2317
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2316
2318
|
} else {
|
|
2317
2319
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
2318
2320
|
}
|
|
@@ -2338,13 +2340,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2338
2340
|
// create the accessory handler for the newly create accessory
|
|
2339
2341
|
// this is imported from `platformAccessory.ts`
|
|
2340
2342
|
new VacuumCleaner(this, accessory, device);
|
|
2341
|
-
|
|
2343
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2342
2344
|
|
|
2343
2345
|
// publish device externally or link the accessory to your platform
|
|
2344
2346
|
this.externalOrPlatformIR(device, accessory);
|
|
2345
2347
|
this.accessories.push(accessory);
|
|
2346
2348
|
} else {
|
|
2347
|
-
|
|
2349
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2348
2350
|
}
|
|
2349
2351
|
}
|
|
2350
2352
|
|
|
@@ -2372,7 +2374,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2372
2374
|
// create the accessory handler for the restored accessory
|
|
2373
2375
|
// this is imported from `platformAccessory.ts`
|
|
2374
2376
|
new Camera(this, existingAccessory, device);
|
|
2375
|
-
|
|
2377
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2376
2378
|
} else {
|
|
2377
2379
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
2378
2380
|
}
|
|
@@ -2398,13 +2400,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2398
2400
|
// create the accessory handler for the newly create accessory
|
|
2399
2401
|
// this is imported from `platformAccessory.ts`
|
|
2400
2402
|
new Camera(this, accessory, device);
|
|
2401
|
-
|
|
2403
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2402
2404
|
|
|
2403
2405
|
// publish device externally or link the accessory to your platform
|
|
2404
2406
|
this.externalOrPlatformIR(device, accessory);
|
|
2405
2407
|
this.accessories.push(accessory);
|
|
2406
2408
|
} else {
|
|
2407
|
-
|
|
2409
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2408
2410
|
}
|
|
2409
2411
|
}
|
|
2410
2412
|
|
|
@@ -2432,7 +2434,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2432
2434
|
// create the accessory handler for the restored accessory
|
|
2433
2435
|
// this is imported from `platformAccessory.ts`
|
|
2434
2436
|
new Others(this, existingAccessory, device);
|
|
2435
|
-
|
|
2437
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
2436
2438
|
} else {
|
|
2437
2439
|
this.unregisterPlatformAccessories(existingAccessory);
|
|
2438
2440
|
}
|
|
@@ -2458,13 +2460,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2458
2460
|
// create the accessory handler for the newly create accessory
|
|
2459
2461
|
// this is imported from `platformAccessory.ts`
|
|
2460
2462
|
new Others(this, accessory, device);
|
|
2461
|
-
|
|
2463
|
+
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`);
|
|
2462
2464
|
|
|
2463
2465
|
// publish device externally or link the accessory to your platform
|
|
2464
2466
|
this.externalOrPlatformIR(device, accessory);
|
|
2465
2467
|
this.accessories.push(accessory);
|
|
2466
2468
|
} else {
|
|
2467
|
-
|
|
2469
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
2468
2470
|
}
|
|
2469
2471
|
}
|
|
2470
2472
|
|
|
@@ -2478,12 +2480,11 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2478
2480
|
}*/
|
|
2479
2481
|
let registerWindowCovering: boolean;
|
|
2480
2482
|
if (isCurtainDevice(device)) {
|
|
2481
|
-
|
|
2482
|
-
+
|
|
2483
|
-
+ ` connectionType: ${device.connectionType}`);
|
|
2483
|
+
this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds}, master: `
|
|
2484
|
+
+ `${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}, connectionType: ${device.connectionType}`);
|
|
2484
2485
|
registerWindowCovering = await this.registerWindowCovering(device);
|
|
2485
2486
|
} else if (isBlindTiltDevice(device)) {
|
|
2486
|
-
|
|
2487
|
+
this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, blindTiltDevicesIds: ${device.blindTiltDevicesIds},`
|
|
2487
2488
|
+ ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group},`
|
|
2488
2489
|
+ ` connectionType: ${device.connectionType}`);
|
|
2489
2490
|
registerWindowCovering =await this.registerWindowCovering(device);
|
|
@@ -2494,38 +2495,38 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2494
2495
|
}
|
|
2495
2496
|
|
|
2496
2497
|
async registerWindowCovering(device: ((curtain | curtain3) & devicesConfig) | (blindTilt & devicesConfig)) {
|
|
2497
|
-
|
|
2498
|
+
this.debugLog(device.master);
|
|
2498
2499
|
let registerCurtain: boolean;
|
|
2499
2500
|
if (device.master && device.group) {
|
|
2500
2501
|
// OpenAPI: Master Curtains/Blind Tilt in Group
|
|
2501
2502
|
registerCurtain = true;
|
|
2502
|
-
|
|
2503
|
-
+ `
|
|
2504
|
-
|
|
2503
|
+
this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, device.group: ${device.group}`
|
|
2504
|
+
+ ` connectionType; ${device.connectionType}`);
|
|
2505
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
|
|
2505
2506
|
} else if (!device.master && device.curtain?.disable_group) {
|
|
2506
2507
|
//!device.group && device.connectionType === 'BLE'
|
|
2507
2508
|
// OpenAPI: Non-Master Curtains/Blind Tilts that has Disable Grouping Checked
|
|
2508
2509
|
registerCurtain = true;
|
|
2509
|
-
|
|
2510
|
+
this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, disable_group: `
|
|
2510
2511
|
+ `${device.curtain?.disable_group}, connectionType; ${device.connectionType}`);
|
|
2511
|
-
|
|
2512
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
|
|
2512
2513
|
} else if (device.master && !device.group) {
|
|
2513
2514
|
// OpenAPI: Master Curtains/Blind Tilts not in Group
|
|
2514
2515
|
registerCurtain = true;
|
|
2515
|
-
|
|
2516
|
-
+ `
|
|
2517
|
-
|
|
2516
|
+
this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] device.master: ${device.master}, device.group: ${device.group}`
|
|
2517
|
+
+ ` connectionType; ${device.connectionType}`);
|
|
2518
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
|
|
2518
2519
|
} else if (device.connectionType === 'BLE') {
|
|
2519
2520
|
// BLE: Curtains/Blind Tilt
|
|
2520
2521
|
registerCurtain = true;
|
|
2521
|
-
|
|
2522
|
+
this.debugLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] connectionType: ${device.connectionType}, `
|
|
2522
2523
|
+ ` group: ${device.group}`);
|
|
2523
|
-
|
|
2524
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}`);
|
|
2524
2525
|
} else {
|
|
2525
2526
|
registerCurtain = false;
|
|
2526
|
-
|
|
2527
|
+
this.debugErrorLog(`deviceName: ${device.deviceName} [${device.deviceType} Config] disable_group: ${device.curtain?.disable_group},`
|
|
2527
2528
|
+ ` device.master: ${device.master}, device.group: ${device.group}`);
|
|
2528
|
-
|
|
2529
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerCurtains: ${registerCurtain}, device.connectionType: ${device.connectionType}`);
|
|
2529
2530
|
}
|
|
2530
2531
|
return registerCurtain;
|
|
2531
2532
|
}
|
|
@@ -2549,16 +2550,16 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2549
2550
|
case 'Curtain3':
|
|
2550
2551
|
case 'Blind Tilt':
|
|
2551
2552
|
registerDevice = await this.registerCurtains(device);
|
|
2552
|
-
|
|
2553
|
+
this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
|
|
2553
2554
|
break;
|
|
2554
2555
|
default:
|
|
2555
2556
|
registerDevice = true;
|
|
2556
|
-
|
|
2557
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2557
2558
|
}
|
|
2558
2559
|
if (registerDevice === true) {
|
|
2559
|
-
|
|
2560
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
|
|
2560
2561
|
} else {
|
|
2561
|
-
|
|
2562
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2562
2563
|
}
|
|
2563
2564
|
} else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName && device.connectionType === 'BLE') {
|
|
2564
2565
|
switch (device.deviceType) {
|
|
@@ -2566,16 +2567,16 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2566
2567
|
case 'Curtain3':
|
|
2567
2568
|
case 'Blind Tilt':
|
|
2568
2569
|
registerDevice = await this.registerCurtains(device);
|
|
2569
|
-
|
|
2570
|
+
this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
|
|
2570
2571
|
break;
|
|
2571
2572
|
default:
|
|
2572
2573
|
registerDevice = true;
|
|
2573
|
-
|
|
2574
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2574
2575
|
}
|
|
2575
2576
|
if (registerDevice === true) {
|
|
2576
|
-
|
|
2577
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
|
|
2577
2578
|
} else {
|
|
2578
|
-
|
|
2579
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2579
2580
|
}
|
|
2580
2581
|
} else if (!device.hide_device && device.connectionType === 'OpenAPI') {
|
|
2581
2582
|
switch (device.deviceType) {
|
|
@@ -2583,16 +2584,16 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2583
2584
|
case 'Curtain3':
|
|
2584
2585
|
case 'Blind Tilt':
|
|
2585
2586
|
registerDevice = await this.registerCurtains(device);
|
|
2586
|
-
|
|
2587
|
+
this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
|
|
2587
2588
|
break;
|
|
2588
2589
|
default:
|
|
2589
2590
|
registerDevice = true;
|
|
2590
|
-
|
|
2591
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2591
2592
|
}
|
|
2592
2593
|
if (registerDevice === true) {
|
|
2593
|
-
|
|
2594
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will display in HomeKit`);
|
|
2594
2595
|
} else {
|
|
2595
|
-
|
|
2596
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2596
2597
|
}
|
|
2597
2598
|
} else if (!device.hide_device && device.connectionType === 'Disabled') {
|
|
2598
2599
|
switch (device.deviceType) {
|
|
@@ -2600,22 +2601,22 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2600
2601
|
case 'Curtain3':
|
|
2601
2602
|
case 'Blind Tilt':
|
|
2602
2603
|
registerDevice = await this.registerCurtains(device);
|
|
2603
|
-
|
|
2604
|
+
this.debugWarnLog(`Device: ${device.deviceName} ${device.deviceType} registerDevice: ${registerDevice}`);
|
|
2604
2605
|
break;
|
|
2605
2606
|
default:
|
|
2606
2607
|
registerDevice = true;
|
|
2607
|
-
|
|
2608
|
+
this.debugWarnLog(`Device: ${device.deviceName} registerDevice: ${registerDevice}`);
|
|
2608
2609
|
}
|
|
2609
|
-
|
|
2610
|
+
this.debugWarnLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will continue to display in HomeKit`);
|
|
2610
2611
|
} else if (!device.connectionType && !device.hide_device) {
|
|
2611
2612
|
registerDevice = false;
|
|
2612
|
-
|
|
2613
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, will not display in HomeKit`);
|
|
2613
2614
|
} else if (device.hide_device) {
|
|
2614
2615
|
registerDevice = false;
|
|
2615
|
-
|
|
2616
|
+
this.debugErrorLog(`Device: ${device.deviceName} hide_device: ${device.hide_device}, will not display in HomeKit`);
|
|
2616
2617
|
} else {
|
|
2617
2618
|
registerDevice = false;
|
|
2618
|
-
|
|
2619
|
+
this.debugErrorLog(`Device: ${device.deviceName} connectionType: ${device.connectionType}, hide_device: `
|
|
2619
2620
|
+ `${device.hide_device}, will not display in HomeKit`);
|
|
2620
2621
|
}
|
|
2621
2622
|
return registerDevice;
|
|
@@ -2628,20 +2629,20 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2628
2629
|
* publish your TV as an external accessory.
|
|
2629
2630
|
*/
|
|
2630
2631
|
if (device.external) {
|
|
2631
|
-
|
|
2632
|
+
this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
|
|
2632
2633
|
this.externalAccessory(accessory);
|
|
2633
2634
|
} else {
|
|
2634
|
-
|
|
2635
|
+
this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
|
|
2635
2636
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
2636
2637
|
}
|
|
2637
2638
|
}
|
|
2638
2639
|
|
|
2639
2640
|
public async externalOrPlatform(device: device & devicesConfig, accessory: PlatformAccessory) {
|
|
2640
2641
|
if (device.external) {
|
|
2641
|
-
|
|
2642
|
-
|
|
2642
|
+
this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
|
|
2643
|
+
this.externalAccessory(accessory);
|
|
2643
2644
|
} else {
|
|
2644
|
-
|
|
2645
|
+
this.debugLog(`${accessory.displayName} External Accessory Mode: ${device.external}`);
|
|
2645
2646
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
2646
2647
|
}
|
|
2647
2648
|
}
|
|
@@ -2659,67 +2660,67 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2659
2660
|
async statusCode(statusCode: number): Promise<void> {
|
|
2660
2661
|
switch (statusCode) {
|
|
2661
2662
|
case 151:
|
|
2662
|
-
|
|
2663
|
+
this.errorLog(`Command not supported by this device type, statusCode: ${statusCode}, Submit Feature Request Here: ` +
|
|
2663
2664
|
'https://tinyurl.com/SwitchBotFeatureRequest');
|
|
2664
2665
|
break;
|
|
2665
2666
|
case 152:
|
|
2666
|
-
|
|
2667
|
+
this.errorLog(`Device not found, statusCode: ${statusCode}`);
|
|
2667
2668
|
break;
|
|
2668
2669
|
case 160:
|
|
2669
|
-
|
|
2670
|
+
this.errorLog(`Command is not supported, statusCode: ${statusCode}, Submit Bugs Here: https://tinyurl.com/SwitchBotBug`);
|
|
2670
2671
|
break;
|
|
2671
2672
|
case 161:
|
|
2672
|
-
|
|
2673
|
+
this.errorLog(`Device is offline, statusCode: ${statusCode}`);
|
|
2673
2674
|
break;
|
|
2674
2675
|
case 171:
|
|
2675
|
-
|
|
2676
|
+
this.errorLog(`is offline, statusCode: ${statusCode}`);
|
|
2676
2677
|
break;
|
|
2677
2678
|
case 190:
|
|
2678
|
-
|
|
2679
|
+
this.errorLog(`Requests reached the daily limit, statusCode: ${statusCode}`);
|
|
2679
2680
|
break;
|
|
2680
2681
|
case 100:
|
|
2681
|
-
|
|
2682
|
+
this.debugLog(`Command successfully sent, statusCode: ${statusCode}`);
|
|
2682
2683
|
break;
|
|
2683
2684
|
case 200:
|
|
2684
|
-
|
|
2685
|
+
this.debugLog(`Request successful, statusCode: ${statusCode}`);
|
|
2685
2686
|
break;
|
|
2686
2687
|
case 400:
|
|
2687
|
-
|
|
2688
|
+
this.errorLog('Bad Request, The client has issued an invalid request. This is commonly used to specify validation errors in a request '
|
|
2688
2689
|
+ `payload, statusCode: ${statusCode}`);
|
|
2689
2690
|
break;
|
|
2690
2691
|
case 401:
|
|
2691
|
-
|
|
2692
|
+
this.errorLog('Unauthorized, Authorization for the API is required, but the request has not been authenticated, '
|
|
2692
2693
|
+ `statusCode: ${statusCode}`);
|
|
2693
2694
|
break;
|
|
2694
2695
|
case 403:
|
|
2695
|
-
|
|
2696
|
+
this.errorLog('Forbidden, The request has been authenticated but does not have appropriate permissions, or a requested resource is not '
|
|
2696
2697
|
+ `found, statusCode: ${statusCode}`);
|
|
2697
2698
|
break;
|
|
2698
2699
|
case 404:
|
|
2699
|
-
|
|
2700
|
+
this.errorLog(`Not Found, Specifies the requested path does not exist, statusCode: ${statusCode}`);
|
|
2700
2701
|
break;
|
|
2701
2702
|
case 406:
|
|
2702
|
-
|
|
2703
|
+
this.errorLog('Not Acceptable, The client has requested a MIME type via the Accept header for a value not supported by the server, '
|
|
2703
2704
|
+ `statusCode: ${statusCode}`);
|
|
2704
2705
|
break;
|
|
2705
2706
|
case 415:
|
|
2706
|
-
|
|
2707
|
+
this.errorLog('Unsupported Media Type, The client has defined a contentType header that is not supported by the server, '
|
|
2707
2708
|
+ `statusCode: ${statusCode}`);
|
|
2708
2709
|
break;
|
|
2709
2710
|
case 422:
|
|
2710
|
-
|
|
2711
|
+
this.errorLog('Unprocessable Entity, The client has made a valid request, but the server cannot process it. This is often used for '
|
|
2711
2712
|
+ `APIs for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
2712
2713
|
break;
|
|
2713
2714
|
case 429:
|
|
2714
|
-
|
|
2715
|
+
this.errorLog('Too Many Requests, The client has exceeded the number of requests allowed for a given time window, '
|
|
2715
2716
|
+ `statusCode: ${statusCode}`);
|
|
2716
2717
|
break;
|
|
2717
2718
|
case 500:
|
|
2718
|
-
|
|
2719
|
+
this.errorLog('Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare, '
|
|
2719
2720
|
+ `statusCode: ${statusCode}`);
|
|
2720
2721
|
break;
|
|
2721
2722
|
default:
|
|
2722
|
-
|
|
2723
|
+
this.errorLog(`Unknown statusCode, statusCode: ${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
|
|
2723
2724
|
}
|
|
2724
2725
|
}
|
|
2725
2726
|
|
|
@@ -2735,13 +2736,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2735
2736
|
if (statusCode === 200 || statusCode === 100) {
|
|
2736
2737
|
return { body, statusCode };
|
|
2737
2738
|
} else {
|
|
2738
|
-
|
|
2739
|
+
this.debugLog(`Received status code: ${statusCode}`);
|
|
2739
2740
|
}
|
|
2740
2741
|
} catch (error: any) {
|
|
2741
|
-
|
|
2742
|
+
this.errorLog(`Error making request: ${error.message}`);
|
|
2742
2743
|
}
|
|
2743
2744
|
retryCount++;
|
|
2744
|
-
|
|
2745
|
+
this.debugLog(`Retry attempt ${retryCount} of ${maxRetries}`);
|
|
2745
2746
|
await sleep(delayBetweenRetries);
|
|
2746
2747
|
}
|
|
2747
2748
|
return { body: null, statusCode: -1 };
|
|
@@ -2753,10 +2754,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2753
2754
|
try {
|
|
2754
2755
|
const SwitchBot = (await import('node-switchbot')).SwitchBot;
|
|
2755
2756
|
queueScheduler.schedule(() => (switchbot = new SwitchBot()));
|
|
2756
|
-
await await this.debugLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}`);
|
|
2757
2757
|
} catch (e: any) {
|
|
2758
2758
|
switchbot = false;
|
|
2759
|
-
|
|
2759
|
+
this.errorLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}, Error: ${e}`);
|
|
2760
2760
|
}
|
|
2761
2761
|
return switchbot;
|
|
2762
2762
|
}
|
|
@@ -2768,7 +2768,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2768
2768
|
'utf-8',
|
|
2769
2769
|
),
|
|
2770
2770
|
);
|
|
2771
|
-
|
|
2771
|
+
this.debugLog(`Plugin Version: ${json.version}`);
|
|
2772
2772
|
this.version = json.version;
|
|
2773
2773
|
}
|
|
2774
2774
|
|
|
@@ -2804,7 +2804,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2804
2804
|
platformConfig.delayBetweenRetries = this.delayBetweenRetries / 1000;
|
|
2805
2805
|
}
|
|
2806
2806
|
if (Object.entries(platformConfig).length !== 0) {
|
|
2807
|
-
|
|
2807
|
+
this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
|
|
2808
2808
|
}
|
|
2809
2809
|
this.platformConfig = platformConfig;
|
|
2810
2810
|
}
|
|
@@ -2814,13 +2814,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2814
2814
|
this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
|
|
2815
2815
|
if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
|
|
2816
2816
|
this.platformLogging = this.config.options.logging;
|
|
2817
|
-
|
|
2817
|
+
this.debugWarnLog(`Using Config Logging: ${this.platformLogging}`);
|
|
2818
2818
|
} else if (this.debugMode) {
|
|
2819
2819
|
this.platformLogging = 'debugMode';
|
|
2820
|
-
|
|
2820
|
+
this.debugWarnLog(`Using ${this.platformLogging} Logging`);
|
|
2821
2821
|
} else {
|
|
2822
2822
|
this.platformLogging = 'standard';
|
|
2823
|
-
|
|
2823
|
+
this.debugWarnLog(`Using ${this.platformLogging} Logging`);
|
|
2824
2824
|
}
|
|
2825
2825
|
}
|
|
2826
2826
|
|
|
@@ -2828,56 +2828,56 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2828
2828
|
* If device level logging is turned on, log to log.warn
|
|
2829
2829
|
* Otherwise send debug logs to log.debug
|
|
2830
2830
|
*/
|
|
2831
|
-
|
|
2832
|
-
if (
|
|
2831
|
+
infoLog(...log: any[]): void {
|
|
2832
|
+
if (this.enablingPlatformLogging()) {
|
|
2833
2833
|
this.log.info(String(...log));
|
|
2834
2834
|
}
|
|
2835
2835
|
}
|
|
2836
2836
|
|
|
2837
|
-
|
|
2838
|
-
if (
|
|
2837
|
+
successLog(...log: any[]): void {
|
|
2838
|
+
if (this.enablingPlatformLogging()) {
|
|
2839
2839
|
this.log.success(String(...log));
|
|
2840
2840
|
}
|
|
2841
2841
|
}
|
|
2842
2842
|
|
|
2843
|
-
|
|
2844
|
-
if (
|
|
2843
|
+
debugSuccessLog(...log: any[]): void {
|
|
2844
|
+
if (this.enablingPlatformLogging()) {
|
|
2845
2845
|
if (this.platformLogging?.includes('debug')) {
|
|
2846
2846
|
this.log.success('[DEBUG]', String(...log));
|
|
2847
2847
|
}
|
|
2848
2848
|
}
|
|
2849
2849
|
}
|
|
2850
2850
|
|
|
2851
|
-
|
|
2852
|
-
if (
|
|
2851
|
+
warnLog(...log: any[]): void {
|
|
2852
|
+
if (this.enablingPlatformLogging()) {
|
|
2853
2853
|
this.log.warn(String(...log));
|
|
2854
2854
|
}
|
|
2855
2855
|
}
|
|
2856
2856
|
|
|
2857
|
-
|
|
2858
|
-
if (
|
|
2857
|
+
debugWarnLog(...log: any[]): void {
|
|
2858
|
+
if (this.enablingPlatformLogging()) {
|
|
2859
2859
|
if (this.platformLogging?.includes('debug')) {
|
|
2860
2860
|
this.log.warn('[DEBUG]', String(...log));
|
|
2861
2861
|
}
|
|
2862
2862
|
}
|
|
2863
2863
|
}
|
|
2864
2864
|
|
|
2865
|
-
|
|
2866
|
-
if (
|
|
2865
|
+
errorLog(...log: any[]): void {
|
|
2866
|
+
if (this.enablingPlatformLogging()) {
|
|
2867
2867
|
this.log.error(String(...log));
|
|
2868
2868
|
}
|
|
2869
2869
|
}
|
|
2870
2870
|
|
|
2871
|
-
|
|
2872
|
-
if (
|
|
2871
|
+
debugErrorLog(...log: any[]): void {
|
|
2872
|
+
if (this.enablingPlatformLogging()) {
|
|
2873
2873
|
if (this.platformLogging?.includes('debug')) {
|
|
2874
2874
|
this.log.error('[DEBUG]', String(...log));
|
|
2875
2875
|
}
|
|
2876
2876
|
}
|
|
2877
2877
|
}
|
|
2878
2878
|
|
|
2879
|
-
|
|
2880
|
-
if (
|
|
2879
|
+
debugLog(...log: any[]): void {
|
|
2880
|
+
if (this.enablingPlatformLogging()) {
|
|
2881
2881
|
if (this.platformLogging === 'debugMode') {
|
|
2882
2882
|
this.log.debug(String(...log));
|
|
2883
2883
|
} else if (this.platformLogging === 'debug') {
|
|
@@ -2886,7 +2886,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2886
2886
|
}
|
|
2887
2887
|
}
|
|
2888
2888
|
|
|
2889
|
-
|
|
2889
|
+
enablingPlatformLogging(): boolean {
|
|
2890
2890
|
return this.platformLogging?.includes('debug') || this.platformLogging === 'standard';
|
|
2891
2891
|
}
|
|
2892
2892
|
}
|