@switchbot/homebridge-switchbot 2.0.0-beta.36 → 2.0.0-beta.38
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 +3 -0
- package/README.md +2 -0
- package/dist/device/ceilinglight.d.ts +137 -0
- package/dist/device/ceilinglight.d.ts.map +1 -0
- package/dist/device/ceilinglight.js +1127 -0
- package/dist/device/ceilinglight.js.map +1 -0
- package/dist/platform.d.ts +1 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +118 -20
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +5 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/device/ceilinglight.ts +1208 -0
- package/src/platform.ts +121 -20
- package/src/settings.ts +6 -0
package/src/platform.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Contact } from './device/contact';
|
|
|
7
7
|
import { Curtain } from './device/curtain';
|
|
8
8
|
import { MeterPlus } from './device/meterplus';
|
|
9
9
|
import { ColorBulb } from './device/colorbulb';
|
|
10
|
+
import { CeilingLight } from './device/ceilinglight';
|
|
10
11
|
import { StripLight } from './device/striplight';
|
|
11
12
|
import { Humidifier } from './device/humidifier';
|
|
12
13
|
import { TV } from './irdevice/tv';
|
|
@@ -468,6 +469,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
468
469
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
469
470
|
this.createColorBulb(device);
|
|
470
471
|
break;
|
|
472
|
+
case 'Ceiling Light':
|
|
473
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
474
|
+
this.createCeilingLight(device);
|
|
475
|
+
break;
|
|
471
476
|
case 'Strip Light':
|
|
472
477
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
473
478
|
this.createStripLight(device);
|
|
@@ -576,7 +581,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
576
581
|
}
|
|
577
582
|
} else if (await this.registerDevice(device)) {
|
|
578
583
|
// the accessory does not yet exist, so we need to create it
|
|
579
|
-
|
|
584
|
+
if (!device.external) {
|
|
585
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
586
|
+
}
|
|
580
587
|
|
|
581
588
|
// create a new accessory
|
|
582
589
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -632,7 +639,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
632
639
|
}
|
|
633
640
|
} else if (await this.registerDevice(device)) {
|
|
634
641
|
// the accessory does not yet exist, so we need to create it
|
|
635
|
-
|
|
642
|
+
if (!device.external) {
|
|
643
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
644
|
+
}
|
|
636
645
|
|
|
637
646
|
this.debugLog(superStringify(device.bot?.mode));
|
|
638
647
|
|
|
@@ -689,7 +698,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
689
698
|
}
|
|
690
699
|
} else if (await this.registerDevice(device)) {
|
|
691
700
|
// the accessory does not yet exist, so we need to create it
|
|
692
|
-
|
|
701
|
+
if (!device.external) {
|
|
702
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
703
|
+
}
|
|
693
704
|
|
|
694
705
|
// create a new accessory
|
|
695
706
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -743,7 +754,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
743
754
|
}
|
|
744
755
|
} else if (await this.registerDevice(device)) {
|
|
745
756
|
// the accessory does not yet exist, so we need to create it
|
|
746
|
-
|
|
757
|
+
if (!device.external) {
|
|
758
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
759
|
+
}
|
|
747
760
|
|
|
748
761
|
// create a new accessory
|
|
749
762
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -797,7 +810,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
797
810
|
}
|
|
798
811
|
} else if (await this.registerDevice(device)) {
|
|
799
812
|
// the accessory does not yet exist, so we need to create it
|
|
800
|
-
|
|
813
|
+
if (!device.external) {
|
|
814
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
815
|
+
}
|
|
801
816
|
|
|
802
817
|
// create a new accessory
|
|
803
818
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -851,7 +866,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
851
866
|
}
|
|
852
867
|
} else if (await this.registerDevice(device)) {
|
|
853
868
|
// the accessory does not yet exist, so we need to create it
|
|
854
|
-
|
|
869
|
+
if (!device.external) {
|
|
870
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
871
|
+
}
|
|
855
872
|
|
|
856
873
|
// create a new accessory
|
|
857
874
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -905,7 +922,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
905
922
|
}
|
|
906
923
|
} else if (await this.registerDevice(device)) {
|
|
907
924
|
// the accessory does not yet exist, so we need to create it
|
|
908
|
-
|
|
925
|
+
if (!device.external) {
|
|
926
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
927
|
+
}
|
|
909
928
|
|
|
910
929
|
if (device.group && !device.curtain?.disable_group) {
|
|
911
930
|
this.debugLog(`Your Curtains are grouped
|
|
@@ -970,7 +989,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
970
989
|
}
|
|
971
990
|
} else if (await this.registerDevice(device)) {
|
|
972
991
|
// the accessory does not yet exist, so we need to create it
|
|
973
|
-
|
|
992
|
+
if (!device.external) {
|
|
993
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
994
|
+
}
|
|
974
995
|
|
|
975
996
|
// create a new accessory
|
|
976
997
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1024,7 +1045,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1024
1045
|
}
|
|
1025
1046
|
} else if (await this.registerDevice(device)) {
|
|
1026
1047
|
// the accessory does not yet exist, so we need to create it
|
|
1027
|
-
|
|
1048
|
+
if (!device.external) {
|
|
1049
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1050
|
+
}
|
|
1028
1051
|
|
|
1029
1052
|
// create a new accessory
|
|
1030
1053
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1078,7 +1101,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1078
1101
|
}
|
|
1079
1102
|
} else if (await this.registerDevice(device)) {
|
|
1080
1103
|
// the accessory does not yet exist, so we need to create it
|
|
1081
|
-
|
|
1104
|
+
if (!device.external) {
|
|
1105
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1106
|
+
}
|
|
1082
1107
|
|
|
1083
1108
|
// create a new accessory
|
|
1084
1109
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1104,6 +1129,62 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1104
1129
|
}
|
|
1105
1130
|
}
|
|
1106
1131
|
|
|
1132
|
+
private async createCeilingLight(device: device & devicesConfig) {
|
|
1133
|
+
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
1134
|
+
|
|
1135
|
+
// see if an accessory with the same uuid has already been registered and restored from
|
|
1136
|
+
// the cached devices we stored in the `configureAccessory` method above
|
|
1137
|
+
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
1138
|
+
|
|
1139
|
+
if (existingAccessory) {
|
|
1140
|
+
// the accessory already exists
|
|
1141
|
+
if (await this.registerDevice(device)) {
|
|
1142
|
+
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1143
|
+
existingAccessory.context.model = device.deviceType;
|
|
1144
|
+
existingAccessory.context.deviceID = device.deviceId;
|
|
1145
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1146
|
+
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1147
|
+
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1148
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1149
|
+
existingAccessory.context.connectionType = await this.connectionType(device);
|
|
1150
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1151
|
+
// create the accessory handler for the restored accessory
|
|
1152
|
+
// this is imported from `platformAccessory.ts`
|
|
1153
|
+
new CeilingLight(this, existingAccessory, device);
|
|
1154
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1155
|
+
} else {
|
|
1156
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
1157
|
+
}
|
|
1158
|
+
} else if (await this.registerDevice(device)) {
|
|
1159
|
+
// the accessory does not yet exist, so we need to create it
|
|
1160
|
+
if (!device.external) {
|
|
1161
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
// create a new accessory
|
|
1165
|
+
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
1166
|
+
|
|
1167
|
+
// store a copy of the device object in the `accessory.context`
|
|
1168
|
+
// the `context` property can be used to store any data about the accessory you may need
|
|
1169
|
+
accessory.context.device = device;
|
|
1170
|
+
accessory.context.model = device.deviceType;
|
|
1171
|
+
accessory.context.deviceID = device.deviceId;
|
|
1172
|
+
accessory.context.firmwareRevision = device.firmware;
|
|
1173
|
+
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1174
|
+
accessory.context.connectionType = await this.connectionType(device);
|
|
1175
|
+
// create the accessory handler for the newly create accessory
|
|
1176
|
+
// this is imported from `platformAccessory.ts`
|
|
1177
|
+
new CeilingLight(this, accessory, device);
|
|
1178
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1179
|
+
|
|
1180
|
+
// publish device externally or link the accessory to your platform
|
|
1181
|
+
this.externalOrPlatform(device, accessory);
|
|
1182
|
+
this.accessories.push(accessory);
|
|
1183
|
+
} else {
|
|
1184
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1107
1188
|
private async createStripLight(device: device & devicesConfig) {
|
|
1108
1189
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
1109
1190
|
|
|
@@ -1132,7 +1213,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1132
1213
|
}
|
|
1133
1214
|
} else if (await this.registerDevice(device)) {
|
|
1134
1215
|
// the accessory does not yet exist, so we need to create it
|
|
1135
|
-
|
|
1216
|
+
if (!device.external) {
|
|
1217
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1218
|
+
}
|
|
1136
1219
|
|
|
1137
1220
|
// create a new accessory
|
|
1138
1221
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1181,7 +1264,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1181
1264
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`);
|
|
1182
1265
|
} else if (!device.hide_device && device.hubDeviceId) {
|
|
1183
1266
|
// the accessory does not yet exist, so we need to create it
|
|
1184
|
-
|
|
1267
|
+
if (!device.external) {
|
|
1268
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1269
|
+
}
|
|
1185
1270
|
|
|
1186
1271
|
// create a new accessory
|
|
1187
1272
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1239,7 +1324,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1239
1324
|
}
|
|
1240
1325
|
} else if (!device.hide_device && device.hubDeviceId) {
|
|
1241
1326
|
// the accessory does not yet exist, so we need to create it
|
|
1242
|
-
|
|
1327
|
+
if (!device.external) {
|
|
1328
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1329
|
+
}
|
|
1243
1330
|
|
|
1244
1331
|
// create a new accessory
|
|
1245
1332
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1293,7 +1380,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1293
1380
|
}
|
|
1294
1381
|
} else if (!device.hide_device && device.hubDeviceId) {
|
|
1295
1382
|
// the accessory does not yet exist, so we need to create it
|
|
1296
|
-
|
|
1383
|
+
if (!device.external) {
|
|
1384
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1385
|
+
}
|
|
1297
1386
|
|
|
1298
1387
|
// create a new accessory
|
|
1299
1388
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1347,7 +1436,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1347
1436
|
}
|
|
1348
1437
|
} else if (!device.hide_device && device.hubDeviceId) {
|
|
1349
1438
|
// the accessory does not yet exist, so we need to create it
|
|
1350
|
-
|
|
1439
|
+
if (!device.external) {
|
|
1440
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1441
|
+
}
|
|
1351
1442
|
|
|
1352
1443
|
// create a new accessory
|
|
1353
1444
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1401,7 +1492,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1401
1492
|
}
|
|
1402
1493
|
} else if (!device.hide_device && device.hubDeviceId) {
|
|
1403
1494
|
// the accessory does not yet exist, so we need to create it
|
|
1404
|
-
|
|
1495
|
+
if (!device.external) {
|
|
1496
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1497
|
+
}
|
|
1405
1498
|
|
|
1406
1499
|
// create a new accessory
|
|
1407
1500
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1455,7 +1548,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1455
1548
|
}
|
|
1456
1549
|
} else if (!device.hide_device && device.hubDeviceId) {
|
|
1457
1550
|
// the accessory does not yet exist, so we need to create it
|
|
1458
|
-
|
|
1551
|
+
if (!device.external) {
|
|
1552
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1553
|
+
}
|
|
1459
1554
|
|
|
1460
1555
|
// create a new accessory
|
|
1461
1556
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1509,7 +1604,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1509
1604
|
}
|
|
1510
1605
|
} else if (!device.hide_device && device.hubDeviceId) {
|
|
1511
1606
|
// the accessory does not yet exist, so we need to create it
|
|
1512
|
-
|
|
1607
|
+
if (!device.external) {
|
|
1608
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1609
|
+
}
|
|
1513
1610
|
|
|
1514
1611
|
// create a new accessory
|
|
1515
1612
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1563,7 +1660,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1563
1660
|
}
|
|
1564
1661
|
} else if (!device.hide_device && device.hubDeviceId) {
|
|
1565
1662
|
// the accessory does not yet exist, so we need to create it
|
|
1566
|
-
|
|
1663
|
+
if (!device.external) {
|
|
1664
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1665
|
+
}
|
|
1567
1666
|
|
|
1568
1667
|
// create a new accessory
|
|
1569
1668
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
@@ -1617,7 +1716,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1617
1716
|
}
|
|
1618
1717
|
} else if (!device.hide_device && device.hubDeviceId) {
|
|
1619
1718
|
// the accessory does not yet exist, so we need to create it
|
|
1620
|
-
|
|
1719
|
+
if (!device.external) {
|
|
1720
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.remoteType} DeviceID: ${device.deviceId}`);
|
|
1721
|
+
}
|
|
1621
1722
|
|
|
1622
1723
|
// create a new accessory
|
|
1623
1724
|
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
package/src/settings.ts
CHANGED
|
@@ -65,6 +65,7 @@ export interface devicesConfig extends device {
|
|
|
65
65
|
contact?: contact;
|
|
66
66
|
motion?: motion;
|
|
67
67
|
colorbulb?: colorbulb;
|
|
68
|
+
ceilinglight?: ceilinglight;
|
|
68
69
|
plug?: Record<any, any>;
|
|
69
70
|
lock?: lock;
|
|
70
71
|
}
|
|
@@ -118,6 +119,11 @@ export type colorbulb = {
|
|
|
118
119
|
adaptiveLightingShift?: number;
|
|
119
120
|
};
|
|
120
121
|
|
|
122
|
+
export type ceilinglight = {
|
|
123
|
+
set_minStep?: number;
|
|
124
|
+
adaptiveLightingShift?: number;
|
|
125
|
+
};
|
|
126
|
+
|
|
121
127
|
export type lock = {
|
|
122
128
|
hide_contactsensor?: boolean;
|
|
123
129
|
};
|