From fdb89b6a6b84ae0158cc64b314b9b4ddaf2d55fb Mon Sep 17 00:00:00 2001 From: Rayan Khan Date: Sat, 24 Apr 2021 01:44:06 -0500 Subject: [PATCH] Revert "split factor variable for heater temperatures" --- config.schema.json | 14 -------------- lib/SimpleHeaterAccessory.js | 10 ++++------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/config.schema.json b/config.schema.json index 927cd4f6..196f40e8 100644 --- a/config.schema.json +++ b/config.schema.json @@ -413,20 +413,6 @@ "functionBody": "return model.devices && model.devices[arrayIndices] && ['SimpleHeater'].includes(model.devices[arrayIndices].type);" } }, - "thresholdTemperatureDivisor": { - "type": "integer", - "placeholder": "1", - "condition": { - "functionBody": "return model.devices && model.devices[arrayIndices] && ['SimpleHeater'].includes(model.devices[arrayIndices].type);" - } - }, - "targetTemperatureDivisor": { - "type": "integer", - "placeholder": "1", - "condition": { - "functionBody": "return model.devices && model.devices[arrayIndices] && ['SimpleHeater'].includes(model.devices[arrayIndices].type);" - } - }, "dpAction": { "type": "integer", "placeholder": "1", diff --git a/lib/SimpleHeaterAccessory.js b/lib/SimpleHeaterAccessory.js index 4308273a..a3112155 100644 --- a/lib/SimpleHeaterAccessory.js +++ b/lib/SimpleHeaterAccessory.js @@ -26,8 +26,6 @@ class SimpleHeaterAccessory extends BaseAccessory { this.dpDesiredTemperature = this._getCustomDP(this.device.context.dpDesiredTemperature) || '2'; this.dpCurrentTemperature = this._getCustomDP(this.device.context.dpCurrentTemperature) || '3'; this.temperatureDivisor = parseInt(this.device.context.temperatureDivisor) || 1; - this.thresholdTemperatureDivisor = parseInt(this.device.context.thresholdTemperatureDivisor) || 1; - this.targetTemperatureDivisor = parseInt(this.device.context.targetTemperatureDivisor) || 1; const characteristicActive = service.getCharacteristic(Characteristic.Active) .updateValue(this._getActive(dps[this.dpActive])) @@ -59,8 +57,8 @@ class SimpleHeaterAccessory extends BaseAccessory { maxValue: this.device.context.maxTemperature || 35, minStep: this.device.context.minTemperatureSteps || 1 }) - .updateValue(this._getDividedState(dps[this.dpDesiredTemperature], this.thresholdTemperatureDivisor)) - .on('get', this.getDividedState.bind(this, this.dpDesiredTemperature, this.thresholdTemperatureDivisor)) + .updateValue(this._getDividedState(dps[this.dpDesiredTemperature], this.temperatureDivisor)) + .on('get', this.getDividedState.bind(this, this.dpDesiredTemperature, this.temperatureDivisor)) .on('set', this.setTargetThresholdTemperature.bind(this)); this.characteristicHeatingThresholdTemperature = characteristicHeatingThresholdTemperature; @@ -75,7 +73,7 @@ class SimpleHeaterAccessory extends BaseAccessory { if (changes.hasOwnProperty(this.dpDesiredTemperature)) { if (characteristicHeatingThresholdTemperature.value !== changes[this.dpDesiredTemperature]) - characteristicHeatingThresholdTemperature.updateValue(changes[this.dpDesiredTemperature * this.targetTemperatureDivisor]); + characteristicHeatingThresholdTemperature.updateValue(changes[this.dpDesiredTemperature * this.temperatureDivisor]); } if (changes.hasOwnProperty(this.dpCurrentTemperature) && characteristicCurrentTemperature.value !== changes[this.dpCurrentTemperature]) characteristicCurrentTemperature.updateValue(this._getDividedState(changes[this.dpCurrentTemperature], this.temperatureDivisor)); @@ -139,7 +137,7 @@ class SimpleHeaterAccessory extends BaseAccessory { } setTargetThresholdTemperature(value, callback) { - this.setState(this.dpDesiredTemperature, value * this.thresholdTemperatureDivisor, err => { + this.setState(this.dpDesiredTemperature, value * this.temperatureDivisor, err => { if (err) return callback(err); if (this.characteristicHeatingThresholdTemperature) {