Skip to content

Commit

Permalink
[radiothermostat] Ignore updates if thermostat data is invalid (openh…
Browse files Browse the repository at this point in the history
…ab#13394)

* Ignore updates if data is invalid

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
  • Loading branch information
mlobstein authored and andrasU committed Nov 12, 2022
1 parent 7186e6f commit 32550e3
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,18 @@ public void onNewMessageEvent(RadioThermostatEvent event) {
switch (evtKey) {
case DEFAULT_RESOURCE:
rthermData.setThermostatData(gson.fromJson(evtVal, RadioThermostatTstatDTO.class));
updateAllChannels();
// if thermostat returned -1 for temperature, skip this update
if (rthermData.getThermostatData().getTemperature() >= 0) {
updateAllChannels();
}
break;
case HUMIDITY_RESOURCE:
RadioThermostatHumidityDTO dto = gson.fromJson(evtVal, RadioThermostatHumidityDTO.class);
if (dto != null) {
// if thermostat returned -1 for humidity, skip this update
if (dto != null && dto.getHumidity() >= 0) {
rthermData.setHumidity(dto.getHumidity());
updateChannel(HUMIDITY, rthermData);
}
updateChannel(HUMIDITY, rthermData);
break;
case RUNTIME_RESOURCE:
rthermData.setRuntime(gson.fromJson(evtVal, RadioThermostatRuntimeDTO.class));
Expand Down

0 comments on commit 32550e3

Please sign in to comment.