Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(heater): multiply / divide by 10 to / from Tuya #351

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/heater_accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) }
Expand All @@ -246,4 +250,4 @@ class HeaterAccessory extends BaseAccessory {
}
}

module.exports = HeaterAccessory;
module.exports = HeaterAccessory;