From 8dbd38a9414f823f71a288b8e75c26e285241b8f Mon Sep 17 00:00:00 2001 From: Jasper Seinhorst Date: Wed, 29 Mar 2023 11:29:49 +0200 Subject: [PATCH] feat: Add device accessory information --- src/Accessories/Charger.ts | 5 +++++ src/Accessories/DirectCharge.ts | 5 +++++ src/Accessories/DirectClimatisation.ts | 11 ++++++++--- src/Platform.ts | 6 +++--- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Accessories/Charger.ts b/src/Accessories/Charger.ts index ff3ccba..7dfb570 100644 --- a/src/Accessories/Charger.ts +++ b/src/Accessories/Charger.ts @@ -11,6 +11,11 @@ export default class Charger implements PorscheAccessory { private sensorType: 'occupancy' | 'contact'; constructor(public config: PlatformConfig, public readonly log: Logger, public readonly api: API, public accessory: PlatformAccessory) { + this.accessory.getService(this.Service.AccessoryInformation)! + .setCharacteristic(this.Characteristic.Manufacturer, 'homebridge-porsche-taycan') + .setCharacteristic(this.Characteristic.Model, this.accessory.context.device.modelDescription) + .setCharacteristic(this.Characteristic.SerialNumber, this.accessory.context.device.vin); + this.lowBatteryLevel = this.config.lowBattery || 35; this.sensorType = this.config.chargerDevice || 'occupancy'; this.chargerService = this.accessory.getService(this.sensorType === 'occupancy' ? this.Service.OccupancySensor : this.Service.ContactSensor) diff --git a/src/Accessories/DirectCharge.ts b/src/Accessories/DirectCharge.ts index 203e120..ba44679 100644 --- a/src/Accessories/DirectCharge.ts +++ b/src/Accessories/DirectCharge.ts @@ -10,6 +10,11 @@ export default class DirectCharge implements PorscheAccessory { private heartBeatActive = false; constructor(public config: PlatformConfig, public readonly log: Logger, public readonly api: API, public accessory: PlatformAccessory) { + this.accessory.getService(this.Service.AccessoryInformation)! + .setCharacteristic(this.Characteristic.Manufacturer, 'homebridge-porsche-taycan') + .setCharacteristic(this.Characteristic.Model, this.accessory.context.device.modelDescription) + .setCharacteristic(this.Characteristic.SerialNumber, this.accessory.context.device.vin); + this.switchService = this.accessory.getService(this.Service.Switch) || this.accessory.addService(this.Service.Switch); this.switchService.getCharacteristic(this.Characteristic.On).on('set', this.setStatus.bind(this)); this.switchService.setCharacteristic(this.Characteristic.On, false); diff --git a/src/Accessories/DirectClimatisation.ts b/src/Accessories/DirectClimatisation.ts index e74ff6b..ace6dd8 100644 --- a/src/Accessories/DirectClimatisation.ts +++ b/src/Accessories/DirectClimatisation.ts @@ -10,9 +10,14 @@ export default class DirectClimatisation implements PorscheAccessory { private heartBeatActive = false; constructor(public config: PlatformConfig, public readonly log: Logger, public readonly api: API, public accessory: PlatformAccessory) { - this.switchService = this.accessory.getService(this.Service.Switch) || this.accessory.addService(this.Service.Switch); - this.switchService.getCharacteristic(this.Characteristic.On).on('set', this.setStatus.bind(this)); - this.switchService.setCharacteristic(this.Characteristic.On, false); + this.accessory.getService(this.Service.AccessoryInformation)! + .setCharacteristic(this.Characteristic.Manufacturer, 'homebridge-porsche-taycan') + .setCharacteristic(this.Characteristic.Model, this.accessory.context.device.modelDescription) + .setCharacteristic(this.Characteristic.SerialNumber, this.accessory.context.device.vin); + + this.switchService = this.accessory.getService(this.Service.Switch) || this.accessory.addService(this.Service.Switch); + this.switchService.getCharacteristic(this.Characteristic.On).on('set', this.setStatus.bind(this)); + this.switchService.setCharacteristic(this.Characteristic.On, false); } private async setStatus(value, callback) { diff --git a/src/Platform.ts b/src/Platform.ts index fa35575..6cbce79 100644 --- a/src/Platform.ts +++ b/src/Platform.ts @@ -40,7 +40,7 @@ export class PorscheTaycanPlatform implements DynamicPlatformPlugin { // Register Charger const chargerUuid = this.api.hap.uuid.generate(`${vehicle.vin}-charger`); const chargerExistingAccessory = this.accessories.find(accessory => accessory.UUID === chargerUuid); - const chargerAccessoryName = `${vehicle.modelDescription} Charger`; + const chargerAccessoryName = 'Charger'; if (chargerExistingAccessory) { platformVehicle.accessories.push(new Charger(this.config, this.log, this.api, chargerExistingAccessory)); @@ -55,7 +55,7 @@ export class PorscheTaycanPlatform implements DynamicPlatformPlugin { // Register DirectCharge const directChargeUuid = this.api.hap.uuid.generate(`${vehicle.vin}-direct-charge`); const directChargeExistingAccessory = this.accessories.find(accessory => accessory.UUID === directChargeUuid); - const directChargeAccessoryName = `${vehicle.modelDescription} Direct Charge`; + const directChargeAccessoryName = 'Direct Charge'; if (directChargeExistingAccessory) { platformVehicle.accessories.push(new DirectCharge(this.config, this.log, this.api, directChargeExistingAccessory)); @@ -70,7 +70,7 @@ export class PorscheTaycanPlatform implements DynamicPlatformPlugin { // Register DirectClimatisation const directClimatisationUuid = this.api.hap.uuid.generate(`${vehicle.vin}-direct-climatisation`); const directClimatisationExistingAccessory = this.accessories.find(accessory => accessory.UUID === directClimatisationUuid); - const directClimatisationAccessoryName = `${vehicle.modelDescription} Direct Climatisation`; + const directClimatisationAccessoryName = 'Direct Climatisation'; if (directClimatisationExistingAccessory) { platformVehicle.accessories.push(new DirectClimatisation(this.config, this.log, this.api, directClimatisationExistingAccessory));