Skip to content

Commit

Permalink
refactor: DirectClimatisation is now called PrecoolHeat
Browse files Browse the repository at this point in the history
  • Loading branch information
jasper-seinhorst committed Feb 8, 2024
1 parent bb52000 commit 8a08685
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Accessories/Battery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Accessories/index.ts
Original file line number Diff line number Diff line change
@@ -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,
};
18 changes: 9 additions & 9 deletions src/Platform.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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]);
}

Expand Down

0 comments on commit 8a08685

Please sign in to comment.