diff --git a/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/services/SignInService.java b/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/services/SignInService.java index 176ac61af..d23cb7f80 100644 --- a/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/services/SignInService.java +++ b/bundles/org.openhab.binding.ojelectronics/src/main/java/org/openhab/binding/ojelectronics/internal/services/SignInService.java @@ -73,17 +73,19 @@ public class SignInService { connectionLosed.run(); return; } - if (result.getResponse().getStatus() != 200) { - unauthorized.run(); + if (result.getResponse().getStatus() == 200) { + PostSignInResponseModel signInModel = gson.fromJson(getContentAsString(), + PostSignInResponseModel.class); + if (signInModel == null || signInModel.errorCode != 0 || signInModel.sessionId.equals("")) { + unauthorized.run(); + return; + } + signInDone.accept(signInModel.sessionId); return; } - PostSignInResponseModel signInModel = gson.fromJson(getContentAsString(), - PostSignInResponseModel.class); - if (signInModel == null || signInModel.errorCode != 0 || signInModel.sessionId.equals("")) { - unauthorized.run(); - return; - } - signInDone.accept(signInModel.sessionId); + + connectionLosed.run(); + return; } }); }