From bb56a5bb8454d789f9b748f8e25fec715660ce6c Mon Sep 17 00:00:00 2001 From: Jin Date: Fri, 2 Jun 2023 16:09:23 +0700 Subject: [PATCH] fix: convert F to C is missing in some case #239 --- src/devices/AirConditioner.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/devices/AirConditioner.ts b/src/devices/AirConditioner.ts index 81b3ed2..a1af6eb 100644 --- a/src/devices/AirConditioner.ts +++ b/src/devices/AirConditioner.ts @@ -708,9 +708,15 @@ export class ACStatus { return temperatureInCelsius; } - // lookup fahrenheit value by celsius value from table TempFahToCel - const temperatureInFahrenheit = parseInt(this.device.deviceModel.lookupMonitorName('TempFahToCel', temperatureInCelsius)); - if (temperatureInFahrenheit === undefined) { + // lookup fahrenheit value by celsius value from table TempCelToFah + let temperatureInFahrenheit = parseInt(this.device.deviceModel.lookupMonitorValue('TempCelToFah', temperatureInCelsius)); + if (isNaN(temperatureInFahrenheit)) { + // lookup again in table TempFahToCel + temperatureInFahrenheit = parseInt(this.device.deviceModel.lookupMonitorValue('TempFahToCel', temperatureInCelsius)); + } + + // if not found in both tables, return original value + if (isNaN(temperatureInFahrenheit)) { return temperatureInCelsius; }