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

Adjust temperature range of kumo accessories #115

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions src/ductless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ export class KumoPlatformAccessory_ductless {
this.HumidityBattery.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
}

const tempStep = 0.1;
let minSetTemp: number, maxSetTemp: number, minGetTemp: number, maxGetTemp: number;
if (this.platform.kumo.isCelsiusUnits) {
minSetTemp = 9;
maxSetTemp = 32;
minGetTemp = -20;
maxGetTemp = 60;
} else {
minSetTemp = this.fahrenheitToCelsius(50);
maxSetTemp = this.fahrenheitToCelsius(90);
minGetTemp = this.fahrenheitToCelsius(0);
maxGetTemp = this.fahrenheitToCelsius(160);
}

// set temperature ranges
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
.setProps({ minStep: tempStep, minValue: minGetTemp, maxValue: maxGetTemp });
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TargetTemperature)
.setProps({ minStep: tempStep, minValue: minSetTemp, maxValue: maxSetTemp });
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
.setProps({ minStep: tempStep, minValue: minSetTemp, maxValue: maxSetTemp });
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
.setProps({ minStep: tempStep, minValue: minSetTemp, maxValue: maxSetTemp });

// create handlers for characteristics
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.Active)
.on('get', this.handleActiveGet.bind(this))
Expand Down Expand Up @@ -843,6 +867,10 @@ export class KumoPlatformAccessory_ductless {
private roundHalf(num: number) {
return Math.round(num*2)/2;
}

private fahrenheitToCelsius = function(temperature: number) {
return (temperature - 32) / 1.8;
};
}


31 changes: 30 additions & 1 deletion src/ductless_simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,31 @@ export class KumoPlatformAccessory_ductless_simple {
this.HumidityBattery.setCharacteristic(this.platform.Characteristic.ChargingState, this.platform.Characteristic.ChargingState.NOT_CHARGEABLE);
}

const tempStep = 0.1;
let minSetTemp: number, maxSetTemp: number, minGetTemp: number, maxGetTemp: number;
if (this.platform.kumo.isCelsiusUnits) {
minSetTemp = 9;
maxSetTemp = 32;
minGetTemp = -20;
maxGetTemp = 60;
} else {
minSetTemp = this.fahrenheitToCelsius(50);
maxSetTemp = this.fahrenheitToCelsius(90);
minGetTemp = this.fahrenheitToCelsius(0);
maxGetTemp = this.fahrenheitToCelsius(160);
}

// set temperature ranges
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
.setProps({ minStep: tempStep, minValue: minGetTemp, maxValue: maxGetTemp });
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.TargetTemperature)
.setProps({ minStep: tempStep, minValue: minSetTemp, maxValue: maxSetTemp });
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
.setProps({ minStep: tempStep, minValue: minSetTemp, maxValue: maxSetTemp });
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
.setProps({ minStep: tempStep, minValue: minSetTemp, maxValue: maxSetTemp });


// create handlers for characteristics
this.HeaterCooler.getCharacteristic(this.platform.Characteristic.Active)
.on('get', this.handleActiveGet.bind(this))
Expand Down Expand Up @@ -618,4 +643,8 @@ export class KumoPlatformAccessory_ductless_simple {
private roundHalf(num: number) {
return Math.round(num*2)/2;
}
}

private fahrenheitToCelsius = function(temperature: number) {
return (temperature - 32) / 1.8;
};
}
4 changes: 4 additions & 0 deletions src/kumo-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const KumoTokenExpirationWindow = KUMO_API_TOKEN_REFRESH_INTERVAL * 60 * 60 * 10
export class KumoApi {
//Devices!: Array<KumoDevice>;
devices;
isCelsiusUnits!: boolean;

private username: string;
private password: string;
Expand Down Expand Up @@ -166,6 +167,9 @@ export class KumoApi {

this.log.debug('Token: %s', this.securityToken);

// Set the temperature units.
this.isCelsiusUnits = data[1].celsius;

// Add the token to our headers that we will use for subsequent API calls.
//this.headers.SecurityToken = this.securityToken;

Expand Down
28 changes: 28 additions & 0 deletions src/platformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@ export class KumoPlatformAccessory {
this.Fan.setCharacteristic(this.platform.Characteristic.Name, 'Fan');
this.PowerSwitch.setCharacteristic(this.platform.Characteristic.Name, 'Power');

const tempStep = 0.1;
let minSetTemp: number, maxSetTemp: number, minGetTemp: number, maxGetTemp: number;
if (this.platform.kumo.isCelsiusUnits) {
minSetTemp = 9;
maxSetTemp = 32;
minGetTemp = -20;
maxGetTemp = 60;
} else {
minSetTemp = this.fahrenheitToCelsius(50);
maxSetTemp = this.fahrenheitToCelsius(90);
minGetTemp = this.fahrenheitToCelsius(0);
maxGetTemp = this.fahrenheitToCelsius(160);
}

// set temperature ranges
this.Thermostat.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
.setProps({ minStep: tempStep, minValue: minGetTemp, maxValue: maxGetTemp });
this.Thermostat.getCharacteristic(this.platform.Characteristic.TargetTemperature)
.setProps({ minStep: tempStep, minValue: minSetTemp, maxValue: maxSetTemp });
this.Thermostat.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
.setProps({ minStep: tempStep, minValue: minSetTemp, maxValue: maxSetTemp });
this.Thermostat.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
.setProps({ minStep: tempStep, minValue: minSetTemp, maxValue: maxSetTemp });

// create handlers for characteristics
this.Thermostat.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
.on('get', this.handleCurrentHeaterCoolerStateGet.bind(this));
Expand Down Expand Up @@ -716,4 +740,8 @@ export class KumoPlatformAccessory {
private roundHalf(num: number) {
return Math.round(num*2)/2;
}

private fahrenheitToCelsius = function(temperature: number) {
return (temperature - 32) / 1.8;
};
}