Fixed thermostats to report celsius.

This commit is contained in:
Mike Riccio
2015-10-15 21:31:08 -07:00
parent 6fa69c5c4b
commit aad811fe6e

View File

@@ -226,34 +226,42 @@ IndigoAccessory.prototype = {
} }
}, },
// Note: HomeKit wants all temperature values to be in celsius
getCurrentTemperature: function(callback) {
this.query("displayRawState", function(temperature) {
callback((temperature - 32.0) * 5.0 / 9.0);
});
},
getTargetTemperature: function(callback) { getTargetTemperature: function(callback) {
this.getStatus(function(json) { this.getStatus(function(json) {
var result; var temperature;
if (json["hvacOperatonModeIsHeat"]) { if (json["hvacOperatonModeIsHeat"]) {
result = json["setpointHeat"]; temperature = json["setpointHeat"];
} }
else if (json["hvacOperationModeIsCool"]) { else if (json["hvacOperationModeIsCool"]) {
result = json["setpointCool"]; temperature = json["setpointCool"];
} }
else { else {
result = (json["setpointHeat"] + json["setpointCool"]) / 2; temperature = (json["setpointHeat"] + json["setpointCool"]) / 2.0;
} }
callback(result); callback((temperature - 32.0) * 5.0 / 9.0);
}); });
}, },
setTargetTemperature: function(temperature) { setTargetTemperature: function(temperature) {
var that = this; var that = this;
var t = (temperature * 9.0 / 5.0) + 32.0;
this.getStatus(function(json) { this.getStatus(function(json) {
if (json["hvacOperatonModeIsHeat"]) { if (json["hvacOperatonModeIsHeat"]) {
that.updateStatus("setpointHeat=" + temperature); that.updateStatus("setpointHeat=" + t);
} }
else if (json["hvacOperationModeIsCool"]) { else if (json["hvacOperationModeIsCool"]) {
that.updateStatus("setpointCool=" + temperature); that.updateStatus("setpointCool=" + t);
} }
else { else {
var cool = temperature + 5; var cool = t + 5;
var heat = temperature - 5; var heat = t - 5;
that.updateStatus("setpointCool=" + cool + "&setpointHeat=" + heat); that.updateStatus("setpointCool=" + cool + "&setpointHeat=" + heat);
} }
}); });
@@ -328,14 +336,12 @@ IndigoAccessory.prototype = {
designedMaxLength: 255 designedMaxLength: 255
}]; }];
/* if (that.typeSupportsOnOff)
{ */
cTypes.push({ cTypes.push({
cType: types.POWER_STATE_CTYPE, cType: types.POWER_STATE_CTYPE,
perms: [Characteristic.Perms.WRITE,Characteristic.Perms.READ,Characteristic.Perms.NOTIFY], perms: [Characteristic.Perms.WRITE,Characteristic.Perms.READ,Characteristic.Perms.NOTIFY],
format: Characteristic.Formats.BOOL, format: Characteristic.Formats.BOOL,
initialValue: (that.isOn) ? 1 : 0, initialValue: (that.isOn) ? 1 : 0,
supportEvents: true, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Change the power state", manfDescription: "Change the power state",
designedMaxLength: 1, designedMaxLength: 1,
@@ -352,15 +358,14 @@ IndigoAccessory.prototype = {
}); });
} }
}); });
// }
if (that.typeSupportsDim) if (that.typeSupportsDim) {
{
cTypes.push({ cTypes.push({
cType: types.BRIGHTNESS_CTYPE, cType: types.BRIGHTNESS_CTYPE,
perms: [Characteristic.Perms.WRITE,Characteristic.Perms.READ,Characteristic.Perms.NOTIFY], perms: [Characteristic.Perms.WRITE,Characteristic.Perms.READ,Characteristic.Perms.NOTIFY],
format: Characteristic.Formats.INT, format: Characteristic.Formats.INT,
initialValue: that.brightness, initialValue: that.brightness,
supportEvents: true, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Adjust Brightness of Light", manfDescription: "Adjust Brightness of Light",
designedMinValue: 0, designedMinValue: 0,
@@ -375,14 +380,14 @@ IndigoAccessory.prototype = {
} }
}); });
} }
if (that.typeSupportsSpeedControl)
{ if (that.typeSupportsSpeedControl) {
cTypes.push({ cTypes.push({
cType: types.ROTATION_SPEED_CTYPE, cType: types.ROTATION_SPEED_CTYPE,
perms: [Characteristic.Perms.WRITE,Characteristic.Perms.READ,Characteristic.Perms.NOTIFY], perms: [Characteristic.Perms.WRITE,Characteristic.Perms.READ,Characteristic.Perms.NOTIFY],
format: Characteristic.Formats.INT, format: Characteristic.Formats.INT,
initialValue: 0, initialValue: 0,
supportEvents: true, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Change the speed of the fan", manfDescription: "Change the speed of the fan",
designedMaxLength: 1, designedMaxLength: 1,
@@ -397,14 +402,14 @@ IndigoAccessory.prototype = {
} }
}); });
} }
if (that.typeSupportsHVAC)
{ if (that.typeSupportsHVAC) {
cTypes.push({ cTypes.push({
cType: types.CURRENTHEATINGCOOLING_CTYPE, cType: types.CURRENTHEATINGCOOLING_CTYPE,
perms: [Characteristic.Perms.READ,Characteristic.Perms.NOTIFY], perms: [Characteristic.Perms.READ,Characteristic.Perms.NOTIFY],
format: Characteristic.Formats.INT, format: Characteristic.Formats.INT,
initialValue: 0, initialValue: 0,
supportEvents: true, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Current Mode", manfDescription: "Current Mode",
designedMaxLength: 1, designedMaxLength: 1,
@@ -416,12 +421,13 @@ IndigoAccessory.prototype = {
that.getCurrentHeatingCooling(callback); that.getCurrentHeatingCooling(callback);
} }
}); });
cTypes.push({ cTypes.push({
cType: types.TARGETHEATINGCOOLING_CTYPE, cType: types.TARGETHEATINGCOOLING_CTYPE,
perms: [Characteristic.Perms.WRITE,Characteristic.Perms.READ,Characteristic.Perms.NOTIFY], perms: [Characteristic.Perms.WRITE,Characteristic.Perms.READ,Characteristic.Perms.NOTIFY],
format: Characteristic.Formats.INT, format: Characteristic.Formats.INT,
initialValue: 0, initialValue: 0,
supportEvents: true, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Target Mode", manfDescription: "Target Mode",
designedMaxLength: 1, designedMaxLength: 1,
@@ -435,6 +441,7 @@ IndigoAccessory.prototype = {
that.getCurrentHeatingCooling(callback); that.getCurrentHeatingCooling(callback);
} }
}); });
cTypes.push({ cTypes.push({
cType: types.CURRENT_TEMPERATURE_CTYPE, cType: types.CURRENT_TEMPERATURE_CTYPE,
perms: [Characteristic.Perms.READ,Characteristic.Perms.NOTIFY], perms: [Characteristic.Perms.READ,Characteristic.Perms.NOTIFY],
@@ -443,15 +450,16 @@ IndigoAccessory.prototype = {
designedMaxValue: 110, designedMaxValue: 110,
designedMinStep: 1, designedMinStep: 1,
initialValue: 0, initialValue: 0,
supportEvents: true, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Current Temperature", manfDescription: "Current Temperature",
unit: Characteristic.Units.FAHRENHEIT, unit: Characteristic.Units.FAHRENHEIT,
onUpdate: null, onUpdate: null,
onRead: function(callback) { onRead: function(callback) {
that.query("displayRawState", callback); that.getCurrentTemperature(callback);
} }
}); });
cTypes.push({ cTypes.push({
cType: types.TARGET_TEMPERATURE_CTYPE, cType: types.TARGET_TEMPERATURE_CTYPE,
perms: [Characteristic.Perms.WRITE,Characteristic.Perms.READ,Characteristic.Perms.NOTIFY], perms: [Characteristic.Perms.WRITE,Characteristic.Perms.READ,Characteristic.Perms.NOTIFY],
@@ -460,7 +468,7 @@ IndigoAccessory.prototype = {
designedMaxValue: 110, designedMaxValue: 110,
designedMinStep: 1, designedMinStep: 1,
initialValue: 0, initialValue: 0,
supportEvents: true, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Target Temperature", manfDescription: "Target Temperature",
unit: Characteristic.Units.FAHRENHEIT, unit: Characteristic.Units.FAHRENHEIT,
@@ -471,6 +479,7 @@ IndigoAccessory.prototype = {
that.getTargetTemperature(callback); that.getTargetTemperature(callback);
} }
}); });
cTypes.push({ cTypes.push({
cType: types.TEMPERATURE_UNITS_CTYPE, cType: types.TEMPERATURE_UNITS_CTYPE,
perms: [Characteristic.Perms.READ,Characteristic.Perms.NOTIFY], perms: [Characteristic.Perms.READ,Characteristic.Perms.NOTIFY],