homebridge-panasonic-heat-pump
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -7,2 +7,3 @@ export declare enum PanasonicSpecialStatus { | ||
export declare enum PanasonicTargetOperationMode { | ||
Off = 0, | ||
Heating = 2, | ||
@@ -23,3 +24,2 @@ Cooling = 3, | ||
setOperationMode(deviceId: string, operationMode: PanasonicTargetOperationMode, retried?: boolean): any; | ||
setZoneOperationStatus(deviceId: string, isOn: boolean, retried?: boolean): any; | ||
setZoneTemp(deviceId: string, temp: number, type: 'cool' | 'heat' | 'eco' | 'comfort', retried?: boolean): any; | ||
@@ -26,0 +26,0 @@ setOperationStatus(deviceId: string, isOn: boolean, retried?: boolean): any; |
@@ -16,2 +16,3 @@ "use strict"; | ||
(function (PanasonicTargetOperationMode) { | ||
PanasonicTargetOperationMode[PanasonicTargetOperationMode["Off"] = 0] = "Off"; | ||
PanasonicTargetOperationMode[PanasonicTargetOperationMode["Heating"] = 2] = "Heating"; | ||
@@ -88,3 +89,3 @@ PanasonicTargetOperationMode[PanasonicTargetOperationMode["Cooling"] = 3] = "Cooling"; | ||
}); | ||
if (response.data.errorCode > 0) { | ||
if (response.data.errorCode > 0 || !response.data.status || !response.data.status[0]) { | ||
if (retried) { | ||
@@ -171,2 +172,3 @@ throw new Error('Cannot authenticate'); | ||
'operationMode': operationMode, | ||
'zoneStatus': [{ zoneId: 1, 'operationStatus': operationMode === PanasonicTargetOperationMode.Off ? 0 : 1 }], | ||
}, | ||
@@ -184,30 +186,2 @@ ], | ||
} | ||
async setZoneOperationStatus(deviceId, isOn, retried = false) { | ||
await this.ensureAuthenticated(); | ||
const response = await (0, axios_1.default)({ | ||
'method': 'POST', | ||
'url': `https://aquarea-smart.panasonic.com/remote/v1/api/devices/${deviceId}`, | ||
'headers': { | ||
'Content-Type': 'application/json', | ||
'Cookie': `accessToken=${this.accessToken}; selectedDeviceId=${deviceId};`, | ||
'Origin': 'https://aquarea-smart.panasonic.com', | ||
'Referer': 'https://aquarea-smart.panasonic.com/remote/a2wStatusDisplay', | ||
}, | ||
'data': JSON.stringify({ | ||
'status': [ | ||
{ | ||
'deviceGuid': deviceId, | ||
'zoneStatus': [{ zoneId: 1, 'operationStatus': isOn ? 1 : 0 }], | ||
}, | ||
], | ||
}), | ||
}); | ||
if (response.status === 403) { | ||
if (retried) { | ||
throw new Error('Cannot authenticate'); | ||
} | ||
await this.ensureAuthenticated(true); | ||
return this.setZoneOperationStatus(deviceId, isOn, true); | ||
} | ||
} | ||
async setZoneTemp(deviceId, temp, type, retried = false) { | ||
@@ -214,0 +188,0 @@ await this.ensureAuthenticated(); |
@@ -19,4 +19,5 @@ "use strict"; | ||
expect(deviceDetails.deviceGuid).toEqual(device.selectedDeviceId); | ||
await panasonicApi.setZoneTemp(device.selectedDeviceId, 5, 'heat'); | ||
}); | ||
}); | ||
//# sourceMappingURL=panasonicApi.test.js.map |
@@ -19,3 +19,3 @@ "use strict"; | ||
.setCharacteristic(this.platform.Characteristic.Model, 'Aquarea') | ||
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.accessory.context.device.uniqueId); | ||
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.accessory.UUID); | ||
// FLOOR | ||
@@ -32,7 +32,2 @@ this.service = this.accessory.getService('Floor Heating') | ||
.onSet(async (state) => { | ||
if (state === this.platform.Characteristic.TargetHeatingCoolingState.OFF) { | ||
// turn off floors | ||
this.panasonicApi.setZoneOperationStatus(this.accessory.context.device.uniqueId, false); | ||
return; | ||
} | ||
const operationMode = (() => { | ||
@@ -45,8 +40,10 @@ switch (state) { | ||
case this.platform.Characteristic.TargetHeatingCoolingState.AUTO: | ||
return panasonicApi_1.PanasonicTargetOperationMode.Auto; | ||
default: | ||
return panasonicApi_1.PanasonicTargetOperationMode.Auto; | ||
case this.platform.Characteristic.TargetHeatingCoolingState.OFF: | ||
return panasonicApi_1.PanasonicTargetOperationMode.Off; | ||
} | ||
})(); | ||
this.panasonicApi.setOperationMode(this.accessory.context.device.uniqueId, operationMode); | ||
this.panasonicApi.setZoneOperationStatus(this.accessory.context.device.uniqueId, true); | ||
await this.getReadings(true); | ||
}).onGet(async () => (await this.getReadings()).targetHeatingCoolingState); | ||
@@ -56,3 +53,7 @@ this.service.getCharacteristic(this.platform.Characteristic.TargetTemperature) | ||
const readings = await this.getReadings(); | ||
this.panasonicApi.setZoneTemp(this.accessory.context.device.uniqueId, temp - readings.temperatureNow, readings.temperatureNow); | ||
const adjustedTemp = (parseInt(temp)) - readings.temperatureNow; | ||
// eslint-disable-next-line no-console | ||
console.log(`Setting Floor Heating temp[${readings.tempType}] to: ${adjustedTemp}`); | ||
this.panasonicApi.setZoneTemp(this.accessory.context.device.uniqueId, adjustedTemp, readings.tempType); | ||
await this.getReadings(true); | ||
}).onGet(async () => { | ||
@@ -68,2 +69,3 @@ const readings = await this.getReadings(); | ||
panasonicApi.setTankTargetHeat(this.accessory.context.device.uniqueId, temp); | ||
await this.getReadings(true); | ||
}).onGet(async () => { | ||
@@ -79,2 +81,3 @@ return (await this.getReadings()).tankTemperatureSet; | ||
this.panasonicApi.setTankStatus(this.accessory.context.device.uniqueId, false); | ||
await this.getReadings(true); | ||
return; | ||
@@ -86,2 +89,3 @@ } | ||
this.panasonicApi.setTankStatus(this.accessory.context.device.uniqueId, true); | ||
await this.getReadings(true); | ||
}).onGet(async () => { | ||
@@ -117,2 +121,3 @@ return (await this.getReadings()).tankTargetHeatingCoolingState; | ||
} | ||
await this.getReadings(true); | ||
}).onGet(async () => { | ||
@@ -132,2 +137,3 @@ return (await this.getReadings()).ecoModeIsActive; | ||
} | ||
await this.getReadings(true); | ||
}).onGet(async () => { | ||
@@ -134,0 +140,0 @@ return (await this.getReadings()).comfortModeIsActive; |
{ | ||
"displayName": "Homebridge Panasonic Heat Pump", | ||
"name": "homebridge-panasonic-heat-pump", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Allows basic control of Panasonic Heat Pump (AQUAREA)", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
190232
3562