From 3f20fa3527be373eb07b61763e46aaceda23c0e2 Mon Sep 17 00:00:00 2001 From: Chris Murton Date: Tue, 21 Sep 2021 20:26:06 +0100 Subject: [PATCH 1/5] Fix reference to allow change to target humidity --- lib/DehumidifierAccessory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DehumidifierAccessory.js b/lib/DehumidifierAccessory.js index f8121617..889354ef 100644 --- a/lib/DehumidifierAccessory.js +++ b/lib/DehumidifierAccessory.js @@ -136,7 +136,7 @@ class DehumidifierAccessory extends BaseAccessory { } } - if (changes.hasOwnProperty('Humidity') && this.characteristicHumidity.value !== changes[this.getDp('Humidity')]) this.characteristicHumidity.updateValue(changes[this.getDp('Humidity')]); + if (changes.hasOwnProperty(this.getDp('Humidity')) && this.characteristicHumidity.value !== changes[this.getDp('Humidity')]) this.characteristicHumidity.updateValue(changes[this.getDp('Humidity')]); if (characteristicChildLock && changes.hasOwnProperty(this.getDp('ChildLock'))) { const newChildLock = this._getLockTargetState(changes[this.getDp('ChildLock')]); From f5ebdd792b31a6fb10c94c84946ab4ac6ece56c1 Mon Sep 17 00:00:00 2001 From: Chris Murton Date: Tue, 21 Sep 2021 21:42:19 +0100 Subject: [PATCH 2/5] Fix current humidity change --- lib/DehumidifierAccessory.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/DehumidifierAccessory.js b/lib/DehumidifierAccessory.js index 889354ef..83788f25 100644 --- a/lib/DehumidifierAccessory.js +++ b/lib/DehumidifierAccessory.js @@ -137,6 +137,7 @@ class DehumidifierAccessory extends BaseAccessory { } if (changes.hasOwnProperty(this.getDp('Humidity')) && this.characteristicHumidity.value !== changes[this.getDp('Humidity')]) this.characteristicHumidity.updateValue(changes[this.getDp('Humidity')]); + if (changes.hasOwnProperty(this.getDp('CurrentHumidity')) && characteristicCurrentHumidity.value !== changes[this.getDp('CurrentHumidity')]) t.characteristicCurrentHumidity.updateValue(changes[this.getDp('CurrentHumidity')]); if (characteristicChildLock && changes.hasOwnProperty(this.getDp('ChildLock'))) { const newChildLock = this._getLockTargetState(changes[this.getDp('ChildLock')]); From e628ac24987dcd30a00b76ac86c1ab5c2a2c222f Mon Sep 17 00:00:00 2001 From: Chris Murton Date: Tue, 21 Sep 2021 20:33:11 +0100 Subject: [PATCH 3/5] Correct tracking of fan speed changes --- lib/DehumidifierAccessory.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/DehumidifierAccessory.js b/lib/DehumidifierAccessory.js index 83788f25..e59937bf 100644 --- a/lib/DehumidifierAccessory.js +++ b/lib/DehumidifierAccessory.js @@ -131,7 +131,7 @@ class DehumidifierAccessory extends BaseAccessory { characteristicActive.updateValue(newActive); if (!changes.hasOwnProperty(this.getDp('FanSpeed'))) { - characteristicRotationSpeed.updateValue(this._getRotationSpeed(state)); + characteristicSpeed.updateValue(this._getRotationSpeed(state)); } } } @@ -144,9 +144,9 @@ class DehumidifierAccessory extends BaseAccessory { if (characteristicChildLock.value !== newChildLock) characteristicChildLock.updateValue(newChildLock); } - if (changes.hasOwnProperty(this.getDp('FanSpeed'))) { - const newSpeed = this._getRotationSpeed(state); - if (characteristicSpeed.value !== newSpeed) characteristicSpeed.updateValue(newSpeed); + if (characteristicRotationSpeed && changes.hasOwnProperty(this.getDp('FanSpeed'))) { + const newRotationSpeed = this._getRotationSpeed(state); + if (characteristicRotationSpeed.value !== newRotationSpeed) characteristicRotationSpeed.updateValue(newRotationSpeed); } }); } From 8d6eddef9a44cddfa031c54c635eb4331c007501 Mon Sep 17 00:00:00 2001 From: Chris Murton Date: Tue, 21 Sep 2021 20:55:13 +0100 Subject: [PATCH 4/5] Handle dehumidifier devices without temperature sensor --- lib/DehumidifierAccessory.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/DehumidifierAccessory.js b/lib/DehumidifierAccessory.js index e59937bf..e0e15e9b 100644 --- a/lib/DehumidifierAccessory.js +++ b/lib/DehumidifierAccessory.js @@ -33,7 +33,9 @@ class DehumidifierAccessory extends BaseAccessory { _registerPlatformAccessory() { const {Service} = this.hap; - this.accessory.addService(Service.TemperatureSensor, this.device.context.name); + if (!this.device.context.noTemperature) { + this.accessory.addService(Service.TemperatureSensor, this.device.context.name); + } this.accessory.addService(Service.HumiditySensor, this.device.context.name); this.accessory.addService(Service.HumidifierDehumidifier, this.device.context.name); @@ -55,11 +57,12 @@ class DehumidifierAccessory extends BaseAccessory { infoService.getCharacteristic(Characteristic.Manufacturer).updateValue(this.device.context.manufacturer); infoService.getCharacteristic(Characteristic.Model).updateValue(this.device.context.model); - const characteristicTemperature = this.accessory.getService(Service.TemperatureSensor) - .getCharacteristic(Characteristic.CurrentTemperature) - .updateValue(this._getCurrentTemperature(dps[this.getDp('CurrentTemperature')])) - .on('get', this.getCurrentTemperature.bind(this)); - + if (!this.device.context.noTemperature) { + const characteristicTemperature = this.accessory.getService(Service.TemperatureSensor) + .getCharacteristic(Characteristic.CurrentTemperature) + .updateValue(this._getCurrentTemperature(dps[this.getDp('CurrentTemperature')])) + .on('get', this.getCurrentTemperature.bind(this)); + } const characteristicCurrentHumidity = this.accessory.getService(Service.HumiditySensor) .getCharacteristic(Characteristic.CurrentRelativeHumidity) From 3cb30c9b84ad8891f93127bbd307fb177cff05c0 Mon Sep 17 00:00:00 2001 From: Chris Murton Date: Tue, 21 Sep 2021 22:00:04 +0100 Subject: [PATCH 5/5] Match RotationSpeed nomenclature from other accessories --- lib/DehumidifierAccessory.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/DehumidifierAccessory.js b/lib/DehumidifierAccessory.js index e0e15e9b..647cef01 100644 --- a/lib/DehumidifierAccessory.js +++ b/lib/DehumidifierAccessory.js @@ -72,10 +72,10 @@ class DehumidifierAccessory extends BaseAccessory { const service = this.accessory.getService(Service.HumidifierDehumidifier); this._checkServiceName(service, this.device.context.name); - let characteristicSpeed; + let characteristicRotationSpeed; if (!this.device.context.noSpeed) { let fanService = this.accessory.getService(Service.Fan); - characteristicSpeed = fanService.getCharacteristic(Characteristic.RotationSpeed) + characteristicRotationSpeed = fanService.getCharacteristic(Characteristic.RotationSpeed) .setProps({ minValue: this.device.context.minSpeed || 1, maxValue: this.device.context.maxSpeed || 2, @@ -134,7 +134,7 @@ class DehumidifierAccessory extends BaseAccessory { characteristicActive.updateValue(newActive); if (!changes.hasOwnProperty(this.getDp('FanSpeed'))) { - characteristicSpeed.updateValue(this._getRotationSpeed(state)); + characteristicRotationSpeed.updateValue(this._getRotationSpeed(state)); } } }