@switchbot/homebridge-switchbot 2.2.3-beta.0 → 2.3.0-beta.0
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 +9 -0
- package/README.md +8 -0
- package/config.schema.json +8 -0
- package/dist/device/robotvacuumcleaner.d.ts +106 -0
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -0
- package/dist/device/robotvacuumcleaner.js +824 -0
- package/dist/device/robotvacuumcleaner.js.map +1 -0
- package/dist/platform.d.ts +1 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +59 -0
- package/dist/platform.js.map +1 -1
- package/package.json +4 -3
- package/src/device/robotvacuumcleaner.ts +874 -0
- package/src/platform.ts +62 -0
package/src/platform.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { ColorBulb } from './device/colorbulb';
|
|
|
10
10
|
import { CeilingLight } from './device/ceilinglight';
|
|
11
11
|
import { StripLight } from './device/striplight';
|
|
12
12
|
import { Humidifier } from './device/humidifier';
|
|
13
|
+
import { RobotVacuumCleaner } from './device/robotvacuumcleaner';
|
|
13
14
|
import { TV } from './irdevice/tv';
|
|
14
15
|
import { Fan } from './irdevice/fan';
|
|
15
16
|
import { Light } from './irdevice/light';
|
|
@@ -447,6 +448,11 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
447
448
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
448
449
|
this.createColorBulb(device);
|
|
449
450
|
break;
|
|
451
|
+
case 'Robot Vacuum Cleaner S1':
|
|
452
|
+
case 'Robot Vacuum Cleaner S1 Plus':
|
|
453
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
454
|
+
this.createRobotVacuumCleaner(device);
|
|
455
|
+
break;
|
|
450
456
|
case 'Ceiling Light':
|
|
451
457
|
case 'Ceiling Light Pro':
|
|
452
458
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
@@ -1226,6 +1232,62 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1226
1232
|
}
|
|
1227
1233
|
}
|
|
1228
1234
|
|
|
1235
|
+
private async createRobotVacuumCleaner(device: device & devicesConfig) {
|
|
1236
|
+
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
1237
|
+
|
|
1238
|
+
// see if an accessory with the same uuid has already been registered and restored from
|
|
1239
|
+
// the cached devices we stored in the `configureAccessory` method above
|
|
1240
|
+
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
1241
|
+
|
|
1242
|
+
if (existingAccessory) {
|
|
1243
|
+
// the accessory already exists
|
|
1244
|
+
if (await this.registerDevice(device)) {
|
|
1245
|
+
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1246
|
+
existingAccessory.context.model = device.deviceType;
|
|
1247
|
+
existingAccessory.context.deviceID = device.deviceId;
|
|
1248
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1249
|
+
existingAccessory.context.firmwareRevision = device.firmware;
|
|
1250
|
+
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1251
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1252
|
+
existingAccessory.context.connectionType = await this.connectionType(device);
|
|
1253
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
1254
|
+
// create the accessory handler for the restored accessory
|
|
1255
|
+
// this is imported from `platformAccessory.ts`
|
|
1256
|
+
new RobotVacuumCleaner(this, existingAccessory, device);
|
|
1257
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
1258
|
+
} else {
|
|
1259
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
1260
|
+
}
|
|
1261
|
+
} else if (await this.registerDevice(device)) {
|
|
1262
|
+
// the accessory does not yet exist, so we need to create it
|
|
1263
|
+
if (!device.external) {
|
|
1264
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
// create a new accessory
|
|
1268
|
+
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
1269
|
+
|
|
1270
|
+
// store a copy of the device object in the `accessory.context`
|
|
1271
|
+
// the `context` property can be used to store any data about the accessory you may need
|
|
1272
|
+
accessory.context.device = device;
|
|
1273
|
+
accessory.context.model = device.deviceType;
|
|
1274
|
+
accessory.context.deviceID = device.deviceId;
|
|
1275
|
+
accessory.context.firmwareRevision = device.firmware;
|
|
1276
|
+
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
1277
|
+
accessory.context.connectionType = await this.connectionType(device);
|
|
1278
|
+
// create the accessory handler for the newly create accessory
|
|
1279
|
+
// this is imported from `platformAccessory.ts`
|
|
1280
|
+
new RobotVacuumCleaner(this, accessory, device);
|
|
1281
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
1282
|
+
|
|
1283
|
+
// publish device externally or link the accessory to your platform
|
|
1284
|
+
this.externalOrPlatform(device, accessory);
|
|
1285
|
+
this.accessories.push(accessory);
|
|
1286
|
+
} else {
|
|
1287
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1229
1291
|
private async createTV(device: irdevice & devicesConfig) {
|
|
1230
1292
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`);
|
|
1231
1293
|
|