From 8a0868519c0f3c4b73fe687e09a00ea95bbe7b69 Mon Sep 17 00:00:00 2001 From: Jasper Seinhorst Date: Thu, 8 Feb 2024 23:32:50 +0100 Subject: [PATCH] refactor: DirectClimatisation is now called PrecoolHeat --- package-lock.json | 4 ++-- package.json | 2 +- src/Accessories/Battery.ts | 2 +- .../{DirectClimatisation.ts => PrecoolHeat.ts} | 14 +++++++------- src/Accessories/index.ts | 4 ++-- src/Platform.ts | 18 +++++++++--------- 6 files changed, 22 insertions(+), 22 deletions(-) rename src/Accessories/{DirectClimatisation.ts => PrecoolHeat.ts} (76%) diff --git a/package-lock.json b/package-lock.json index f067769..39c2f33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebridge-porsche-taycan", - "version": "0.15.1", + "version": "0.16.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "homebridge-porsche-taycan", - "version": "0.15.1", + "version": "0.16.0", "license": "Apache-2.0", "dependencies": { "porsche-connect": "^0.0.14" diff --git a/package.json b/package.json index 5f980cb..e8ba0bf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Homebridge Porsche Taycan", "name": "homebridge-porsche-taycan", - "version": "0.15.1", + "version": "0.16.0", "description": "Control your Porsche Taycan through the home app", "license": "Apache-2.0", "author": "Jasper Seinhorst", diff --git a/src/Accessories/Battery.ts b/src/Accessories/Battery.ts index b5e3eb9..794d82c 100644 --- a/src/Accessories/Battery.ts +++ b/src/Accessories/Battery.ts @@ -20,7 +20,7 @@ export default class Charger implements PorscheAccessory { // Battery level const newBatteryLevel = emobilityInfo.batteryChargeStatus.stateOfChargeInPercentage; if (newBatteryLevel !== this.batteryDevice.getCharacteristic(this.Characteristic.CurrentRelativeHumidity).value) { - this.log.debug('Battery level ->', newBatteryLevel); + this.log.info('Battery level ->', newBatteryLevel); } this.batteryDevice.setCharacteristic(this.Characteristic.CurrentRelativeHumidity, newBatteryLevel); } diff --git a/src/Accessories/DirectClimatisation.ts b/src/Accessories/PrecoolHeat.ts similarity index 76% rename from src/Accessories/DirectClimatisation.ts rename to src/Accessories/PrecoolHeat.ts index dd05acc..93a2e97 100644 --- a/src/Accessories/DirectClimatisation.ts +++ b/src/Accessories/PrecoolHeat.ts @@ -2,7 +2,7 @@ import { Service, PlatformAccessory, PlatformConfig, Logger, API, Characteristic import { PorscheAccessory } from '../PlatformTypes'; import { VehicleEMobility, Vehicle } from 'porsche-connect'; -export default class DirectClimatisation implements PorscheAccessory { +export default class PrecoolHeat implements PorscheAccessory { public readonly Service: typeof Service = this.api.hap.Service; public readonly Characteristic: typeof Characteristic = this.api.hap.Characteristic; private switchService: Service; @@ -24,10 +24,10 @@ export default class DirectClimatisation implements PorscheAccessory { // Only call API when status is not changed during heartbeat if (this.vehicle && !this.heartBeatActive) { if (value) { - this.log.debug('Connecting with API to enable Direct Climatisation'); + this.log.debug('Connecting with API to start Precool/heat'); await this.vehicle.enableClimate(); } else { - this.log.debug('Connecting with API to disable Direct Climatisation'); + this.log.debug('Connecting with API to stop Precool/heat'); await this.vehicle.disableClimate(); } return callback(); @@ -40,11 +40,11 @@ export default class DirectClimatisation implements PorscheAccessory { this.heartBeatActive = true; this.vehicle = vehicle; - const isDirectClimatisationActive = !!(emobilityInfo.directClimatisation.climatisationState === 'ON'); - if (isDirectClimatisationActive !== this.switchService.getCharacteristic(this.Characteristic.On).value) { - this.log.info('Direct Climatisation ->', isDirectClimatisationActive ? 'ON' : 'OFF'); + const isPrecoolHeatActive = !!(emobilityInfo.directClimatisation.climatisationState === 'ON'); + if (isPrecoolHeatActive !== this.switchService.getCharacteristic(this.Characteristic.On).value) { + this.log.info('Precool/heat ->', isPrecoolHeatActive ? 'ON' : 'OFF'); } - this.switchService.setCharacteristic(this.Characteristic.On, isDirectClimatisationActive); + this.switchService.setCharacteristic(this.Characteristic.On, isPrecoolHeatActive); this.heartBeatActive = false; } diff --git a/src/Accessories/index.ts b/src/Accessories/index.ts index 48e9c53..811e387 100644 --- a/src/Accessories/index.ts +++ b/src/Accessories/index.ts @@ -1,9 +1,9 @@ import Battery from './Battery'; import Charger from './Charger'; -import DirectClimatisation from './DirectClimatisation'; +import PrecoolHeat from './PrecoolHeat'; export { Battery, Charger, - DirectClimatisation, + PrecoolHeat, }; \ No newline at end of file diff --git a/src/Platform.ts b/src/Platform.ts index a380708..04f3446 100644 --- a/src/Platform.ts +++ b/src/Platform.ts @@ -1,5 +1,5 @@ import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service, Characteristic } from 'homebridge'; -import { Battery, Charger, DirectClimatisation } from './Accessories'; +import { Battery, Charger, PrecoolHeat } from './Accessories'; import PorscheConnect, { EngineType } from 'porsche-connect'; import { PlatformVehicle, PorscheAccessory } from './PlatformTypes'; @@ -72,17 +72,17 @@ export class PorscheTaycanPlatform implements DynamicPlatformPlugin { this.api.registerPlatformAccessories('homebridge-porsche-taycan', 'PorscheTaycan', [accessory]); } - // Register DirectClimatisation - const directClimatisationUuid = this.api.hap.uuid.generate(`${vehicle.vin}-direct-climatisation`); - const directClimatisationExistingAccessory = this.accessories.find(accessory => accessory.UUID === directClimatisationUuid); + // Register Precool / heat + const precoolHeatUuid = this.api.hap.uuid.generate(`${vehicle.vin}-precool-heat`); + const precoolHeatExistingAccessory = this.accessories.find(accessory => accessory.UUID === precoolHeatUuid); - if (directClimatisationExistingAccessory) { - platformVehicle.accessories.push(new DirectClimatisation(this.config, this.log, this.api, directClimatisationExistingAccessory)); + if (precoolHeatExistingAccessory) { + platformVehicle.accessories.push(new PrecoolHeat(this.config, this.log, this.api, precoolHeatExistingAccessory)); } else { - this.log.info('Direct Climatisation added as accessory'); - const accessory = new this.api.platformAccessory('Direct Climatisation', directClimatisationUuid); + this.log.info('Precool/heat added as accessory'); + const accessory = new this.api.platformAccessory('Precool/heat', precoolHeatUuid); accessory.context.device = vehicle; - platformVehicle.accessories.push(new DirectClimatisation(this.config, this.log, this.api, accessory)); + platformVehicle.accessories.push(new PrecoolHeat(this.config, this.log, this.api, accessory)); this.api.registerPlatformAccessories('homebridge-porsche-taycan', 'PorscheTaycan', [accessory]); }