Skip to content

Commit

Permalink
[hydrawise] fixes null pointer error for some sprinkler controllers
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
  • Loading branch information
digitaldan committed Dec 10, 2022
1 parent d068125 commit 82b7f17
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;

import javax.measure.quantity.Speed;
Expand Down Expand Up @@ -258,8 +259,7 @@ public void onData(List<Controller> controllers) {
// update values with what the cloud tells us even though the controller may be offline
if (!controller.status.online) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
String.format("Controller Offline: %s last seen %s", controller.status.summary,
secondsToDateTime(controller.status.lastContact.timestamp)));
"Service reports controller as offline");
} else if (getThing().getStatus() != ThingStatus.ONLINE) {
updateStatus(ThingStatus.ONLINE);
}
Expand All @@ -277,7 +277,9 @@ private void updateController(Controller controller) {
updateGroupState(CHANNEL_GROUP_CONTROLLER_SYSTEM, CHANNEL_CONTROLLER_SUMMARY,
new StringType(controller.status.summary));
updateGroupState(CHANNEL_GROUP_CONTROLLER_SYSTEM, CHANNEL_CONTROLLER_LAST_CONTACT,
secondsToDateTime(controller.status.lastContact.timestamp));
Objects.nonNull(controller.status.lastContact)
? secondsToDateTime(controller.status.lastContact.timestamp)
: UnDefType.NULL);
}

private void updateZones(List<Zone> zones) {
Expand Down

0 comments on commit 82b7f17

Please sign in to comment.