Skip to content

Commit

Permalink
Allow setting current temperature separately
Browse files Browse the repository at this point in the history
Add setter for currentTemperature and do no update current temperature when target temperature is set.
  • Loading branch information
jjknudsen authored May 31, 2023
1 parent 5dec019 commit 2180842
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/thermostat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ export default class Thermostat implements AccessoryPlugin {
private getCurrentTemperature(cb: CharacteristicGetCallback) {
cb(null, this.currentTemperature);
}

private setCurrentTemperature(
value: CharacteristicValue,
cb: CharacteristicSetCallback
) {
this.currentTemperature = value;

this.logger.debug(`Set CurrentTemperature to '${value}'`);
cb();
}

private getTargetTemperature(cb: CharacteristicGetCallback) {
cb(null, this.targetTemperature);
Expand All @@ -125,12 +135,6 @@ export default class Thermostat implements AccessoryPlugin {
) {
this.targetTemperature = value;

this.currentTemperature = value;
this.service.setCharacteristic(
this.Characteristic.CurrentTemperature,
value
);

this.logger.debug(`Set Temperature to '${value}'`);
cb();
}
Expand Down Expand Up @@ -176,7 +180,8 @@ export default class Thermostat implements AccessoryPlugin {

this.service
.getCharacteristic(this.Characteristic.CurrentTemperature)
.on('get', this.getCurrentTemperature.bind(this));
.on('get', this.getCurrentTemperature.bind(this))
.on('set', this.setCurrentTemperature.bind(this));

this.service
.getCharacteristic(this.Characteristic.TargetTemperature)
Expand Down

0 comments on commit 2180842

Please sign in to comment.