@switchbot/homebridge-switchbot 2.2.2-beta.25 → 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 +21 -28
- 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 +21 -28
- 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':
|
|
@@ -1238,7 +1241,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1238
1241
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1239
1242
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1240
1243
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1241
|
-
existingAccessory.context.connectionType =
|
|
1244
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1242
1245
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1243
1246
|
// create the accessory handler for the restored accessory
|
|
1244
1247
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1260,7 +1263,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1260
1263
|
accessory.context.deviceID = device.deviceId;
|
|
1261
1264
|
accessory.context.firmwareRevision = device.firmware;
|
|
1262
1265
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1263
|
-
accessory.context.connectionType =
|
|
1266
|
+
accessory.context.connectionType = device.connectionType;
|
|
1264
1267
|
// create the accessory handler for the newly create accessory
|
|
1265
1268
|
// this is imported from `platformAccessory.ts`
|
|
1266
1269
|
new TV(this, accessory, device);
|
|
@@ -1290,7 +1293,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1290
1293
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1291
1294
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1292
1295
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1293
|
-
existingAccessory.context.connectionType =
|
|
1296
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1294
1297
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1295
1298
|
// create the accessory handler for the restored accessory
|
|
1296
1299
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1315,7 +1318,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1315
1318
|
accessory.context.deviceID = device.deviceId;
|
|
1316
1319
|
accessory.context.firmwareRevision = device.firmware;
|
|
1317
1320
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1318
|
-
accessory.context.connectionType =
|
|
1321
|
+
accessory.context.connectionType = device.connectionType;
|
|
1319
1322
|
// create the accessory handler for the newly create accessory
|
|
1320
1323
|
// this is imported from `platformAccessory.ts`
|
|
1321
1324
|
new Fan(this, accessory, device);
|
|
@@ -1346,7 +1349,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1346
1349
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1347
1350
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1348
1351
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1349
|
-
existingAccessory.context.connectionType =
|
|
1352
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1350
1353
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1351
1354
|
// create the accessory handler for the restored accessory
|
|
1352
1355
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1371,7 +1374,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1371
1374
|
accessory.context.deviceID = device.deviceId;
|
|
1372
1375
|
accessory.context.firmwareRevision = device.firmware;
|
|
1373
1376
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1374
|
-
accessory.context.connectionType =
|
|
1377
|
+
accessory.context.connectionType = device.connectionType;
|
|
1375
1378
|
// create the accessory handler for the newly create accessory
|
|
1376
1379
|
// this is imported from `platformAccessory.ts`
|
|
1377
1380
|
new Light(this, accessory, device);
|
|
@@ -1402,7 +1405,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1402
1405
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1403
1406
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1404
1407
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1405
|
-
existingAccessory.context.connectionType =
|
|
1408
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1406
1409
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1407
1410
|
// create the accessory handler for the restored accessory
|
|
1408
1411
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1427,7 +1430,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1427
1430
|
accessory.context.deviceID = device.deviceId;
|
|
1428
1431
|
accessory.context.firmwareRevision = device.firmware;
|
|
1429
1432
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1430
|
-
accessory.context.connectionType =
|
|
1433
|
+
accessory.context.connectionType = device.connectionType;
|
|
1431
1434
|
// create the accessory handler for the newly create accessory
|
|
1432
1435
|
// this is imported from `platformAccessory.ts`
|
|
1433
1436
|
new AirConditioner(this, accessory, device);
|
|
@@ -1458,7 +1461,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1458
1461
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1459
1462
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1460
1463
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1461
|
-
existingAccessory.context.connectionType =
|
|
1464
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1462
1465
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1463
1466
|
// create the accessory handler for the restored accessory
|
|
1464
1467
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1483,7 +1486,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1483
1486
|
accessory.context.deviceID = device.deviceId;
|
|
1484
1487
|
accessory.context.firmwareRevision = device.firmware;
|
|
1485
1488
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1486
|
-
accessory.context.connectionType =
|
|
1489
|
+
accessory.context.connectionType = device.connectionType;
|
|
1487
1490
|
// create the accessory handler for the newly create accessory
|
|
1488
1491
|
// this is imported from `platformAccessory.ts`
|
|
1489
1492
|
new AirPurifier(this, accessory, device);
|
|
@@ -1514,7 +1517,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1514
1517
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1515
1518
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1516
1519
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1517
|
-
existingAccessory.context.connectionType =
|
|
1520
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1518
1521
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1519
1522
|
// create the accessory handler for the restored accessory
|
|
1520
1523
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1539,7 +1542,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1539
1542
|
accessory.context.deviceID = device.deviceId;
|
|
1540
1543
|
accessory.context.firmwareRevision = device.firmware;
|
|
1541
1544
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1542
|
-
accessory.context.connectionType =
|
|
1545
|
+
accessory.context.connectionType = device.connectionType;
|
|
1543
1546
|
// create the accessory handler for the newly create accessory
|
|
1544
1547
|
// this is imported from `platformAccessory.ts`
|
|
1545
1548
|
new WaterHeater(this, accessory, device);
|
|
@@ -1570,7 +1573,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1570
1573
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1571
1574
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1572
1575
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1573
|
-
existingAccessory.context.connectionType =
|
|
1576
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1574
1577
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1575
1578
|
// create the accessory handler for the restored accessory
|
|
1576
1579
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1595,7 +1598,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1595
1598
|
accessory.context.deviceID = device.deviceId;
|
|
1596
1599
|
accessory.context.firmwareRevision = device.firmware;
|
|
1597
1600
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1598
|
-
accessory.context.connectionType =
|
|
1601
|
+
accessory.context.connectionType = device.connectionType;
|
|
1599
1602
|
// create the accessory handler for the newly create accessory
|
|
1600
1603
|
// this is imported from `platformAccessory.ts`
|
|
1601
1604
|
new VacuumCleaner(this, accessory, device);
|
|
@@ -1626,7 +1629,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1626
1629
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1627
1630
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1628
1631
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1629
|
-
existingAccessory.context.connectionType =
|
|
1632
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1630
1633
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1631
1634
|
// create the accessory handler for the restored accessory
|
|
1632
1635
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1651,7 +1654,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1651
1654
|
accessory.context.deviceID = device.deviceId;
|
|
1652
1655
|
accessory.context.firmwareRevision = device.firmware;
|
|
1653
1656
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1654
|
-
accessory.context.connectionType =
|
|
1657
|
+
accessory.context.connectionType = device.connectionType;
|
|
1655
1658
|
// create the accessory handler for the newly create accessory
|
|
1656
1659
|
// this is imported from `platformAccessory.ts`
|
|
1657
1660
|
new Camera(this, accessory, device);
|
|
@@ -1682,7 +1685,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1682
1685
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1683
1686
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1684
1687
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1685
|
-
existingAccessory.context.connectionType =
|
|
1688
|
+
existingAccessory.context.connectionType = device.connectionType;
|
|
1686
1689
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1687
1690
|
// create the accessory handler for the restored accessory
|
|
1688
1691
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1707,7 +1710,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1707
1710
|
accessory.context.deviceID = device.deviceId;
|
|
1708
1711
|
accessory.context.firmwareRevision = device.firmware;
|
|
1709
1712
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1710
|
-
accessory.context.connectionType =
|
|
1713
|
+
accessory.context.connectionType = device.connectionType;
|
|
1711
1714
|
// create the accessory handler for the newly create accessory
|
|
1712
1715
|
// this is imported from `platformAccessory.ts`
|
|
1713
1716
|
new Others(this, accessory, device);
|
|
@@ -1758,16 +1761,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1758
1761
|
return registerCurtain;
|
|
1759
1762
|
}
|
|
1760
1763
|
|
|
1761
|
-
async connectionTypeIR(device: device & irDevicesConfig): Promise<any> {
|
|
1762
|
-
let connectionType: string;
|
|
1763
|
-
if (!device.connectionType && device.remoteType) {
|
|
1764
|
-
connectionType = 'OpenAPI';
|
|
1765
|
-
} else {
|
|
1766
|
-
connectionType = device.connectionType!;
|
|
1767
|
-
}
|
|
1768
|
-
return connectionType;
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
1764
|
async connectionType(device: device & devicesConfig): Promise<any> {
|
|
1772
1765
|
let connectionType: string;
|
|
1773
1766
|
if (!device.connectionType && this.config.credentials?.token && this.config.credentials.secret) {
|
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);
|