Skip to content

Commit

Permalink
2.6.3
Browse files Browse the repository at this point in the history
- Added code for water out thermometer
  • Loading branch information
hjuhlin committed Jul 22, 2024
1 parent 4ca2eb7 commit dd70a03
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 18 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ This is a plugin for Aqua Temp pool heater.
2.6.2
- Added code for finding devices in shared lists.

2.6.3
- Added code for water out thermometer

# Default config

```json
Expand All @@ -64,6 +67,7 @@ This is a plugin for Aqua Temp pool heater.
"Password": "[Password]",
"UpdateTime": 60,
"ViewWaterThermometer": false,
"ViewWaterOutThermometer": false,
"ViewElectricPowerUsage": false,
"PowerConsumptionLimit": 0,
"Debug": false,
Expand Down
10 changes: 8 additions & 2 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@
"default": 60
} ,
"ViewWaterThermometer": {
"title": "Extra thermometer for water temperature",
"title": "Extra thermometer for water IN temperature",
"type": "boolean",
"required": false,
"default": false
},
},
"ViewWaterOutThermometer": {
"title": "Extra thermometer for water OUT temperature",
"type": "boolean",
"required": false,
"default": false
},
"ViewElectricPowerUsage": {
"title": "View electric power usage (only works in Eve app)",
"type": "boolean",
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.2",
"version": "2.6.3",
"description": "This is a plugin for Aqua Temp pool heater.",
"license": "Apache-2.0",
"repository": {
Expand Down
53 changes: 41 additions & 12 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,41 @@ export class AquaTempHomebridgePlatform implements DynamicPlatformPlugin {
device.deviceNickName = deviceNickName;

if (codeData.code ==='T02') {
if (this.config['Debug'] as boolean) {
this.log.info('Update temperature for ' + device.deviceNickName + ': '+codeData.value);
}
if (this.config['ViewWaterThermometer'] as boolean === true) {
if (this.config['Debug'] as boolean) {
this.log.info('Update water IN temperature for ' + device.deviceNickName + ': '+codeData.value);
}

if (codeData.value!==null) {
currentTemp = parseFloat(codeData.value);
if (codeData.value!==null) {
currentTemp = parseFloat(codeData.value);

thermostatService.updateCharacteristic(this.Characteristic.CurrentTemperature, codeData.value);
thermostatService.updateCharacteristic(this.Characteristic.CurrentTemperature, codeData.value);

if (this.config['ViewWaterThermometer'] as boolean === true) {
const thermometerObjectWater = this.getAccessory(device, 'thermometerwater');
const thermometerServiceWater = thermometerObjectWater.accessory.getService(this.Service.TemperatureSensor);

if (thermometerServiceWater!==undefined) {
if (this.config['Debug'] as boolean) {
this.log.info('Update water temperature for ' + device.deviceNickName + ': '+codeData.value);
}
thermometerServiceWater.updateCharacteristic(this.Characteristic.CurrentTemperature, codeData.value);
}
}
}
}

if (codeData.code ==='T03') {
if (this.config['ViewWaterOutThermometer'] as boolean === true) {
if (this.config['Debug'] as boolean) {
this.log.info('Update water OUT temperature for ' + device.deviceNickName + ': '+codeData.value);
}

if (codeData.value!==null) {
currentTemp = parseFloat(codeData.value);

thermostatService.updateCharacteristic(this.Characteristic.CurrentTemperature, codeData.value);

const thermometerObjectWater = this.getAccessory(device, 'thermometerwaterout');
const thermometerServiceWater = thermometerObjectWater.accessory.getService(this.Service.TemperatureSensor);

if (thermometerServiceWater!==undefined) {
thermometerServiceWater.updateCharacteristic(this.Characteristic.CurrentTemperature, codeData.value);
}
}
Expand Down Expand Up @@ -262,6 +279,9 @@ export class AquaTempHomebridgePlatform implements DynamicPlatformPlugin {
this.log.error(deviceResult.error_code);
this.log.error(deviceResult.error_msg_code);
}
}).catch((error) => {
this.log.error('GetDeviceStatus', 'Caught error');
this.log.error(error);
});
}

Expand Down Expand Up @@ -304,7 +324,9 @@ export class AquaTempHomebridgePlatform implements DynamicPlatformPlugin {
} else {
this.log.error('Error login in!');
}

}).catch((error) => {
this.log.error('Login', 'Caught error');
this.log.error(error);
});
}

Expand Down Expand Up @@ -386,6 +408,12 @@ export class AquaTempHomebridgePlatform implements DynamicPlatformPlugin {
this.addOrRestorAccessory(waterObject.accessory, device.deviceNickName, 'thermometerwater', waterObject.exists);
}

if (this.config['ViewWaterOutThermometer'] as boolean === true) {
const waterObject = this.getAccessory(device, 'thermometerwaterout');
new ThermometerAccessory(this, waterObject.accessory, device, this.config, this.log, 'waterout');
this.addOrRestorAccessory(waterObject.accessory, device.deviceNickName, 'thermometerwaterout', waterObject.exists);
}

const thermostatObject = this.getAccessory(device, 'thermostat');
if (this.config['EveLoging'] as boolean === true) {
const fakeGatoService = new this.FakeGatoHistoryService('custom', thermostatObject.accessory,
Expand All @@ -404,7 +432,8 @@ export class AquaTempHomebridgePlatform implements DynamicPlatformPlugin {
for (const device of deviceList) {
if (accessory.UUID === this.localIdForType(device, 'thermostat') ||
accessory.UUID === this.localIdForType(device, 'thermometer') ||
accessory.UUID === this.localIdForType(device, 'thermometerwater')) {
accessory.UUID === this.localIdForType(device, 'thermometerwater') ||
accessory.UUID === this.localIdForType(device, 'thermometerwaterout')) {
found = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/httprequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class HttpRequest {
body: {
device_code: deviceCode,
appId: '14',
protocal_codes: ['T02', 'T05', 'T12', 'R02', 'power', 'Manual-mute'],
protocal_codes: ['T02', 'T03', 'T05', 'T12', 'R02', 'power', 'Manual-mute'],
},
json: true,
}, (error, response, body) => {
Expand Down

0 comments on commit dd70a03

Please sign in to comment.