Skip to content

Commit

Permalink
Support target heating cooling state
Browse files Browse the repository at this point in the history
  • Loading branch information
awaescher committed Jan 15, 2024
1 parent 1813abd commit 40c492d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/EltakoThermostatAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ export class EltakoThermostatAccessory implements IUpdatableAccessory {
maxValue: this.platform.Characteristic.CurrentHeatingCoolingState.HEAT,
});

this.service.getCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState)
.onGet(this.getTargetHeatingCoolingState.bind(this))
.onSet(this.setTargetHeatingCoolingState.bind(this))
.setProps({
validValues: [
this.platform.Characteristic.TargetHeatingCoolingState.OFF,
this.platform.Characteristic.TargetHeatingCoolingState.HEAT,
],
maxValue: this.platform.Characteristic.TargetHeatingCoolingState.HEAT,
});

this.service.getCharacteristic(this.platform.Characteristic.TargetTemperature)
.onGet(this.getTargetTemperature.bind(this))
.onSet(this.setTargetTemperature.bind(this));
Expand All @@ -49,7 +60,6 @@ export class EltakoThermostatAccessory implements IUpdatableAccessory {
}

getCurrentHeatingCoolingState(): CharacteristicValue {

const state = this.platform.deviceStateCache.find(s => s.sid === this.accessory.context.device.info.sid);
const mode = state?.state?.operation_mode ?? '';

Expand All @@ -65,6 +75,14 @@ export class EltakoThermostatAccessory implements IUpdatableAccessory {
await this.platform.miniSafe.sendGenericCommandWithValue(this.accessory.context.device.info.sid, 'operation_mode', operationMode);
}

getTargetHeatingCoolingState(): CharacteristicValue {
return this.getCurrentHeatingCoolingState();
}

async setTargetHeatingCoolingState(value: CharacteristicValue) {
this.setCurrentHeatingCoolingState(value);
}

getTargetTemperature(): CharacteristicValue {
const state = this.platform.deviceStateCache.find(s => s.sid === this.accessory.context.device.info.sid);
return state?.state?.setpoint ?? 0;
Expand All @@ -89,6 +107,10 @@ export class EltakoThermostatAccessory implements IUpdatableAccessory {
.getCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState)
.updateValue(this.getCurrentHeatingCoolingState());

this.service
.getCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState)
.updateValue(this.getTargetHeatingCoolingState());

this.service
.getCharacteristic(this.platform.Characteristic.TargetTemperature)
.updateValue(this.getTargetTemperature());
Expand Down

0 comments on commit 40c492d

Please sign in to comment.