[plugwiseha] Fix bug introduced with #12349 (#12366)

* Fix bug introduced with #12349

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2022-02-25 13:33:58 +01:00 committed by GitHub
parent 0737ee6bef
commit da0234f69c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 7 deletions

View File

@ -35,8 +35,12 @@ public class ActuatorFunctionalities extends PlugwiseHACollection<ActuatorFuncti
.map(Boolean::parseBoolean);
}
public Optional<String> getRegulationControl() {
return this.getFunctionalityThermostat().flatMap(ActuatorFunctionality::getRegulationControl);
public String getRegulationControl() {
ActuatorFunctionality functionality = this.getFunctionalityThermostat().orElse(null);
if (functionality != null) {
return functionality.getRegulationControl();
}
return null;
}
public Optional<Boolean> getCoolingAllowed() {

View File

@ -81,8 +81,8 @@ public class ActuatorFunctionality extends PlugwiseBaseModel implements Plugwise
return updatedDate;
}
public Optional<String> getRegulationControl() {
return Optional.ofNullable(regulationControl);
public String getRegulationControl() {
return regulationControl;
}
public Optional<String> getCoolingAllowed() {

View File

@ -109,8 +109,11 @@ public class Location extends PlugwiseBaseModel implements PlugwiseComparableDat
return this.actuatorFunctionalities.getCoolingAllowed();
}
public Optional<String> getRegulationControl() {
return this.actuatorFunctionalities.getRegulationControl();
public String getRegulationControl() {
if (this.actuatorFunctionalities != null) {
return this.actuatorFunctionalities.getRegulationControl();
}
return null;
}
public int applianceCount() {

View File

@ -175,12 +175,16 @@ public class PlugwiseHABridgeHandler extends BaseBridgeHandler {
} catch (PlugwiseHAUnauthorizedException | PlugwiseHANotAuthorizedException e) {
updateStatus(OFFLINE, CONFIGURATION_ERROR, STATUS_DESCRIPTION_INVALID_CREDENTIALS);
} catch (PlugwiseHACommunicationException e) {
this.logger.trace("Bridge encountered an error {}", e.getMessage(), e);
updateStatus(OFFLINE, COMMUNICATION_ERROR, STATUS_DESCRIPTION_COMMUNICATION_ERROR);
} catch (PlugwiseHATimeoutException e) {
this.logger.trace("Bridge encountered an error {}", e.getMessage(), e);
updateStatus(OFFLINE, COMMUNICATION_ERROR, STATUS_DESCRIPTION_TIMEOUT);
} catch (PlugwiseHAException e) {
this.logger.trace("Bridge encountered an error {}", e.getMessage(), e);
updateStatus(OFFLINE, COMMUNICATION_ERROR, e.getMessage());
} catch (RuntimeException e) {
this.logger.trace("Bridge encountered an error {}", e.getMessage(), e);
updateStatus(OFFLINE, COMMUNICATION_ERROR, e.getMessage());
}
}

View File

@ -224,7 +224,10 @@ public class PlugwiseHAZoneHandler extends PlugwiseHABaseHandler<Location, Plugw
}
break;
case ZONE_REGULATION_CHANNEL:
state = new StringType(entity.getRegulationControl().orElse(null));
String value = entity.getRegulationControl();
if (value != null) {
state = new StringType(entity.getRegulationControl());
}
break;
case ZONE_TEMPERATURE_CHANNEL:
if (entity.getTemperature().isPresent()) {