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

Revert "split factor variable for heater temperatures" #258

Merged
merged 1 commit into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
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
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