Skip to content

Commit

Permalink
Fixed issue with current temperature becoming less/more than the mini…
Browse files Browse the repository at this point in the history
…mum or maximum temperature
  • Loading branch information
lprhodes committed Apr 29, 2017
1 parent cbc368e commit e2932d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions accessories/aircon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class AirConAccessory extends BroadlinkRMAccessory {
state.targetTemperature = undefined
}

if (state.currentTemperature > this.config.maxTemperature) state.currentTemperature = this.config.maxTemperature;

state.targetHeatingCoolingState = state.currentHeatingCoolingState;
}

Expand Down Expand Up @@ -327,6 +325,9 @@ class AirConAccessory extends BroadlinkRMAccessory {
onTemperature = (temperature) => {
state.currentTemperature = temperature;

if (state.currentTemperature > this.config.maxTemperature) state.currentTemperature = this.config.minTemperature;
if (state.currentTemperature < this.config.minTemperature) state.currentTemperature = this.config.minTemperature;

if (this.removeTemperatureListenerTimer) clearTimeout(this.removeTemperatureListenerTimer)
device.removeListener('temperature', onTemperature);
this.processQueuedCallbacks();
Expand Down Expand Up @@ -364,15 +365,11 @@ class AirConAccessory extends BroadlinkRMAccessory {
}

setTargetTemperature (hexData, previousValue) {
const { config, name, state } = this;
const { config, log, name, state } = this;
const { minTemperature, maxTemperature } = config;

let error;

if (state.currentTemperature < minTemperature) error = new Error(`The target temperature (${this.targetTemperature}) must be more than the minTemperature (${minTemperature})`);
if (state.currentTemperature > maxTemperature) error = new Error(`The target temperature (${this.targetTemperature}) must be less than the maxTemperature (${maxTemperature})`);

if (error) throw error
if (state.targetTemperature < minTemperature) return log(`The target temperature (${this.targetTemperature}) must be more than the minTemperature (${minTemperature})`);
if (state.targetTemperature > maxTemperature) return log(`The target temperature (${this.targetTemperature}) must be less than the maxTemperature (${maxTemperature})`);

if (state.targetTemperature === previousValue) return

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-broadlink-rm",
"version": "2.3.0",
"version": "2.3.1",
"description": "Broadlink RM plugin (including the mini and pro) for homebridge: https://github.com/nfarina/homebridge",
"license": "ISC",
"keywords": [
Expand Down

0 comments on commit e2932d1

Please sign in to comment.