Skip to content

Commit

Permalink
Merge pull request #6 from bwdeleeuw/min.-temp-issue
Browse files Browse the repository at this point in the history
Fix for minimum target temperature of 10C, 50F
  • Loading branch information
bwdeleeuw authored Nov 6, 2016
2 parents 4641688 + c0ee201 commit c653606
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,27 @@ function tccThermostatAccessory(log, name, deviceData, username, password, devic
this.log = log;
}

function toFahrenheit(temperature) {
return ((temperature * 9 / 5) + 32);
}

function toCelsius(temperature) {
return ((temperature - 32) * 5 / 9);
}

tccThermostatAccessory.prototype = {

getCurrentTemperature: function(callback) {
var that = this;

var currentTemperature = this.device.latestData.uiData.DispTemperature;
that.log("Current temperature of " + this.name + " is " + currentTemperature + "°");
switch (this.device.latestData.uiData.DisplayUnits) {
case "F":
currentTemperature = (currentTemperature - 32) * 5 / 9;
currentTemperature = toCelsius(currentTemperature);
break;
}
callback(null, Number(currentTemperature));
that.log("Current temperature of " + this.name + " is " + currentTemperature + "°");
},

getCurrentHeatingCoolingState: function(callback) {
Expand Down Expand Up @@ -231,7 +239,7 @@ tccThermostatAccessory.prototype = {
// verify that the task did succeed
switch (this.device.latestData.uiData.DisplayUnits) {
case "F":
value = (value * 9 / 5) + 32;
value = toFahrenheit(value);
break;
}

Expand Down Expand Up @@ -266,7 +274,7 @@ tccThermostatAccessory.prototype = {
}
switch (this.device.latestData.uiData.DisplayUnits) {
case "F":
targetTemperature = (targetTemperature - 32) * 5 / 9;
targetTemperature = toCelsius(targetTemperature);
break;
}
callback(null, Number(targetTemperature));
Expand Down

0 comments on commit c653606

Please sign in to comment.