@switchbot/homebridge-switchbot 2.0.0-beta.19 → 2.0.0-beta.20
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 +6 -1
- package/README.md +1 -2
- package/config.schema.json +51 -32
- package/dist/device/bot.d.ts +32 -29
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +549 -575
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts +33 -15
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +426 -341
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +16 -9
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +246 -208
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +21 -18
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +449 -449
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts +22 -20
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +346 -324
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +22 -10
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +257 -178
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +21 -14
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +287 -239
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +23 -10
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +308 -190
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +17 -10
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +225 -193
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +24 -17
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +270 -267
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +36 -14
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +447 -299
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +7 -14
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +177 -169
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -5
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +72 -57
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +3 -4
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +47 -33
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +3 -4
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +66 -48
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +3 -4
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +48 -47
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +3 -4
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +47 -33
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +10 -11
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +64 -48
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +7 -12
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +52 -41
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +6 -11
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +52 -42
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +0 -4
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +44 -66
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +3 -3
- package/dist/settings.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/device/bot.ts +551 -589
- package/src/device/colorbulb.ts +441 -375
- package/src/device/contact.ts +249 -213
- package/src/device/curtain.ts +452 -461
- package/src/device/humidifier.ts +358 -365
- package/src/device/lock.ts +263 -179
- package/src/device/meter.ts +302 -253
- package/src/device/meterplus.ts +319 -194
- package/src/device/motion.ts +230 -199
- package/src/device/plug.ts +273 -274
- package/src/device/striplight.ts +460 -316
- package/src/irdevice/airconditioner.ts +181 -183
- package/src/irdevice/airpurifier.ts +70 -60
- package/src/irdevice/camera.ts +46 -36
- package/src/irdevice/fan.ts +64 -49
- package/src/irdevice/light.ts +47 -51
- package/src/irdevice/other.ts +46 -36
- package/src/irdevice/tv.ts +64 -51
- package/src/irdevice/vacuumcleaner.ts +52 -45
- package/src/irdevice/waterheater.ts +50 -45
- package/src/platform.ts +44 -68
- package/src/settings.ts +3 -3
package/src/platform.ts
CHANGED
|
@@ -160,7 +160,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
160
160
|
if (!deviceConfig.deviceId) {
|
|
161
161
|
throw new Error('The devices config section is missing the *Device ID* in the config. Please check your config.');
|
|
162
162
|
}
|
|
163
|
-
if (!deviceConfig.configDeviceType && deviceConfig.
|
|
163
|
+
if (!deviceConfig.configDeviceType && deviceConfig.connectionType) {
|
|
164
164
|
throw new Error('The devices config section is missing the *Device Type* in the config. Please check your config.');
|
|
165
165
|
}
|
|
166
166
|
}
|
|
@@ -618,7 +618,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
618
618
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
619
619
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
620
620
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
621
|
-
|
|
621
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
622
622
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
623
623
|
// create the accessory handler for the restored accessory
|
|
624
624
|
// this is imported from `platformAccessory.ts`
|
|
@@ -641,7 +641,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
641
641
|
accessory.context.deviceID = device.deviceId;
|
|
642
642
|
accessory.context.firmwareRevision = device.firmware;
|
|
643
643
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
644
|
-
|
|
644
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
645
645
|
// create the accessory handler for the newly create accessory
|
|
646
646
|
// this is imported from `platformAccessory.ts`
|
|
647
647
|
new Humidifier(this, accessory, device);
|
|
@@ -674,7 +674,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
674
674
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
675
675
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
676
676
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
677
|
-
|
|
677
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
678
678
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
679
679
|
// create the accessory handler for the restored accessory
|
|
680
680
|
// this is imported from `platformAccessory.ts`
|
|
@@ -699,7 +699,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
699
699
|
accessory.context.deviceID = device.deviceId;
|
|
700
700
|
accessory.context.firmwareRevision = device.firmware;
|
|
701
701
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
702
|
-
|
|
702
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
703
703
|
// accessory.context.firmwareRevision = findaccessories.accessoryAttribute.softwareRevision;
|
|
704
704
|
// create the accessory handler for the newly create accessory
|
|
705
705
|
// this is imported from `platformAccessory.ts`
|
|
@@ -731,7 +731,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
731
731
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
732
732
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
733
733
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
734
|
-
|
|
734
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
735
735
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
736
736
|
// create the accessory handler for the restored accessory
|
|
737
737
|
// this is imported from `platformAccessory.ts`
|
|
@@ -754,7 +754,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
754
754
|
accessory.context.deviceID = device.deviceId;
|
|
755
755
|
accessory.context.firmwareRevision = device.firmware;
|
|
756
756
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
757
|
-
|
|
757
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
758
758
|
// create the accessory handler for the newly create accessory
|
|
759
759
|
// this is imported from `platformAccessory.ts`
|
|
760
760
|
new Meter(this, accessory, device);
|
|
@@ -785,7 +785,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
785
785
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
786
786
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
787
787
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
788
|
-
|
|
788
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
789
789
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
790
790
|
// create the accessory handler for the restored accessory
|
|
791
791
|
// this is imported from `platformAccessory.ts`
|
|
@@ -808,7 +808,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
808
808
|
accessory.context.deviceID = device.deviceId;
|
|
809
809
|
accessory.context.firmwareRevision = device.firmware;
|
|
810
810
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
811
|
-
|
|
811
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
812
812
|
// create the accessory handler for the newly create accessory
|
|
813
813
|
// this is imported from `platformAccessory.ts`
|
|
814
814
|
new MeterPlus(this, accessory, device);
|
|
@@ -839,7 +839,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
839
839
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
840
840
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
841
841
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
842
|
-
|
|
842
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
843
843
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
844
844
|
// create the accessory handler for the restored accessory
|
|
845
845
|
// this is imported from `platformAccessory.ts`
|
|
@@ -862,7 +862,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
862
862
|
accessory.context.deviceID = device.deviceId;
|
|
863
863
|
accessory.context.firmwareRevision = device.firmware;
|
|
864
864
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
865
|
-
|
|
865
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
866
866
|
// create the accessory handler for the newly create accessory
|
|
867
867
|
// this is imported from `platformAccessory.ts`
|
|
868
868
|
new Motion(this, accessory, device);
|
|
@@ -893,7 +893,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
893
893
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
894
894
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
895
895
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
896
|
-
|
|
896
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
897
897
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
898
898
|
// create the accessory handler for the restored accessory
|
|
899
899
|
// this is imported from `platformAccessory.ts`
|
|
@@ -916,7 +916,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
916
916
|
accessory.context.deviceID = device.deviceId;
|
|
917
917
|
accessory.context.firmwareRevision = device.firmware;
|
|
918
918
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
919
|
-
|
|
919
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
920
920
|
// create the accessory handler for the newly create accessory
|
|
921
921
|
// this is imported from `platformAccessory.ts`
|
|
922
922
|
new Contact(this, accessory, device);
|
|
@@ -947,7 +947,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
947
947
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
948
948
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
949
949
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
950
|
-
|
|
950
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
951
951
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
952
952
|
// create the accessory handler for the restored accessory
|
|
953
953
|
// this is imported from `platformAccessory.ts`
|
|
@@ -981,7 +981,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
981
981
|
accessory.context.deviceID = device.deviceId;
|
|
982
982
|
accessory.context.firmwareRevision = device.firmware;
|
|
983
983
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
984
|
-
|
|
984
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
985
985
|
// create the accessory handler for the newly create accessory
|
|
986
986
|
// this is imported from `platformAccessory.ts`
|
|
987
987
|
new Curtain(this, accessory, device);
|
|
@@ -1027,7 +1027,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1027
1027
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1028
1028
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1029
1029
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1030
|
-
|
|
1030
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1031
1031
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1032
1032
|
// create the accessory handler for the restored accessory
|
|
1033
1033
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1050,7 +1050,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1050
1050
|
accessory.context.deviceID = device.deviceId;
|
|
1051
1051
|
accessory.context.firmwareRevision = device.firmware;
|
|
1052
1052
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1053
|
-
|
|
1053
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1054
1054
|
// create the accessory handler for the newly create accessory
|
|
1055
1055
|
// this is imported from `platformAccessory.ts`
|
|
1056
1056
|
new Plug(this, accessory, device);
|
|
@@ -1081,7 +1081,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1081
1081
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1082
1082
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1083
1083
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1084
|
-
|
|
1084
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1085
1085
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1086
1086
|
// create the accessory handler for the restored accessory
|
|
1087
1087
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1104,7 +1104,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1104
1104
|
accessory.context.deviceID = device.deviceId;
|
|
1105
1105
|
accessory.context.firmwareRevision = device.firmware;
|
|
1106
1106
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1107
|
-
|
|
1107
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1108
1108
|
// create the accessory handler for the newly create accessory
|
|
1109
1109
|
// this is imported from `platformAccessory.ts`
|
|
1110
1110
|
new Lock(this, accessory, device);
|
|
@@ -1135,7 +1135,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1135
1135
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1136
1136
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1137
1137
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1138
|
-
|
|
1138
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1139
1139
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1140
1140
|
// create the accessory handler for the restored accessory
|
|
1141
1141
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1158,7 +1158,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1158
1158
|
accessory.context.deviceID = device.deviceId;
|
|
1159
1159
|
accessory.context.firmwareRevision = device.firmware;
|
|
1160
1160
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1161
|
-
|
|
1161
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1162
1162
|
// create the accessory handler for the newly create accessory
|
|
1163
1163
|
// this is imported from `platformAccessory.ts`
|
|
1164
1164
|
new ColorBulb(this, accessory, device);
|
|
@@ -1189,7 +1189,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1189
1189
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1190
1190
|
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1191
1191
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1192
|
-
|
|
1192
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1193
1193
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1194
1194
|
// create the accessory handler for the restored accessory
|
|
1195
1195
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1212,7 +1212,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1212
1212
|
accessory.context.deviceID = device.deviceId;
|
|
1213
1213
|
accessory.context.firmwareRevision = device.firmware;
|
|
1214
1214
|
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1215
|
-
|
|
1215
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1216
1216
|
// create the accessory handler for the newly create accessory
|
|
1217
1217
|
// this is imported from `platformAccessory.ts`
|
|
1218
1218
|
new StripLight(this, accessory, device);
|
|
@@ -1241,7 +1241,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1241
1241
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1242
1242
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1243
1243
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1244
|
-
|
|
1244
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1245
1245
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1246
1246
|
// create the accessory handler for the restored accessory
|
|
1247
1247
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1261,7 +1261,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1261
1261
|
accessory.context.deviceID = device.deviceId;
|
|
1262
1262
|
accessory.context.firmwareRevision = device.firmware;
|
|
1263
1263
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1264
|
-
|
|
1264
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1265
1265
|
// create the accessory handler for the newly create accessory
|
|
1266
1266
|
// this is imported from `platformAccessory.ts`
|
|
1267
1267
|
new TV(this, accessory, device);
|
|
@@ -1296,7 +1296,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1296
1296
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1297
1297
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1298
1298
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1299
|
-
|
|
1299
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1300
1300
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1301
1301
|
// create the accessory handler for the restored accessory
|
|
1302
1302
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1319,7 +1319,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1319
1319
|
accessory.context.deviceID = device.deviceId;
|
|
1320
1320
|
accessory.context.firmwareRevision = device.firmware;
|
|
1321
1321
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1322
|
-
|
|
1322
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1323
1323
|
// create the accessory handler for the newly create accessory
|
|
1324
1324
|
// this is imported from `platformAccessory.ts`
|
|
1325
1325
|
new Fan(this, accessory, device);
|
|
@@ -1350,7 +1350,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1350
1350
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1351
1351
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1352
1352
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1353
|
-
|
|
1353
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1354
1354
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1355
1355
|
// create the accessory handler for the restored accessory
|
|
1356
1356
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1373,7 +1373,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1373
1373
|
accessory.context.deviceID = device.deviceId;
|
|
1374
1374
|
accessory.context.firmwareRevision = device.firmware;
|
|
1375
1375
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1376
|
-
|
|
1376
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1377
1377
|
// create the accessory handler for the newly create accessory
|
|
1378
1378
|
// this is imported from `platformAccessory.ts`
|
|
1379
1379
|
new Light(this, accessory, device);
|
|
@@ -1404,7 +1404,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1404
1404
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1405
1405
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1406
1406
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1407
|
-
|
|
1407
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1408
1408
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1409
1409
|
// create the accessory handler for the restored accessory
|
|
1410
1410
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1427,7 +1427,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1427
1427
|
accessory.context.deviceID = device.deviceId;
|
|
1428
1428
|
accessory.context.firmwareRevision = device.firmware;
|
|
1429
1429
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1430
|
-
|
|
1430
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1431
1431
|
// create the accessory handler for the newly create accessory
|
|
1432
1432
|
// this is imported from `platformAccessory.ts`
|
|
1433
1433
|
new AirConditioner(this, accessory, device);
|
|
@@ -1458,7 +1458,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1458
1458
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1459
1459
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1460
1460
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1461
|
-
|
|
1461
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1462
1462
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1463
1463
|
// create the accessory handler for the restored accessory
|
|
1464
1464
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1481,7 +1481,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1481
1481
|
accessory.context.deviceID = device.deviceId;
|
|
1482
1482
|
accessory.context.firmwareRevision = device.firmware;
|
|
1483
1483
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1484
|
-
|
|
1484
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1485
1485
|
// create the accessory handler for the newly create accessory
|
|
1486
1486
|
// this is imported from `platformAccessory.ts`
|
|
1487
1487
|
new AirPurifier(this, accessory, device);
|
|
@@ -1512,7 +1512,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1512
1512
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1513
1513
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1514
1514
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1515
|
-
|
|
1515
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1516
1516
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1517
1517
|
// create the accessory handler for the restored accessory
|
|
1518
1518
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1535,7 +1535,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1535
1535
|
accessory.context.deviceID = device.deviceId;
|
|
1536
1536
|
accessory.context.firmwareRevision = device.firmware;
|
|
1537
1537
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1538
|
-
|
|
1538
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1539
1539
|
// create the accessory handler for the newly create accessory
|
|
1540
1540
|
// this is imported from `platformAccessory.ts`
|
|
1541
1541
|
new WaterHeater(this, accessory, device);
|
|
@@ -1566,7 +1566,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1566
1566
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1567
1567
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1568
1568
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1569
|
-
|
|
1569
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1570
1570
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1571
1571
|
// create the accessory handler for the restored accessory
|
|
1572
1572
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1589,7 +1589,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1589
1589
|
accessory.context.deviceID = device.deviceId;
|
|
1590
1590
|
accessory.context.firmwareRevision = device.firmware;
|
|
1591
1591
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1592
|
-
|
|
1592
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1593
1593
|
// create the accessory handler for the newly create accessory
|
|
1594
1594
|
// this is imported from `platformAccessory.ts`
|
|
1595
1595
|
new VacuumCleaner(this, accessory, device);
|
|
@@ -1620,7 +1620,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1620
1620
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1621
1621
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1622
1622
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1623
|
-
|
|
1623
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1624
1624
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1625
1625
|
// create the accessory handler for the restored accessory
|
|
1626
1626
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1643,7 +1643,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1643
1643
|
accessory.context.deviceID = device.deviceId;
|
|
1644
1644
|
accessory.context.firmwareRevision = device.firmware;
|
|
1645
1645
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1646
|
-
|
|
1646
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1647
1647
|
// create the accessory handler for the newly create accessory
|
|
1648
1648
|
// this is imported from `platformAccessory.ts`
|
|
1649
1649
|
new Camera(this, accessory, device);
|
|
@@ -1674,7 +1674,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1674
1674
|
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1675
1675
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1676
1676
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1677
|
-
|
|
1677
|
+
existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1678
1678
|
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1679
1679
|
// create the accessory handler for the restored accessory
|
|
1680
1680
|
// this is imported from `platformAccessory.ts`
|
|
@@ -1697,7 +1697,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1697
1697
|
accessory.context.deviceID = device.deviceId;
|
|
1698
1698
|
accessory.context.firmwareRevision = device.firmware;
|
|
1699
1699
|
accessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1700
|
-
|
|
1700
|
+
accessory.context.connectionType = device.connectionType || 'OpenAPI';
|
|
1701
1701
|
// create the accessory handler for the newly create accessory
|
|
1702
1702
|
// this is imported from `platformAccessory.ts`
|
|
1703
1703
|
new Others(this, accessory, device);
|
|
@@ -1712,14 +1712,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1712
1712
|
}
|
|
1713
1713
|
|
|
1714
1714
|
private registerDevice(device: device & devicesConfig) {
|
|
1715
|
-
if (!device.hide_device && device.enableCloudService && device.
|
|
1715
|
+
if (!device.hide_device && device.enableCloudService && device.connectionType === 'Both') {
|
|
1716
1716
|
this.registeringDevice = true;
|
|
1717
1717
|
this.debugLog(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled`);
|
|
1718
1718
|
} else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName
|
|
1719
|
-
&& !device.enableCloudService) {
|
|
1719
|
+
&& !device.enableCloudService && device.connectionType === 'BLE') {
|
|
1720
1720
|
this.registeringDevice = true;
|
|
1721
1721
|
this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled`);
|
|
1722
|
-
} else if (!device.hide_device && device.enableCloudService &&
|
|
1722
|
+
} else if (!device.hide_device && device.enableCloudService && device.connectionType === 'OpenAPI') {
|
|
1723
1723
|
this.registeringDevice = true;
|
|
1724
1724
|
this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
|
|
1725
1725
|
} else {
|
|
@@ -1743,30 +1743,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1743
1743
|
this.api.publishExternalAccessories(PLUGIN_NAME, [accessory]);
|
|
1744
1744
|
}
|
|
1745
1745
|
|
|
1746
|
-
public async connectionTypeNewAccessory(device: device & devicesConfig, accessory: PlatformAccessory) {
|
|
1747
|
-
if (device.ble) {
|
|
1748
|
-
accessory.context.connectionType = 'BLE';
|
|
1749
|
-
} else {
|
|
1750
|
-
accessory.context.connectionType = 'OpenAPI';
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
|
-
public async connectionTypeExistingAccessory(device: device & devicesConfig, existingAccessory: PlatformAccessory) {
|
|
1755
|
-
if (device.ble) {
|
|
1756
|
-
existingAccessory.context.connectionType = 'BLE';
|
|
1757
|
-
} else {
|
|
1758
|
-
existingAccessory.context.connectionType = 'OpenAPI';
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
public async connectionTypeNewIRAccessory(accessory: PlatformAccessory) {
|
|
1763
|
-
accessory.context.connectionType = 'IR wirth OpenAPI';
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
public async connectionTypeExistingIRAccessory(existingAccessory: PlatformAccessory) {
|
|
1767
|
-
existingAccessory.context.connectionType = 'IR with OpenAPI';
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
1746
|
public unregisterPlatformAccessories(existingAccessory: PlatformAccessory) {
|
|
1771
1747
|
// remove platform accessories when no longer present
|
|
1772
1748
|
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [existingAccessory]);
|
package/src/settings.ts
CHANGED
|
@@ -48,8 +48,7 @@ export interface devicesConfig extends device {
|
|
|
48
48
|
refreshRate?: number;
|
|
49
49
|
firmware?: string;
|
|
50
50
|
logging?: string;
|
|
51
|
-
|
|
52
|
-
openAPI?: boolean;
|
|
51
|
+
connectionType?: string;
|
|
53
52
|
customBLEaddress?: string;
|
|
54
53
|
scanDuration?: number;
|
|
55
54
|
hide_device?: boolean;
|
|
@@ -126,8 +125,9 @@ export interface irDevicesConfig extends irdevice {
|
|
|
126
125
|
configRemoteType?: string;
|
|
127
126
|
deviceId: string;
|
|
128
127
|
external?: boolean;
|
|
128
|
+
firmware?: string;
|
|
129
129
|
logging?: string;
|
|
130
|
-
|
|
130
|
+
connectionType?: string;
|
|
131
131
|
hide_device?: boolean;
|
|
132
132
|
irfan?: irfan;
|
|
133
133
|
irair?: irair;
|