diff --git a/config.schema.json b/config.schema.json index 21bd99a..a74465c 100644 --- a/config.schema.json +++ b/config.schema.json @@ -1,5 +1,5 @@ { - "pluginAlias": "ExampleHomebridgePlugin", + "pluginAlias": "HomebridgeSamsungACSmartThings", "pluginType": "platform", "singular": true, "schema": { @@ -9,7 +9,13 @@ "title": "Name", "type": "string", "required": true, - "default": "Example Dynamic Platform" + "default": "homebridge-samsung-air-conditioner-smart-things" + }, + "token": { + "title": "Token", + "type": "string", + "required": true, + "default": "" } } } diff --git a/src/platform.ts b/src/platform.ts index 0acd34c..4dcc490 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -31,8 +31,7 @@ export class SamsungAC implements DynamicPlatformPlugin { } discoverDevices() { - const token = 'ef7a9c71-ef1a-4864-8bc9-7265b5deb355'; - SamsungAPI.getDevices(token).then(samsungDevices => { + SamsungAPI.getDevices(this.config.token).then(samsungDevices => { for (const device of samsungDevices) { const uuid = this.api.hap.uuid.generate(device.deviceId.toString()); @@ -40,6 +39,7 @@ export class SamsungAC implements DynamicPlatformPlugin { if (existingAccessory) { this.log.info('Restoring existing accessory from cache:', existingAccessory.displayName); + existingAccessory.context.token = this.config.token; new SamsungACPlatformAccessory(this, existingAccessory); } else { @@ -48,7 +48,7 @@ export class SamsungAC implements DynamicPlatformPlugin { const accessory = new this.api.platformAccessory(device.label, uuid); accessory.context.device = device; - accessory.context.token = token; + accessory.context.token = this.config.token; new SamsungACPlatformAccessory(this, accessory);