[radiothermostat] Ignore updates if thermostat data is invalid ()

* Ignore updates if data is invalid

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
mlobstein 2022-09-17 10:49:59 -05:00 committed by GitHub
parent 7dfb963f92
commit 8a9c66a567
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions
bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/handler

View File

@ -371,14 +371,18 @@ public class RadioThermostatHandler extends BaseThingHandler implements RadioThe
switch (evtKey) { switch (evtKey) {
case DEFAULT_RESOURCE: case DEFAULT_RESOURCE:
rthermData.setThermostatData(gson.fromJson(evtVal, RadioThermostatTstatDTO.class)); rthermData.setThermostatData(gson.fromJson(evtVal, RadioThermostatTstatDTO.class));
// if thermostat returned -1 for temperature, skip this update
if (rthermData.getThermostatData().getTemperature() >= 0) {
updateAllChannels(); updateAllChannels();
}
break; break;
case HUMIDITY_RESOURCE: case HUMIDITY_RESOURCE:
RadioThermostatHumidityDTO dto = gson.fromJson(evtVal, RadioThermostatHumidityDTO.class); 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()); rthermData.setHumidity(dto.getHumidity());
}
updateChannel(HUMIDITY, rthermData); updateChannel(HUMIDITY, rthermData);
}
break; break;
case RUNTIME_RESOURCE: case RUNTIME_RESOURCE:
rthermData.setRuntime(gson.fromJson(evtVal, RadioThermostatRuntimeDTO.class)); rthermData.setRuntime(gson.fromJson(evtVal, RadioThermostatRuntimeDTO.class));