Skip to content

Commit

Permalink
Merge pull request iRayanKhan#258 from iRayanKhan/revert-251-main
Browse files Browse the repository at this point in the history
Revert "split factor variable for heater temperatures"
  • Loading branch information
iRayanKhan committed Apr 24, 2021
2 parents 9433f97 + fdb89b6 commit c107c85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
14 changes: 0 additions & 14 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 4 additions & 6 deletions lib/SimpleHeaterAccessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down Expand Up @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c107c85

Please sign in to comment.