@switchbot/homebridge-switchbot 3.5.2-beta.1 → 3.5.2-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/config.schema.json +13 -13
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +121 -107
- package/dist/device/bot.js.map +1 -1
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +2 -0
- package/dist/device/device.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +90 -50
- package/dist/irdevice/other.js.map +1 -1
- package/package.json +2 -2
- package/src/device/bot.ts +121 -101
- package/src/device/device.ts +2 -0
- package/src/irdevice/other.ts +90 -50
package/src/device/bot.ts
CHANGED
|
@@ -1162,92 +1162,132 @@ export class Bot extends deviceBase {
|
|
|
1162
1162
|
|
|
1163
1163
|
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
1164
1164
|
// If outletService still present, then remove first
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
accessory.
|
|
1169
|
-
|
|
1165
|
+
accessory.context.Outlet = accessory.context.Outlet ?? {};
|
|
1166
|
+
this.Outlet = {
|
|
1167
|
+
Name: accessory.context.Outlet.Name ?? accessory.displayName,
|
|
1168
|
+
Service: accessory.getService(this.hap.Service.Outlet) as Service,
|
|
1169
|
+
On: accessory.context.On ?? false,
|
|
1170
|
+
};
|
|
1171
|
+
accessory.context.Outlet = this.Outlet as object;
|
|
1172
|
+
await this.warnLog('Removing any leftover Outlet Service');
|
|
1173
|
+
accessory.removeService(this.Outlet.Service);
|
|
1170
1174
|
}
|
|
1171
1175
|
|
|
1172
1176
|
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
1173
1177
|
// If garageDoorService still present, then remove first
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
accessory.
|
|
1178
|
-
|
|
1178
|
+
accessory.context.GarageDoor = accessory.context.GarageDoor ?? {};
|
|
1179
|
+
this.GarageDoor = {
|
|
1180
|
+
Name: accessory.context.GarageDoor.Name ?? accessory.displayName,
|
|
1181
|
+
Service: accessory.getService(this.hap.Service.GarageDoorOpener) as Service,
|
|
1182
|
+
On: accessory.context.On ?? false,
|
|
1183
|
+
};
|
|
1184
|
+
accessory.context.GarageDoor = this.GarageDoor as object;
|
|
1185
|
+
await this.warnLog('Removing any leftover Garage Door Service');
|
|
1186
|
+
accessory.removeService(this.GarageDoor.Service);
|
|
1179
1187
|
}
|
|
1180
1188
|
|
|
1181
1189
|
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
1182
1190
|
// If doorService still present, then remove first
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
accessory.
|
|
1187
|
-
|
|
1191
|
+
accessory.context.Door = accessory.context.Door ?? {};
|
|
1192
|
+
this.Door = {
|
|
1193
|
+
Name: accessory.context.Door.Name ?? accessory.displayName,
|
|
1194
|
+
Service: accessory.getService(this.hap.Service.Door) as Service,
|
|
1195
|
+
On: accessory.context.On ?? false,
|
|
1196
|
+
};
|
|
1197
|
+
accessory.context.Door = this.Door as object;
|
|
1198
|
+
await this.warnLog('Removing any leftover Door Service');
|
|
1199
|
+
accessory.removeService(this.Door.Service);
|
|
1188
1200
|
}
|
|
1189
1201
|
|
|
1190
1202
|
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
1191
1203
|
// If lockService still present, then remove first
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
accessory.
|
|
1196
|
-
|
|
1204
|
+
accessory.context.LockMechanism = accessory.context.LockMechanism ?? {};
|
|
1205
|
+
this.LockMechanism = {
|
|
1206
|
+
Name: accessory.context.LockMechanism.Name ?? accessory.displayName,
|
|
1207
|
+
Service: accessory.getService(this.hap.Service.LockMechanism) as Service,
|
|
1208
|
+
On: accessory.context.On ?? false,
|
|
1209
|
+
};
|
|
1210
|
+
accessory.context.LockMechanism = this.LockMechanism as object;
|
|
1211
|
+
this.warnLog('Removing any leftover Lock Service');
|
|
1212
|
+
accessory.removeService(this.LockMechanism.Service);
|
|
1197
1213
|
}
|
|
1198
1214
|
|
|
1199
1215
|
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
1200
1216
|
// If faucetService still present, then remove first
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
accessory.
|
|
1205
|
-
|
|
1217
|
+
accessory.context.Faucet = accessory.context.Faucet ?? {};
|
|
1218
|
+
this.Faucet = {
|
|
1219
|
+
Name: accessory.context.Faucet.Name ?? accessory.displayName,
|
|
1220
|
+
Service: accessory.getService(this.hap.Service.Valve) as Service,
|
|
1221
|
+
On: accessory.context.On ?? false,
|
|
1222
|
+
};
|
|
1223
|
+
accessory.context.Faucet = this.Faucet as object;
|
|
1224
|
+
await this.warnLog('Removing any leftover Faucet Service');
|
|
1225
|
+
accessory.removeService(this.Faucet.Service);
|
|
1206
1226
|
}
|
|
1207
1227
|
|
|
1208
1228
|
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
1209
1229
|
// If fanService still present, then remove first
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
accessory.
|
|
1214
|
-
|
|
1230
|
+
accessory.context.Fan = accessory.context.Fan ?? {};
|
|
1231
|
+
this.Fan = {
|
|
1232
|
+
Name: accessory.context.Fan.Name ?? accessory.displayName,
|
|
1233
|
+
Service: accessory.getService(this.hap.Service.Fan) as Service,
|
|
1234
|
+
On: accessory.context.On ?? false,
|
|
1235
|
+
};
|
|
1236
|
+
accessory.context.Fan = this.Fan as object;
|
|
1237
|
+
this.warnLog('Removing any leftover Fan Service');
|
|
1238
|
+
accessory.removeService(this.Fan.Service);
|
|
1215
1239
|
}
|
|
1216
1240
|
|
|
1217
1241
|
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
1218
1242
|
// If windowService still present, then remove first
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
accessory.
|
|
1223
|
-
|
|
1243
|
+
accessory.context.Window = accessory.context.Window ?? {};
|
|
1244
|
+
this.Window = {
|
|
1245
|
+
Name: accessory.context.Window.Name ?? accessory.displayName,
|
|
1246
|
+
Service: accessory.getService(this.hap.Service.Window) as Service,
|
|
1247
|
+
On: accessory.context.On ?? false,
|
|
1248
|
+
};
|
|
1249
|
+
accessory.context.Window = this.Window as object;
|
|
1250
|
+
await this.warnLog('Removing any leftover Window Service');
|
|
1251
|
+
accessory.removeService(this.Window.Service);
|
|
1224
1252
|
}
|
|
1225
1253
|
|
|
1226
1254
|
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
1227
1255
|
// If windowCoveringService still present, then remove first
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
accessory.
|
|
1232
|
-
|
|
1256
|
+
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {};
|
|
1257
|
+
this.WindowCovering = {
|
|
1258
|
+
Name: accessory.context.WindowCovering.Name ?? accessory.displayName,
|
|
1259
|
+
Service: accessory.getService(this.hap.Service.WindowCovering) as Service,
|
|
1260
|
+
On: accessory.context.On ?? false,
|
|
1261
|
+
};
|
|
1262
|
+
accessory.context.WindowCovering = this.WindowCovering as object;
|
|
1263
|
+
await this.warnLog('Removing any leftover Window Covering Service');
|
|
1264
|
+
accessory.removeService(this.WindowCovering.Service);
|
|
1233
1265
|
}
|
|
1234
1266
|
|
|
1235
1267
|
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
1236
1268
|
// If statefulProgrammableSwitchService still present, then remove first
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
accessory.
|
|
1241
|
-
|
|
1269
|
+
accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {};
|
|
1270
|
+
this.StatefulProgrammableSwitch = {
|
|
1271
|
+
Name: accessory.context.StatefulProgrammableSwitch.Name ?? accessory.displayName,
|
|
1272
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
1273
|
+
On: accessory.context.On ?? false,
|
|
1274
|
+
};
|
|
1275
|
+
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch as object;
|
|
1276
|
+
await this.warnLog('Removing any leftover Stateful Programmable Switch Service');
|
|
1277
|
+
accessory.removeService(this.StatefulProgrammableSwitch.Service);
|
|
1242
1278
|
}
|
|
1243
1279
|
|
|
1244
1280
|
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
1245
1281
|
// If switchService still present, then remove first
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
accessory.
|
|
1250
|
-
|
|
1282
|
+
accessory.context.Switch = accessory.context.Switch ?? {};
|
|
1283
|
+
this.Switch = {
|
|
1284
|
+
Name: accessory.context.Switch.Name ?? accessory.displayName,
|
|
1285
|
+
Service: accessory.getService(this.hap.Service.Switch) as Service,
|
|
1286
|
+
On: accessory.context.On ?? false,
|
|
1287
|
+
};
|
|
1288
|
+
accessory.context.Switch = this.Switch as object;
|
|
1289
|
+
await this.warnLog('Removing any leftover Switch Service');
|
|
1290
|
+
accessory.removeService(this.Switch.Service);
|
|
1251
1291
|
}
|
|
1252
1292
|
|
|
1253
1293
|
async getOn(): Promise<boolean> {
|
|
@@ -1322,63 +1362,43 @@ export class Bot extends deviceBase {
|
|
|
1322
1362
|
|
|
1323
1363
|
async getBotConfigSettings(device: device & devicesConfig) {
|
|
1324
1364
|
//Bot Device Type
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
await this.debugWarnLog(`Using Device Type: ${this.botDeviceType}`);
|
|
1333
|
-
} else {
|
|
1334
|
-
this.botDeviceType = 'outlet';
|
|
1335
|
-
await this.errorLog(`No Device Type Set, deviceType: ${this.device.bot?.deviceType}`);
|
|
1336
|
-
await this.warnLog(`Using default deviceType: ${this.botDeviceType}`);
|
|
1337
|
-
}
|
|
1365
|
+
this.botDeviceType = this.accessory.context.botDeviceType === device.bot?.deviceType ? this.accessory.context.botDeviceType
|
|
1366
|
+
: device.bot?.deviceType ?? 'outlet';
|
|
1367
|
+
const botDeviceType = this.accessory.context.botDeviceType ? `Using Device Type: ${this.botDeviceType}, from Accessory Cache.`
|
|
1368
|
+
: device.bot?.deviceType ? `Using Device Type: ${this.botDeviceType}`
|
|
1369
|
+
: `No Device Type Set, deviceType: ${this.device.bot?.deviceType}, Using default deviceType: ${this.botDeviceType}`;
|
|
1370
|
+
await this.debugWarnLog(botDeviceType);
|
|
1371
|
+
this.accessory.context.botDeviceType = this.botDeviceType;
|
|
1338
1372
|
// Bot Mode
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
this.botMode = 'switch';
|
|
1345
|
-
await this.debugLog(`Using Bot Mode: ${this.botMode}`);
|
|
1346
|
-
} else if (device.bot?.mode === 'press') {
|
|
1347
|
-
this.botMode = 'press';
|
|
1348
|
-
await this.debugLog(`Using Bot Mode: ${this.botMode}`);
|
|
1349
|
-
} else if (device.bot?.mode === 'multipress') {
|
|
1350
|
-
this.botMode = 'multipress';
|
|
1351
|
-
await this.debugLog(`Using Bot Mode: ${this.botMode}`);
|
|
1352
|
-
} else {
|
|
1353
|
-
throw new Error(`Bot Mode: ${this.botMode}`);
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1373
|
+
this.botMode = this.accessory.context.botMode ?? device.bot?.mode ?? 'switch';
|
|
1374
|
+
const botMode = this.accessory.context.botMode ? `Using Bot Mode: ${this.botMode}, from Accessory Cache.`
|
|
1375
|
+
: device.bot?.mode ? `Using Bot Mode: ${this.botMode}` : `No Bot Mode Set, Using default Bot Mode: ${this.botMode}`;
|
|
1376
|
+
await this.debugWarnLog(botMode);
|
|
1377
|
+
this.accessory.context.botMode = this.botMode;
|
|
1356
1378
|
// Bot Double Press
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1379
|
+
this.doublePress = this.accessory.context.doublePress ?? device.bot?.doublePress ?? 1;
|
|
1380
|
+
const doublePress = this.accessory.context.doublePress ? `Using Double Press: ${this.doublePress}, from Accessory Cache.`
|
|
1381
|
+
: device.bot?.doublePress ? `Using Double Press: ${this.doublePress}`
|
|
1382
|
+
: `No Double Press Set, Using default Double Press: ${this.doublePress}`;
|
|
1383
|
+
await this.debugWarnLog(doublePress);
|
|
1384
|
+
this.accessory.context.doublePress = this.doublePress;
|
|
1364
1385
|
// Bot Press PushRate
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1386
|
+
this.pushRatePress = this.accessory.context.pushRatePress ?? device.bot?.pushRatePress ?? 15;
|
|
1387
|
+
const pushRatePress = this.accessory.context.pushRatePress ? `Using Push Rate Press: ${this.pushRatePress}, from Accessory Cache.`
|
|
1388
|
+
: device.bot?.pushRatePress ? `Using Bot Push Rate Press: ${this.pushRatePress}`
|
|
1389
|
+
: `No Push Rate Press Set, Using default Push Rate Press: ${this.pushRatePress}`;
|
|
1390
|
+
await this.debugWarnLog(pushRatePress);
|
|
1391
|
+
this.accessory.context.pushRatePress = this.pushRatePress;
|
|
1373
1392
|
// Bot Allow Push
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1393
|
+
this.allowPush = this.accessory.context.allowPush ?? device.bot?.allowPush ?? false;
|
|
1394
|
+
const allowPush = this.accessory.context.allowPush ? `Using Allow Push: ${this.allowPush}, from Accessory Cache.`
|
|
1395
|
+
: device.bot?.allowPush ? `Using Allow Push: ${this.allowPush}`
|
|
1396
|
+
: `No Allow Push Set, Using default Allow Push: ${this.allowPush}`;
|
|
1397
|
+
await this.debugWarnLog(allowPush);
|
|
1398
|
+
this.accessory.context.allowPush = this.allowPush;
|
|
1380
1399
|
// Bot Multi Press Count
|
|
1381
1400
|
this.multiPressCount = 0;
|
|
1401
|
+
await this.debugWarnLog(`Multi Press Count: ${this.multiPressCount}`);
|
|
1382
1402
|
}
|
|
1383
1403
|
|
|
1384
1404
|
async BLEPushConnection() {
|
package/src/device/device.ts
CHANGED
|
@@ -480,6 +480,7 @@ export abstract class deviceBase {
|
|
|
480
480
|
case 'Bot':
|
|
481
481
|
device.model = SwitchBotModel.Bot;
|
|
482
482
|
device.bleModel = SwitchBotBLEModel.Bot;
|
|
483
|
+
device.bleModelName = SwitchBotBLEModelName.Bot;
|
|
483
484
|
device.bleModelFriednlyName = SwitchBotBLEModelFriendlyName.Bot;
|
|
484
485
|
break;
|
|
485
486
|
case 'Meter':
|
|
@@ -599,6 +600,7 @@ export abstract class deviceBase {
|
|
|
599
600
|
case 'Robot Vacuum Cleaner S1':
|
|
600
601
|
device.model = SwitchBotModel.RobotVacuumCleanerS1;
|
|
601
602
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
603
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
602
604
|
device.bleModelFriednlyName = SwitchBotBLEModelFriendlyName.Unknown;
|
|
603
605
|
break;
|
|
604
606
|
case 'Robot Vacuum Cleaner S1 Plus':
|
package/src/irdevice/other.ts
CHANGED
|
@@ -770,92 +770,132 @@ export class Others extends irdeviceBase {
|
|
|
770
770
|
|
|
771
771
|
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
772
772
|
// If Outlet.Service still present, then remove first
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
accessory.
|
|
777
|
-
|
|
773
|
+
accessory.context.Outlet = accessory.context.Outlet ?? {};
|
|
774
|
+
this.Outlet = {
|
|
775
|
+
Name: accessory.context.Outlet.Name ?? `${accessory.displayName} Outlet`,
|
|
776
|
+
Service: accessory.getService(this.hap.Service.Outlet) as Service,
|
|
777
|
+
On: accessory.context.On ?? false,
|
|
778
|
+
};
|
|
779
|
+
accessory.context.Outlet = this.Outlet as object;
|
|
780
|
+
this.warnLog('Removing any leftover Outlet Service');
|
|
781
|
+
accessory.removeService(this.Outlet.Service);
|
|
778
782
|
}
|
|
779
783
|
|
|
780
784
|
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
781
785
|
// If GarageDoor.Service still present, then remove first
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
accessory.
|
|
786
|
-
|
|
786
|
+
accessory.context.GarageDoor = accessory.context.GarageDoor ?? {};
|
|
787
|
+
this.GarageDoor = {
|
|
788
|
+
Name: accessory.context.GarageDoor.Name ?? `${accessory.displayName} Garage Door`,
|
|
789
|
+
Service: accessory.getService(this.hap.Service.GarageDoorOpener) as Service,
|
|
790
|
+
On: accessory.context.On ?? false,
|
|
791
|
+
};
|
|
792
|
+
accessory.context.GarageDoor = this.GarageDoor as object;
|
|
793
|
+
this.warnLog('Removing any leftover Garage Door Service');
|
|
794
|
+
accessory.removeService(this.GarageDoor.Service);
|
|
787
795
|
}
|
|
788
796
|
|
|
789
797
|
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
790
798
|
// If Door.Service still present, then remove first
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
accessory.
|
|
795
|
-
|
|
799
|
+
accessory.context.Door = accessory.context.Door ?? {};
|
|
800
|
+
this.Door = {
|
|
801
|
+
Name: accessory.context.Door.Name ?? `${accessory.displayName} Door`,
|
|
802
|
+
Service: accessory.getService(this.hap.Service.Door) as Service,
|
|
803
|
+
On: accessory.context.On ?? false,
|
|
804
|
+
};
|
|
805
|
+
accessory.context.Door = this.Door as object;
|
|
806
|
+
this.warnLog('Removing any leftover Door Service');
|
|
807
|
+
accessory.removeService(this.Door.Service);
|
|
796
808
|
}
|
|
797
809
|
|
|
798
810
|
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
799
811
|
// If Lock.Service still present, then remove first
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
accessory.
|
|
804
|
-
|
|
812
|
+
accessory.context.LockMechanism = accessory.context.LockMechanism ?? {};
|
|
813
|
+
this.LockMechanism = {
|
|
814
|
+
Name: accessory.context.LockMechanism.Name ?? `${accessory.displayName} Lock`,
|
|
815
|
+
Service: accessory.getService(this.hap.Service.LockMechanism) as Service,
|
|
816
|
+
On: accessory.context.On ?? false,
|
|
817
|
+
};
|
|
818
|
+
accessory.context.LockMechanism = this.LockMechanism as object;
|
|
819
|
+
this.warnLog('Removing any leftover Lock Service');
|
|
820
|
+
accessory.removeService(this.LockMechanism.Service);
|
|
805
821
|
}
|
|
806
822
|
|
|
807
823
|
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
808
824
|
// If Faucet.Service still present, then remove first
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
accessory.
|
|
813
|
-
|
|
825
|
+
accessory.context.Faucet = accessory.context.Faucet ?? {};
|
|
826
|
+
this.Faucet = {
|
|
827
|
+
Name: accessory.context.Faucet.Name ?? `${accessory.displayName} Faucet`,
|
|
828
|
+
Service: accessory.getService(this.hap.Service.Faucet) as Service,
|
|
829
|
+
On: accessory.context.On ?? false,
|
|
830
|
+
};
|
|
831
|
+
accessory.context.Faucet = this.Faucet as object;
|
|
832
|
+
this.warnLog('Removing any leftover Faucet Service');
|
|
833
|
+
accessory.removeService(this.Faucet.Service);
|
|
814
834
|
}
|
|
815
835
|
|
|
816
836
|
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
817
837
|
// If Fan Service still present, then remove first
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
accessory.
|
|
822
|
-
|
|
838
|
+
accessory.context.Fan = accessory.context.Fan ?? {};
|
|
839
|
+
this.Fan = {
|
|
840
|
+
Name: accessory.context.Fan.Name ?? `${accessory.displayName} Fan`,
|
|
841
|
+
Service: accessory.getService(this.hap.Service.Fanv2) as Service,
|
|
842
|
+
On: accessory.context.On ?? false,
|
|
843
|
+
};
|
|
844
|
+
accessory.context.Fan = this.Fan as object;
|
|
845
|
+
this.warnLog('Removing any leftover Fan Service');
|
|
846
|
+
accessory.removeService(this.Fan.Service);
|
|
823
847
|
}
|
|
824
848
|
|
|
825
849
|
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
826
850
|
// If Window.Service still present, then remove first
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
accessory.
|
|
831
|
-
|
|
851
|
+
accessory.context.Window = accessory.context.Window ?? {};
|
|
852
|
+
this.Window = {
|
|
853
|
+
Name: accessory.context.Window.Name ?? `${accessory.displayName} Window`,
|
|
854
|
+
Service: accessory.getService(this.hap.Service.Window) as Service,
|
|
855
|
+
On: accessory.context.On ?? false,
|
|
856
|
+
};
|
|
857
|
+
accessory.context.Window = this.Window as object;
|
|
858
|
+
this.warnLog('Removing any leftover Window Service');
|
|
859
|
+
accessory.removeService(this.Window.Service);
|
|
832
860
|
}
|
|
833
861
|
|
|
834
862
|
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
835
863
|
// If WindowCovering.Service still present, then remove first
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
accessory.
|
|
840
|
-
|
|
864
|
+
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {};
|
|
865
|
+
this.WindowCovering = {
|
|
866
|
+
Name: accessory.context.WindowCovering.Name ?? `${accessory.displayName} Window Covering`,
|
|
867
|
+
Service: accessory.getService(this.hap.Service.WindowCovering) as Service,
|
|
868
|
+
On: accessory.context.On ?? false,
|
|
869
|
+
};
|
|
870
|
+
accessory.context.WindowCovering = this.WindowCovering as object;
|
|
871
|
+
this.warnLog('Removing any leftover Window Covering Service');
|
|
872
|
+
accessory.removeService(this.WindowCovering.Service);
|
|
841
873
|
}
|
|
842
874
|
|
|
843
875
|
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
844
876
|
// If StatefulProgrammableSwitch.Service still present, then remove first
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
accessory.
|
|
849
|
-
|
|
877
|
+
accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {};
|
|
878
|
+
this.StatefulProgrammableSwitch = {
|
|
879
|
+
Name: accessory.context.StatefulProgrammableSwitch.Name ?? `${accessory.displayName} Stateful Programmable Switch`,
|
|
880
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
881
|
+
On: accessory.context.On ?? false,
|
|
882
|
+
};
|
|
883
|
+
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch as object;
|
|
884
|
+
this.warnLog('Removing any leftover Stateful Programmable Switch Service');
|
|
885
|
+
accessory.removeService(this.StatefulProgrammableSwitch.Service);
|
|
850
886
|
}
|
|
851
887
|
|
|
852
888
|
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
853
889
|
// If Switch.Service still present, then remove first
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
accessory.
|
|
858
|
-
|
|
890
|
+
accessory.context.Switch = accessory.context.Switch ?? {};
|
|
891
|
+
this.Switch = {
|
|
892
|
+
Name: accessory.context.Switch.Name ?? `${accessory.displayName} Switch`,
|
|
893
|
+
Service: accessory.getService(this.hap.Service.Switch) as Service,
|
|
894
|
+
On: accessory.context.On ?? false,
|
|
895
|
+
};
|
|
896
|
+
accessory.context.Switch = this.Switch as object;
|
|
897
|
+
this.warnLog('Removing any leftover Switch Service');
|
|
898
|
+
accessory.removeService(this.Switch.Service);
|
|
859
899
|
}
|
|
860
900
|
|
|
861
901
|
async getOtherConfigSettings(device: irdevice & irDevicesConfig): Promise<void> {
|