diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f3f9c3..18aa183 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index 3465f62..00e7041 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/InsteonLocalAccessory.ts b/src/InsteonLocalAccessory.ts index 834f0b6..384e833 100644 --- a/src/InsteonLocalAccessory.ts +++ b/src/InsteonLocalAccessory.ts @@ -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; @@ -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)=>{