Skip to content

Commit

Permalink
Additional fixes for thermostat
Browse files Browse the repository at this point in the history
  • Loading branch information
kuestess committed Sep 27, 2022
1 parent 68bba83 commit dc4720b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

All notable changes to this project will be documented in this file.
## 0.5.4-2
- [FIXED] Fix for setting thermostat mode
- [ENHANCED] Additional debugging for temp setting
## 0.5.4-1
- [FIXED] Fix for temperature units
## 0.5.4
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"displayName": "InsteonLocal",
"name": "homebridge-platform-insteonlocal",
"version": "0.5.4-1",
"version": "0.5.4-2",
"description": "Insteon platform plugin with local control for homebridge: https://github.com/nfarina/homebridge",
"license": "ISC",
"repository": {
Expand Down
30 changes: 18 additions & 12 deletions src/InsteonLocalAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1970,31 +1970,33 @@ export class InsteonLocalAccessory {

let theTemp;

this.log('Setting ' + this.name + ' temperature to ' + temp);

this.platform.checkHubConnection();
this.lastUpdate = moment();

if(this.unit == 'F'){
theTemp = convertTemp('C', 'F', temp);
theTemp = Math.round(convertTemp('C', 'F', temp));
} else {
theTemp = temp;
theTemp = Math.round(temp);
}

this.log('Setting ' + this.name + ' temperature to ' + theTemp);

this.platform.checkHubConnection();
this.lastUpdate = moment();

if(this.mode == 'cool'){
this.thermostat.coolTemp(theTemp, (response)=>{
if(!response || typeof(response) === 'undefined'){
this.thermostat.coolTemp(theTemp, (err, response)=>{
if(err || !response || typeof(response) === 'undefined'){
return new Error('Thermostat did not return status');
}
this.log.debug(util.inspect(response));

this.service.getCharacteristic(this.platform.Characteristic.TargetTemperature).updateValue(temp);
this.targetTemp = temp;
});
} else if(this.mode == 'heat'){
this.thermostat.heatTemp(theTemp, (response)=>{
if(!response || typeof(response) === 'undefined'){
this.thermostat.heatTemp(theTemp, (err, response)=>{
if(err || !response || typeof(response) === 'undefined'){
return new Error('Thermostat did not return status');
}
this.log.debug(util.inspect(response));

this.service.getCharacteristic(this.platform.Characteristic.TargetTemperature).updateValue(temp);
this.targetTemp = temp;
Expand Down Expand Up @@ -2038,7 +2040,11 @@ export class InsteonLocalAccessory {

this.platform.checkHubConnection();
this.log.debug('Set ' + this.name + ' mode to ' + mode);
mode == 1 ? mode='heat' : mode='cool';
if(mode == 0) {
mode = 'off';
} else {
mode == 1 ? mode='heat' : mode='cool';
}

this.lastUpdate = moment();
this.thermostat.mode(mode, (err, response)=>{
Expand Down

0 comments on commit dc4720b

Please sign in to comment.