Skip to content

Commit

Permalink
Updated after code review.
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com> (github: jannegpriv)
  • Loading branch information
jannegpriv committed May 27, 2020
1 parent c486318 commit 5e2351b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private boolean areWeLoggedIn() {
return null;
}

private @Nullable <T> T postJSONVerisureAPI(String url, String data, Class<T> jsonClass) {
private <T> @Nullable T postJSONVerisureAPI(String url, String data, Class<T> jsonClass) {
for (int cnt = 0; cnt < APISERVERLIST.size(); cnt++) {
ContentResponse response = postVerisureAPI(apiServerInUse + url, data, Boolean.TRUE);
if (response != null) {
Expand Down Expand Up @@ -537,9 +537,7 @@ private String createOperationJSON(String operation, VariablesDTO variables, Str
operationJSON.setOperationName(operation);
operationJSON.setVariables(variables);
operationJSON.setQuery(query);
List<OperationDTO> list = Collections.singletonList(operationJSON);

return gson.toJson(list);
return gson.toJson(Collections.singletonList(operationJSON));
}

private synchronized void updateAlarmStatus(VerisureInstallation installation) {
Expand Down Expand Up @@ -586,8 +584,7 @@ private synchronized void updateSmartLockStatus(VerisureInstallation installatio
doorLockList.forEach(doorLock -> {
VerisureSmartLocksDTO slThing = new VerisureSmartLocksDTO();
VerisureSmartLocksDTO.Installation inst = new VerisureSmartLocksDTO.Installation();
List<VerisureSmartLocksDTO.Doorlock> list = Collections.singletonList(doorLock);
inst.setDoorlocks(list);
inst.setDoorlocks(Collections.singletonList(doorLock));
VerisureSmartLocksDTO.Data data = new VerisureSmartLocksDTO.Data();
data.setInstallation(inst);
slThing.setData(data);
Expand Down Expand Up @@ -629,8 +626,7 @@ private synchronized void updateSmartPlugStatus(VerisureInstallation installatio
smartPlugList.forEach(smartPlug -> {
VerisureSmartPlugsDTO spThing = new VerisureSmartPlugsDTO();
VerisureSmartPlugsDTO.Installation inst = new VerisureSmartPlugsDTO.Installation();
List<VerisureSmartPlugsDTO.Smartplug> list = Collections.singletonList(smartPlug);
inst.setSmartplugs(list);
inst.setSmartplugs(Collections.singletonList(smartPlug));
VerisureSmartPlugsDTO.Data data = new VerisureSmartPlugsDTO.Data();
data.setInstallation(inst);
spThing.setData(data);
Expand Down Expand Up @@ -685,8 +681,7 @@ private synchronized void updateClimateStatus(VerisureInstallation installation)
}
VerisureClimatesDTO cThing = new VerisureClimatesDTO();
VerisureClimatesDTO.Installation inst = new VerisureClimatesDTO.Installation();
List<VerisureClimatesDTO.Climate> list = Collections.singletonList(climate);
inst.setClimates(list);
inst.setClimates(Collections.singletonList(climate));
VerisureClimatesDTO.Data data = new VerisureClimatesDTO.Data();
data.setInstallation(inst);
cThing.setData(data);
Expand Down Expand Up @@ -723,8 +718,7 @@ private synchronized void updateDoorWindowStatus(VerisureInstallation installati
doorWindowList.forEach(doorWindow -> {
VerisureDoorWindowsDTO dThing = new VerisureDoorWindowsDTO();
VerisureDoorWindowsDTO.Installation inst = new VerisureDoorWindowsDTO.Installation();
List<VerisureDoorWindowsDTO.DoorWindow> list = Collections.singletonList(doorWindow);
inst.setDoorWindows(list);
inst.setDoorWindows(Collections.singletonList(doorWindow));
VerisureDoorWindowsDTO.Data data = new VerisureDoorWindowsDTO.Data();
data.setInstallation(inst);
dThing.setData(data);
Expand Down Expand Up @@ -789,8 +783,7 @@ private synchronized void updateUserPresenceStatus(VerisureInstallation installa
if (localUserTrackingStatus != null && localUserTrackingStatus.equals("ACTIVE")) {
VerisureUserPresencesDTO upThing = new VerisureUserPresencesDTO();
VerisureUserPresencesDTO.Installation inst = new VerisureUserPresencesDTO.Installation();
List<VerisureUserPresencesDTO.UserTracking> list = Collections.singletonList(userTracking);
inst.setUserTrackings(list);
inst.setUserTrackings(Collections.singletonList(userTracking));
VerisureUserPresencesDTO.Data data = new VerisureUserPresencesDTO.Data();
data.setInstallation(inst);
upThing.setData(data);
Expand Down Expand Up @@ -824,8 +817,7 @@ private synchronized void updateMiceDetectionStatus(VerisureInstallation install
miceList.forEach(mouse -> {
VerisureMiceDetectionDTO miceThing = new VerisureMiceDetectionDTO();
VerisureMiceDetectionDTO.Installation inst = new VerisureMiceDetectionDTO.Installation();
List<VerisureMiceDetectionDTO.Mouse> list = Collections.singletonList(mouse);
inst.setMice(list);
inst.setMice(Collections.singletonList(mouse));
VerisureMiceDetectionDTO.Data data = new VerisureMiceDetectionDTO.Data();
data.setInstallation(inst);
miceThing.setData(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@ public void initialize() {
config = getConfigAs(VerisureThingConfiguration.class);
// Set status to UNKNOWN and let background task set correct status
updateStatus(ThingStatus.UNKNOWN);
scheduler.execute(() -> {
Bridge bridge = getBridge();
if (bridge != null) {
this.bridgeStatusChanged(bridge.getStatusInfo());
}
});
Bridge bridge = getBridge();
if (bridge != null) {
this.bridgeStatusChanged(bridge.getStatusInfo());
}
}

@Override
Expand Down

0 comments on commit 5e2351b

Please sign in to comment.