@switchbot/homebridge-switchbot 2.2.2-beta.24 → 2.2.2-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -3
- package/config.schema.json +9 -11
- package/dist/irdevice/airconditioner.d.ts +6 -6
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +39 -35
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +8 -8
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +29 -29
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +4 -4
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +20 -24
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +4 -4
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +22 -26
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +4 -4
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +20 -20
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +4 -4
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +20 -24
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +6 -6
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +25 -29
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +4 -4
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +20 -24
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +4 -4
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +26 -31
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +0 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +29 -35
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +8 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +5 -5
- package/src/irdevice/airconditioner.ts +43 -39
- package/src/irdevice/airpurifier.ts +34 -33
- package/src/irdevice/camera.ts +23 -26
- package/src/irdevice/fan.ts +25 -28
- package/src/irdevice/light.ts +23 -22
- package/src/irdevice/other.ts +23 -26
- package/src/irdevice/tv.ts +30 -33
- package/src/irdevice/vacuumcleaner.ts +23 -26
- package/src/irdevice/waterheater.ts +28 -32
- package/src/platform.ts +28 -34
- package/src/settings.ts +11 -5
|
@@ -5,7 +5,6 @@ import superStringify from 'super-stringify';
|
|
|
5
5
|
import { SwitchBotPlatform } from '../platform';
|
|
6
6
|
import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
|
|
7
7
|
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
8
|
-
const version = process.env.npm_package_version;
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Platform Accessory
|
|
@@ -20,8 +19,8 @@ export class WaterHeater {
|
|
|
20
19
|
Active!: CharacteristicValue;
|
|
21
20
|
|
|
22
21
|
// Config
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
disablePushOn?: boolean;
|
|
23
|
+
disablePushOff?: boolean;
|
|
25
24
|
deviceLogging!: string;
|
|
26
25
|
|
|
27
26
|
constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
|
|
@@ -29,8 +28,8 @@ export class WaterHeater {
|
|
|
29
28
|
this.logs({ device });
|
|
30
29
|
this.config({ device });
|
|
31
30
|
this.context();
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
31
|
+
this.disablePushOnChanges({ device });
|
|
32
|
+
this.disablePushOffChanges({ device });
|
|
34
33
|
|
|
35
34
|
// set accessory information
|
|
36
35
|
accessory
|
|
@@ -64,18 +63,15 @@ export class WaterHeater {
|
|
|
64
63
|
|
|
65
64
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
66
65
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} else {
|
|
66
|
+
|
|
67
|
+
this.Active = value;
|
|
68
|
+
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
71
69
|
await this.pushWaterHeaterOnChanges();
|
|
72
70
|
this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.IN_USE);
|
|
71
|
+
} else {
|
|
72
|
+
await this.pushWaterHeaterOffChanges();
|
|
73
|
+
this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.NOT_IN_USE);
|
|
73
74
|
}
|
|
74
|
-
/**
|
|
75
|
-
* pushWaterHeaterOnChanges and pushWaterHeaterOffChanges above assume they are measuring the state of the accessory BEFORE
|
|
76
|
-
* they are updated, so we are only updating the accessory state after calling the above.
|
|
77
|
-
*/
|
|
78
|
-
this.Active = value;
|
|
79
75
|
}
|
|
80
76
|
|
|
81
77
|
/**
|
|
@@ -86,8 +82,8 @@ export class WaterHeater {
|
|
|
86
82
|
*/
|
|
87
83
|
async pushWaterHeaterOnChanges(): Promise<void> {
|
|
88
84
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushWaterHeaterOnChanges Active: ${this.Active},`
|
|
89
|
-
+ `
|
|
90
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
85
|
+
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
86
|
+
if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
91
87
|
const commandType: string = await this.commandType();
|
|
92
88
|
const command: string = await this.commandOn();
|
|
93
89
|
const body = superStringify({
|
|
@@ -101,8 +97,8 @@ export class WaterHeater {
|
|
|
101
97
|
|
|
102
98
|
async pushWaterHeaterOffChanges(): Promise<void> {
|
|
103
99
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushWaterHeaterOffChanges Active: ${this.Active},`
|
|
104
|
-
+ `
|
|
105
|
-
if (this.Active === this.platform.Characteristic.Active.
|
|
100
|
+
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
101
|
+
if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
106
102
|
const commandType: string = await this.commandType();
|
|
107
103
|
const command: string = await this.commandOff();
|
|
108
104
|
const body = superStringify({
|
|
@@ -180,19 +176,19 @@ export class WaterHeater {
|
|
|
180
176
|
}
|
|
181
177
|
}
|
|
182
178
|
|
|
183
|
-
async
|
|
184
|
-
if (device.
|
|
185
|
-
this.
|
|
179
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
180
|
+
if (device.disablePushOn === undefined) {
|
|
181
|
+
this.disablePushOn = false;
|
|
186
182
|
} else {
|
|
187
|
-
this.
|
|
183
|
+
this.disablePushOn = device.disablePushOn;
|
|
188
184
|
}
|
|
189
185
|
}
|
|
190
186
|
|
|
191
|
-
async
|
|
192
|
-
if (device.
|
|
193
|
-
this.
|
|
187
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
188
|
+
if (device.disablePushOff === undefined) {
|
|
189
|
+
this.disablePushOff = false;
|
|
194
190
|
} else {
|
|
195
|
-
this.
|
|
191
|
+
this.disablePushOff = device.disablePushOff;
|
|
196
192
|
}
|
|
197
193
|
}
|
|
198
194
|
|
|
@@ -268,13 +264,13 @@ export class WaterHeater {
|
|
|
268
264
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
269
265
|
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
270
266
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
271
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} version: ${version}`);
|
|
267
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
272
268
|
if (accessory.context.FirmwareRevision) {
|
|
273
269
|
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
274
270
|
} else if (device.firmware) {
|
|
275
271
|
FirmwareRevision = device.firmware;
|
|
276
272
|
} else {
|
|
277
|
-
FirmwareRevision = version!;
|
|
273
|
+
FirmwareRevision = this.platform.version!;
|
|
278
274
|
}
|
|
279
275
|
return FirmwareRevision;
|
|
280
276
|
}
|
|
@@ -310,11 +306,11 @@ export class WaterHeater {
|
|
|
310
306
|
if (device.customize !== undefined) {
|
|
311
307
|
config['customize'] = device.customize;
|
|
312
308
|
}
|
|
313
|
-
if (device.
|
|
314
|
-
config['
|
|
309
|
+
if (device.disablePushOn !== undefined) {
|
|
310
|
+
config['disablePushOn'] = device.disablePushOn;
|
|
315
311
|
}
|
|
316
|
-
if (device.
|
|
317
|
-
config['
|
|
312
|
+
if (device.disablePushOff !== undefined) {
|
|
313
|
+
config['disablePushOff'] = device.disablePushOff;
|
|
318
314
|
}
|
|
319
315
|
if (Object.entries(config).length !== 0) {
|
|
320
316
|
this.infoLog({ log: [`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`] });
|
package/src/platform.ts
CHANGED
|
@@ -471,6 +471,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
private createIRDevice(device: irdevice & devicesConfig) {
|
|
474
|
+
if (device.connectionType === undefined) {
|
|
475
|
+
device.connectionType = 'OpenAPI';
|
|
476
|
+
}
|
|
474
477
|
switch (device.remoteType) {
|
|
475
478
|
case 'TV':
|
|
476
479
|
case 'DIY TV':
|
|
@@ -485,7 +488,12 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
485
488
|
case 'Speaker':
|
|
486
489
|
case 'DIY Speaker':
|
|
487
490
|
this.debugLog(`Discovered ${device.remoteType}: ${device.deviceId}`);
|
|
488
|
-
|
|
491
|
+
if (device.external === undefined) {
|
|
492
|
+
device.external = true;
|
|
493
|
+
this.createTV(device);
|
|
494
|
+
} else {
|
|
495
|
+
this.createTV(device);
|
|
496
|
+
}
|
|
489
497
|
break;
|
|
490
498
|
case 'Fan':
|
|
491
499
|
case 'DIY Fan':
|
|
@@ -1233,7 +1241,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1233
1241
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1234
1242
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1235
1243
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1236
|
-
existingAccessory.context.connectionType =
|
|
1244
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1237
1245
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1238
1246
|
// create the accessory handler for the restored accessory
|
|
1239
1247
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1255,7 +1263,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1255
1263
|
accessory.context.deviceID = device.deviceId;
|
|
1256
1264
|
accessory.context.firmwareRevision = device.firmware;
|
|
1257
1265
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1258
|
-
accessory.context.connectionType =
|
|
1266
|
+
accessory.context.connectionType = device.connectionType;
|
|
1259
1267
|
// create the accessory handler for the newly create accessory
|
|
1260
1268
|
// this is imported from `platformAccessory.ts`
|
|
1261
1269
|
new TV(this, accessory, device);
|
|
@@ -1285,7 +1293,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1285
1293
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1286
1294
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1287
1295
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1288
|
-
existingAccessory.context.connectionType =
|
|
1296
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1289
1297
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1290
1298
|
// create the accessory handler for the restored accessory
|
|
1291
1299
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1310,7 +1318,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1310
1318
|
accessory.context.deviceID = device.deviceId;
|
|
1311
1319
|
accessory.context.firmwareRevision = device.firmware;
|
|
1312
1320
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1313
|
-
accessory.context.connectionType =
|
|
1321
|
+
accessory.context.connectionType = device.connectionType;
|
|
1314
1322
|
// create the accessory handler for the newly create accessory
|
|
1315
1323
|
// this is imported from `platformAccessory.ts`
|
|
1316
1324
|
new Fan(this, accessory, device);
|
|
@@ -1341,7 +1349,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1341
1349
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1342
1350
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1343
1351
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1344
|
-
existingAccessory.context.connectionType =
|
|
1352
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1345
1353
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1346
1354
|
// create the accessory handler for the restored accessory
|
|
1347
1355
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1366,7 +1374,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1366
1374
|
accessory.context.deviceID = device.deviceId;
|
|
1367
1375
|
accessory.context.firmwareRevision = device.firmware;
|
|
1368
1376
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1369
|
-
accessory.context.connectionType =
|
|
1377
|
+
accessory.context.connectionType = device.connectionType;
|
|
1370
1378
|
// create the accessory handler for the newly create accessory
|
|
1371
1379
|
// this is imported from `platformAccessory.ts`
|
|
1372
1380
|
new Light(this, accessory, device);
|
|
@@ -1397,7 +1405,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1397
1405
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1398
1406
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1399
1407
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1400
|
-
existingAccessory.context.connectionType =
|
|
1408
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1401
1409
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1402
1410
|
// create the accessory handler for the restored accessory
|
|
1403
1411
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1422,7 +1430,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1422
1430
|
accessory.context.deviceID = device.deviceId;
|
|
1423
1431
|
accessory.context.firmwareRevision = device.firmware;
|
|
1424
1432
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1425
|
-
accessory.context.connectionType =
|
|
1433
|
+
accessory.context.connectionType = device.connectionType;
|
|
1426
1434
|
// create the accessory handler for the newly create accessory
|
|
1427
1435
|
// this is imported from `platformAccessory.ts`
|
|
1428
1436
|
new AirConditioner(this, accessory, device);
|
|
@@ -1453,7 +1461,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1453
1461
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1454
1462
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1455
1463
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1456
|
-
existingAccessory.context.connectionType =
|
|
1464
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1457
1465
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1458
1466
|
// create the accessory handler for the restored accessory
|
|
1459
1467
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1478,7 +1486,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1478
1486
|
accessory.context.deviceID = device.deviceId;
|
|
1479
1487
|
accessory.context.firmwareRevision = device.firmware;
|
|
1480
1488
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1481
|
-
accessory.context.connectionType =
|
|
1489
|
+
accessory.context.connectionType = device.connectionType;
|
|
1482
1490
|
// create the accessory handler for the newly create accessory
|
|
1483
1491
|
// this is imported from `platformAccessory.ts`
|
|
1484
1492
|
new AirPurifier(this, accessory, device);
|
|
@@ -1509,7 +1517,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1509
1517
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1510
1518
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1511
1519
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1512
|
-
existingAccessory.context.connectionType =
|
|
1520
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1513
1521
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1514
1522
|
// create the accessory handler for the restored accessory
|
|
1515
1523
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1534,7 +1542,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1534
1542
|
accessory.context.deviceID = device.deviceId;
|
|
1535
1543
|
accessory.context.firmwareRevision = device.firmware;
|
|
1536
1544
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1537
|
-
accessory.context.connectionType =
|
|
1545
|
+
accessory.context.connectionType = device.connectionType;
|
|
1538
1546
|
// create the accessory handler for the newly create accessory
|
|
1539
1547
|
// this is imported from `platformAccessory.ts`
|
|
1540
1548
|
new WaterHeater(this, accessory, device);
|
|
@@ -1565,7 +1573,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1565
1573
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1566
1574
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1567
1575
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1568
|
-
existingAccessory.context.connectionType =
|
|
1576
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1569
1577
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1570
1578
|
// create the accessory handler for the restored accessory
|
|
1571
1579
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1590,7 +1598,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1590
1598
|
accessory.context.deviceID = device.deviceId;
|
|
1591
1599
|
accessory.context.firmwareRevision = device.firmware;
|
|
1592
1600
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1593
|
-
accessory.context.connectionType =
|
|
1601
|
+
accessory.context.connectionType = device.connectionType;
|
|
1594
1602
|
// create the accessory handler for the newly create accessory
|
|
1595
1603
|
// this is imported from `platformAccessory.ts`
|
|
1596
1604
|
new VacuumCleaner(this, accessory, device);
|
|
@@ -1621,7 +1629,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1621
1629
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1622
1630
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1623
1631
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1624
|
-
existingAccessory.context.connectionType =
|
|
1632
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1625
1633
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1626
1634
|
// create the accessory handler for the restored accessory
|
|
1627
1635
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1646,7 +1654,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1646
1654
|
accessory.context.deviceID = device.deviceId;
|
|
1647
1655
|
accessory.context.firmwareRevision = device.firmware;
|
|
1648
1656
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1649
|
-
accessory.context.connectionType =
|
|
1657
|
+
accessory.context.connectionType = device.connectionType;
|
|
1650
1658
|
// create the accessory handler for the newly create accessory
|
|
1651
1659
|
// this is imported from `platformAccessory.ts`
|
|
1652
1660
|
new Camera(this, accessory, device);
|
|
@@ -1677,7 +1685,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1677
1685
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1678
1686
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1679
1687
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1680
|
-
existingAccessory.context.connectionType =
|
|
1688
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1681
1689
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1682
1690
|
// create the accessory handler for the restored accessory
|
|
1683
1691
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1702,7 +1710,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1702
1710
|
accessory.context.deviceID = device.deviceId;
|
|
1703
1711
|
accessory.context.firmwareRevision = device.firmware;
|
|
1704
1712
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1705
|
-
accessory.context.connectionType =
|
|
1713
|
+
accessory.context.connectionType = device.connectionType;
|
|
1706
1714
|
// create the accessory handler for the newly create accessory
|
|
1707
1715
|
// this is imported from `platformAccessory.ts`
|
|
1708
1716
|
new Others(this, accessory, device);
|
|
@@ -1753,16 +1761,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1753
1761
|
return registerCurtain;
|
|
1754
1762
|
}
|
|
1755
1763
|
|
|
1756
|
-
async connectionTypeIR(device: device & irDevicesConfig): Promise<any> {
|
|
1757
|
-
let connectionType: string;
|
|
1758
|
-
if (!device.connectionType && device.remoteType) {
|
|
1759
|
-
connectionType = 'OpenAPI';
|
|
1760
|
-
} else {
|
|
1761
|
-
connectionType = device.connectionType!;
|
|
1762
|
-
}
|
|
1763
|
-
return connectionType;
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
1764
|
async connectionType(device: device & devicesConfig): Promise<any> {
|
|
1767
1765
|
let connectionType: string;
|
|
1768
1766
|
if (!device.connectionType && this.config.credentials?.token && this.config.credentials.secret) {
|
|
@@ -1833,11 +1831,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1833
1831
|
* Only one TV can exist per bridge, to bypass this limitation, you should
|
|
1834
1832
|
* publish your TV as an external accessory.
|
|
1835
1833
|
*/
|
|
1836
|
-
if (device.external
|
|
1837
|
-
device.external = true;
|
|
1838
|
-
this.debugWarnLog(`${accessory.displayName} External TV Accessory Mode`);
|
|
1839
|
-
this.externalAccessory(accessory);
|
|
1840
|
-
} else if (device.external) {
|
|
1834
|
+
if (device.external) {
|
|
1841
1835
|
this.debugWarnLog(`${accessory.displayName} External Accessory Mode`);
|
|
1842
1836
|
this.externalAccessory(accessory);
|
|
1843
1837
|
} else {
|
package/src/settings.ts
CHANGED
|
@@ -140,8 +140,8 @@ export interface irDevicesConfig extends irdevice {
|
|
|
140
140
|
customOn?: string;
|
|
141
141
|
customOff?: string;
|
|
142
142
|
customize?: boolean;
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
disablePushOn?: boolean;
|
|
144
|
+
disablePushOff?: boolean;
|
|
145
145
|
irfan?: irfan;
|
|
146
146
|
irair?: irair;
|
|
147
147
|
irpur?: Record<any, any>;
|
|
@@ -169,6 +169,12 @@ export type other = {
|
|
|
169
169
|
deviceType?: string;
|
|
170
170
|
};
|
|
171
171
|
|
|
172
|
+
export type body = {
|
|
173
|
+
command: string;
|
|
174
|
+
parameter: string;
|
|
175
|
+
commandType: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
172
178
|
//a list of physical devices.
|
|
173
179
|
export type deviceList = {
|
|
174
180
|
device: Array<device>;
|
|
@@ -359,7 +365,7 @@ export type switchbot = {
|
|
|
359
365
|
wait: (arg0: number) => any;
|
|
360
366
|
};
|
|
361
367
|
|
|
362
|
-
export function rgb2hs(r, g, b) {
|
|
368
|
+
export function rgb2hs(r: any, g: any, b: any) {
|
|
363
369
|
/*
|
|
364
370
|
Credit:
|
|
365
371
|
https://github.com/WickyNilliams/pure-color
|
|
@@ -394,7 +400,7 @@ export function rgb2hs(r, g, b) {
|
|
|
394
400
|
return [Math.round(h), Math.round(s)];
|
|
395
401
|
}
|
|
396
402
|
|
|
397
|
-
export function hs2rgb(h, s) {
|
|
403
|
+
export function hs2rgb(h: any, s: any) {
|
|
398
404
|
/*
|
|
399
405
|
Credit:
|
|
400
406
|
https://github.com/WickyNilliams/pure-color
|
|
@@ -437,7 +443,7 @@ export function hs2rgb(h, s) {
|
|
|
437
443
|
return [Math.round(rgb[0]), Math.round(rgb[1]), Math.round(rgb[2])];
|
|
438
444
|
}
|
|
439
445
|
|
|
440
|
-
export function k2rgb(k) {
|
|
446
|
+
export function k2rgb(k: number) {
|
|
441
447
|
// Set kelvin to nearest 100, between 2000 and 7100
|
|
442
448
|
k = Math.round(k / 100) * 100;
|
|
443
449
|
k = Math.max(Math.min(k, 7100), 2000);
|