Skip to content

Commit

Permalink
2.7.0
Browse files Browse the repository at this point in the history
- Fixed the start up bug and a bug for shared device
  • Loading branch information
hjuhlin committed Jul 23, 2024
1 parent c1913b1 commit fbef51c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 23 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ This is a plugin for Aqua Temp pool heater.

# Important information!

- There is a bug that I have not managed to solve. After the plugin is installed and configured, one extra restart is needed. After that it works as expected.

- With the new version of the Auqa Temp API version only one device can be logged in at the same time. If you are online in the official app, Homebridge can’t be online. The best way to fix this is to make a new account for Homebridge and share your heater with that account.


Expand Down Expand Up @@ -57,6 +55,10 @@ This is a plugin for Aqua Temp pool heater.
2.6.4
- Added code for water out thermometer

2.7.0
- Fixed the start up bug and a bug for shared device


# Default config

```json
Expand Down
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
Expand Up @@ -2,7 +2,7 @@
"private": false,
"displayName": "Aqua Temp Plugin",
"name": "homebridge-aqua-temp",
"version": "2.6.4",
"version": "2.7.0",
"description": "This is a plugin for Aqua Temp pool heater.",
"license": "Apache-2.0",
"repository": {
Expand Down
42 changes: 34 additions & 8 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export class AquaTempHomebridgePlatform implements DynamicPlatformPlugin {
}

isHeating = isOn;

thermostatService.updateCharacteristic(this.Characteristic.TargetHeatingCoolingState,
isOn?this.Characteristic.TargetHeatingCoolingState.HEAT: this.Characteristic.TargetHeatingCoolingState.OFF);
}
Expand Down Expand Up @@ -202,11 +203,11 @@ export class AquaTempHomebridgePlatform implements DynamicPlatformPlugin {

if (this.config['ViewElectricPowerUsage'] as boolean) {
const powerConsumptionLimit = this.config['PowerConsumptionLimit'] as number;
if (device.is_fault!==false || currentPowerUsage<=powerConsumptionLimit) {
if (device.isFault!==false || currentPowerUsage<=powerConsumptionLimit) {
isHeating = false;
}
} else {
if (device.is_fault!==false) {
if (device.isFault!==false) {
isHeating = false;
}
}
Expand Down Expand Up @@ -390,12 +391,14 @@ export class AquaTempHomebridgePlatform implements DynamicPlatformPlugin {
}

discoverDevices(deviceList:ObjectResult[]) {
this.accessories.forEach(accessory => {
if (this.config['ClearAllAtStartUp'] as boolean) {
if (this.config['ClearAllAtStartUp'] as boolean) {
this.log.warn('ClearAllAtStartUp', 'Removing all existing accessory');

this.accessories.forEach(accessory => {
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
this.log.info('Removing existing accessory:', accessory.displayName);
}
});
});
}

for (const device of deviceList) {
const airObject = this.getAccessory(device, 'thermometer');
Expand Down Expand Up @@ -439,8 +442,24 @@ export class AquaTempHomebridgePlatform implements DynamicPlatformPlugin {
}

if (found === false) {
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
this.log.info('Removing existing accessory:', accessory.displayName);
this.removeAccessory(accessory, accessory.displayName, 'thermostat');
this.removeAccessory(accessory, accessory.displayName, 'thermometer');
}

if (this.config['ViewWaterThermometer'] as boolean === false) {
for (const device of deviceList) {
if (accessory.UUID === this.localIdForType(device, 'thermometerwater')) {
this.removeAccessory(accessory, accessory.displayName, 'thermometerwater');
}
}
}

if (this.config['ViewWaterOutThermometer'] as boolean === false) {
for (const device of deviceList) {
if (accessory.UUID === this.localIdForType(device, 'thermometerwaterout')) {
this.removeAccessory(accessory, accessory.displayName, 'thermometerwaterout');
}
}
}
});

Expand Down Expand Up @@ -470,6 +489,13 @@ export class AquaTempHomebridgePlatform implements DynamicPlatformPlugin {
this.log.info('Adding new accessory:', name +' ('+type+')');
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
}

this.accessories.push(accessory);
}

public removeAccessory(accessory: PlatformAccessory<Record<string, unknown>>, name: string, type: string) {
this.log.info('Removing existing accessory:', name +' ('+type+')');
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
}

localIdForType(device:ObjectResult, type:string):string {
Expand Down
2 changes: 1 addition & 1 deletion src/types/ObjectResult.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface ObjectResult {
deviceStatus: string;
is_fault: boolean;
isFault: boolean;
deviceId: string;
deviceCode: string;
productId: string;
Expand Down
20 changes: 11 additions & 9 deletions src/utils/httprequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ export class HttpRequest {
'x-token': token,
},
body: {
device_code: deviceCode,
deviceCode: deviceCode,
appId: '14',
protocal_codes: ['T02', 'T03', 'T05', 'T12', 'R02', 'power', 'Manual-mute'],
protocalCodes: ['T02', 'T03', 'T05', 'T12', 'R02', 'power', 'Manual-mute'],
},
json: true,
}, (error, response, body) => {
Expand Down Expand Up @@ -152,10 +152,11 @@ export class HttpRequest {
'x-token': token,
},
body: {
appId: '14',
param: [{
device_code: deviceCode,
deviceCode: deviceCode,
value: turnOn? '1':'0',
protocol_code: 'Power',
protocolCode: 'Power',
}],
},
json: true,
Expand Down Expand Up @@ -183,10 +184,11 @@ export class HttpRequest {
'x-token': token,
},
body: {
appId: '14',
param: [{
device_code: deviceCode,
deviceCode: deviceCode,
value: value,
protocol_code: 'R02',
protocolCode: 'R02',
}],
},
json: true,
Expand Down Expand Up @@ -214,10 +216,11 @@ export class HttpRequest {
'x-token': token,
},
body: {
appId: '14',
param: [{
device_code: deviceCode,
deviceCode: deviceCode,
value: value,
protocol_code: 'Manual-mute',
protocolCode: 'Manual-mute',
}],
},
json: true,
Expand All @@ -234,5 +237,4 @@ export class HttpRequest {
});
});
}

}

0 comments on commit fbef51c

Please sign in to comment.