Skip to content

Commit

Permalink
Additional fix for restoring air-conditioner values
Browse files Browse the repository at this point in the history
  • Loading branch information
lprhodes committed Apr 21, 2017
1 parent 66f65f2 commit 5104796
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions accessories/aircon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ class AirConAccessory extends BroadlinkRMAccessory {
correctReloadedState () {
this.state.lastUsedHeatingCoolingState = undefined;
this.state.lastUsedTemperature = undefined;

if (this.state.currentHeatingCoolingState === 0) {
this.state.targetTemperature = undefined
}

this.state.targetHeatingCoolingState = this.state.currentHeatingCoolingState;
}

constructor (log, config) {
Expand All @@ -22,8 +28,8 @@ class AirConAccessory extends BroadlinkRMAccessory {
if (state.currentHeatingCoolingState === undefined) state.currentHeatingCoolingState = Characteristic.CurrentHeatingCoolingState.OFF;
if (state.targetHeatingCoolingState === undefined) state.targetHeatingCoolingState = Characteristic.CurrentHeatingCoolingState.OFF;

if (!state.targetTemperature) state.targetTemperature = minTemperature || 0;
if (!state.firstTemperatureUpdate) state.firstTemperatureUpdate = true;
// if (state.targetTemperature === undefined) state.targetTemperature = minTemperature || 0;
if (state.firstTemperatureUpdate === undefined) state.firstTemperatureUpdate = true;

config.minTemperature = minTemperature || 0;
config.maxTemperature = maxTemperature || 30;
Expand Down Expand Up @@ -129,7 +135,7 @@ class AirConAccessory extends BroadlinkRMAccessory {
const { config, data, host, log, name, state } = this;
const { defaultHeatTemperature, defaultCoolTemperature, heatTemperature } = config;

log(`Potentially ${name} sendTemperature (${temperature})`);
log(`Potential ${name} sendTemperature (${temperature})`);

let hasTemperatureChanged = (state.targetTemperature !== temperature);
let hexData = data[`temperature${temperature}`];
Expand Down Expand Up @@ -167,7 +173,7 @@ class AirConAccessory extends BroadlinkRMAccessory {
this.thermostatService.setCharacteristic(Characteristic.TargetTemperature, state.targetTemperature);

state.lastUsedTemperature = state.targetTemperature;
state.lastUsedHeatingCoolingState= state.currentHeatingCoolingState;
state.lastUsedHeatingCoolingState = state.currentHeatingCoolingState;

sendData({ host, hexData: hexData.data, log });
}
Expand Down Expand Up @@ -284,7 +290,7 @@ class AirConAccessory extends BroadlinkRMAccessory {
})
}

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

Expand All @@ -295,7 +301,9 @@ class AirConAccessory extends BroadlinkRMAccessory {

if (error) throw error

this.sendTemperature(state.targetTemperature);
if (state.targetTemperature === previousValue) return

this.sendTemperature(state.targetTemperature, previousValue);
}

configKeyForCurrentHeatingCoolingState () {
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.0.3",
"version": "2.0.4",
"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 5104796

Please sign in to comment.