From f6d90fd08cfaf556d428e6555daf2babaef975d7 Mon Sep 17 00:00:00 2001 From: joshua Date: Tue, 14 Mar 2023 13:41:21 +0100 Subject: [PATCH 1/2] fix(heater): multiply / divide by 10 to / from Tuya --- lib/heater_accessory.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/heater_accessory.js b/lib/heater_accessory.js index 1d0be8b6..c4709b91 100644 --- a/lib/heater_accessory.js +++ b/lib/heater_accessory.js @@ -47,7 +47,7 @@ class HeaterAccessory extends BaseAccessory { } if (statusMap.code === 'temp_current' || statusMap.code === 'temp_current_f') { this.temperatureMap = statusMap - this.normalAsync(Characteristic.CurrentTemperature, this.temperatureMap.value, { + this.normalAsync(Characteristic.CurrentTemperature, (this.temperatureMap.value / 10), { minValue: -20, maxValue: 122, minStep: 1 @@ -85,7 +85,7 @@ class HeaterAccessory extends BaseAccessory { this.temp_set_range = { 'min': 32, 'max': 104 } } } - this.normalAsync(Characteristic.HeatingThresholdTemperature, this.tempsetMap.value, { + this.normalAsync(Characteristic.HeatingThresholdTemperature, this.tempsetMap.value / 10, { minValue: this.temp_set_range.min, maxValue: this.temp_set_range.max, minStep: 1 @@ -161,7 +161,7 @@ class HeaterAccessory extends BaseAccessory { case Characteristic.HeatingThresholdTemperature: const tempset = value; code = this.tempsetMap.code; - value = tempset; + value = tempset * 10; break; default: break; @@ -246,4 +246,4 @@ class HeaterAccessory extends BaseAccessory { } } -module.exports = HeaterAccessory; \ No newline at end of file +module.exports = HeaterAccessory; From f128f8fff660c8db3231cdfbcc51d381a74437e7 Mon Sep 17 00:00:00 2001 From: joshua Date: Tue, 14 Mar 2023 16:17:32 +0100 Subject: [PATCH 2/2] fix(heater): divide maxRange by 10 so you can't set your heater to 370 celcius --- lib/heater_accessory.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/heater_accessory.js b/lib/heater_accessory.js index c4709b91..e95f1efc 100644 --- a/lib/heater_accessory.js +++ b/lib/heater_accessory.js @@ -226,6 +226,10 @@ class HeaterAccessory extends BaseAccessory { for (const funcDic of this.functionArr) { let valueRange = JSON.parse(funcDic.values) let isnull = (JSON.stringify(valueRange) == "{}") + if (!isnull) { + valueRange.min = valueRange.min / 10; + valueRange.max = valueRange.max / 10; + } switch (funcDic.code) { case 'temp_set': tempSetRange = isnull ? { 'min': 0, 'max': 50 } : { 'min': parseInt(valueRange.min), 'max': parseInt(valueRange.max) }