Skip to content

Commit

Permalink
[plugwiseha] Fix bug introduced with openhab#12349 (openhab#12366)
Browse files Browse the repository at this point in the history
* Fix bug introduced with openhab#12349

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
  • Loading branch information
lsiepel authored and psmedley committed Feb 23, 2023
1 parent 1b12ada commit 9f206ba
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ public Optional<Boolean> getRelayLockState() {
.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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public ZonedDateTime getUpdatedDate() {
return updatedDate;
}

public Optional<String> getRegulationControl() {
return Optional.ofNullable(regulationControl);
public String getRegulationControl() {
return regulationControl;
}

public Optional<String> getCoolingAllowed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ public Optional<Boolean> getCoolingAllowed() {
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,16 @@ private void run() {
} 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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ protected void refreshChannel(Location entity, ChannelUID channelUID) {
}
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()) {
Expand Down

0 comments on commit 9f206ba

Please sign in to comment.