Skip to content

Commit

Permalink
Rebuilt temperature and humidity monitoring to use updateValue method #…
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwi-cam committed Sep 25, 2024
1 parent 4527409 commit 802d896
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- refreshCharacteristic and value() were not updating the UI. Rebuilt to use updateValue method. (#733)

## [4.4.18 - 2024-08-08]
### Added
- Added ping state change logging for troubleshooting
Expand Down
7 changes: 5 additions & 2 deletions accessories/aircon.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ class AirConAccessory extends BroadlinkRMAccessory {

this.updateTemperatureUI();
if (!config.isUnitTest) {setInterval(()=>{this.getCurrentTemperature(this.updateTemperatureUI.bind(this))}, config.temperatureUpdateFrequency * 1000)}
//if (!config.isUnitTest) {setInterval(this.updateTemperatureUI.bind(this), config.temperatureUpdateFrequency * 1000)}
}

onTemperature (temperature,humidity) {
Expand Down Expand Up @@ -617,8 +618,10 @@ class AirConAccessory extends BroadlinkRMAccessory {
const { config, serviceManager } = this;
const { noHumidity } = config;

serviceManager.refreshCharacteristicUI(Characteristic.CurrentTemperature);
if(!noHumidity){serviceManager.refreshCharacteristicUI(Characteristic.CurrentRelativeHumidity);}
//serviceManager.refreshCharacteristicUI(Characteristic.CurrentTemperature);
//if(!noHumidity){serviceManager.refreshCharacteristicUI(Characteristic.CurrentRelativeHumidity);}
serviceManager.updateCharacteristicUI(Characteristic.CurrentTemperature, this.state.currentTemperature);
if(!noHumidity){serviceManager.updateCharacteristic(Characteristic.CurrentRelativeHumidity, this.state.currentHumidity);}
}

getCurrentTemperature (callback) {
Expand Down
5 changes: 3 additions & 2 deletions accessories/humidifier-dehumidifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class HumidifierDehumidifierAccessory extends FanAccessory {
device.checkHumidity();

this.updateHumidityUI();
if (!config.isUnitTest && !config.noHumidity) {setInterval(()=>{this.getCurrentHumidity(this.updateHumidityUI.bind(this))}, config.humidityUpdateFrequency * 1000)}
if (!config.isUnitTest && !config.noHumidity) {setInterval(this.updateHumidityUI.bind(this), config.humidityUpdateFrequency * 1000)}
}

onHumidity (temperature,humidity) {
Expand Down Expand Up @@ -426,7 +426,8 @@ class HumidifierDehumidifierAccessory extends FanAccessory {
updateHumidityUI () {
const { config, serviceManager } = this;

serviceManager.refreshCharacteristicUI(Characteristic.CurrentRelativeHumidity);
//serviceManager.refreshCharacteristicUI(Characteristic.CurrentRelativeHumidity);
serviceManager.updateCharacteristic(Characteristic.CurrentRelativeHumidity, this.state.currentHumidity);
}

getCurrentHumidity (callback) {
Expand Down
7 changes: 6 additions & 1 deletion helpers/serviceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ class ServiceManager {
this.service.setCharacteristic(characteristic, value);
}

updateCharacteristic (characteristic, value) {
this.service.getCharacteristic(characteristic).updateValue(value);
}

getCharacteristic (characteristic) {
return this.service.getCharacteristic(characteristic)
}

refreshCharacteristicUI (characteristic) {
this.getCharacteristic(characteristic).value;
//Historically, we refreshed the UI using getValue(). This is being depricated and replaced by the parameter value, which unfortunately does not refresh the UI, instaed use updateCharacteristic(characteristic, value)
this.service.getCharacteristic(characteristic).value;
}

// Convenience
Expand Down

0 comments on commit 802d896

Please sign in to comment.