Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
gitflow
.idea
node_modules
*.swp
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ NestThermostatAccessory.prototype.updateData = function (data) {
thermostat.getCharacteristic(Characteristic.CurrentRelativeHumidity).getValue();
thermostat.getCharacteristic(Characteristic.TargetHeatingCoolingState).getValue();
thermostat.getCharacteristic(Characteristic.TargetTemperature).getValue();
if (this.device.has_fan) {
var fan = this.getService(Service.Fan);
fan.getCharacteristic(Characteristic.On).getValue();
}
};

NestThermostatAccessory.prototype.getCurrentHeatingCooling = function () {
Expand Down
26 changes: 26 additions & 0 deletions lib/nest-thermostat-accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,40 @@ function NestThermostatAccessory(conn, log, device, structure) {
return val + "%";
});

thermostatService.getCharacteristic(Characteristic.TargetTemperature)
.setProps({
minStep: 0.5
});
bindCharacteristic(Characteristic.TargetTemperature, "Target temperature", this.getTargetTemperature, this.setTargetTemperature, formatAsDisplayTemperature);
bindCharacteristic(Characteristic.TargetHeatingCoolingState, "Target heating", this.getTargetHeatingCooling, this.setTargetHeatingCooling, formatHeatingCoolingState);

this.addAwayCharacteristic(thermostatService);

if (this.device.has_fan) {
var thermostatFanService = this.addService(Service.Fan);
var formatFanState = function (val) {
if (val) {
return "On";
}
return "Off";
};
this.bindCharacteristic(thermostatFanService, Characteristic.On, "Fan State", this.getFanState, this.setFanState, formatFanState);
}
this.updateData();
}

NestThermostatAccessory.prototype.getFanState = function () {
return this.device.fan_timer_active;
};

NestThermostatAccessory.prototype.setFanState = function (targetFanState, callback) {

this.log("Setting target fan state for " + this.name + " to: " + targetFanState);

return this.updateDevicePropertyAsync("fan_timer_active", !!targetFanState, "fan enable/disable")
.asCallback(callback);
};

NestThermostatAccessory.prototype.getCurrentHeatingCooling = function () {
switch (this.device.hvac_state) {
case "off":
Expand Down