[somfytahoma] pure local mode if token provided (#18774)
Signed-off-by: Ondrej Pecta <opecta@gmail.com>pull/18788/head
parent
17e439cafd
commit
dc006338ae
|
@ -111,4 +111,8 @@ public class SomfyTahomaConfig {
|
|||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public void setDevMode(boolean devMode) {
|
||||
this.devMode = devMode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,9 +247,11 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
|
|||
|
||||
public synchronized void login() {
|
||||
if (thingConfig.getEmail().isEmpty() || thingConfig.getPassword().isEmpty()) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"Can not access device as username and/or password are null");
|
||||
return;
|
||||
if (!thingConfig.isDevMode() || (thingConfig.isDevMode() && thingConfig.getToken().isEmpty())) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||
"Can not access device as username and/or password are null");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (tooManyRequests || Instant.now().minusSeconds(LOGIN_LIMIT_TIME).isBefore(lastLoginTimestamp)) {
|
||||
|
@ -269,15 +271,17 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
|
|||
lastLoginTimestamp = Instant.now();
|
||||
|
||||
if (thingConfig.getCloudPortal().equalsIgnoreCase(COZYTOUCH_PORTAL)) {
|
||||
// make sure all requests will be sent to cloud
|
||||
thingConfig.setDevMode(false);
|
||||
if (!loginCozyTouch()) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
loginTahoma();
|
||||
}
|
||||
|
||||
if (thingConfig.isDevMode()) {
|
||||
initializeLocalMode();
|
||||
if (thingConfig.isDevMode()) {
|
||||
initializeLocalMode();
|
||||
} else {
|
||||
loginTahoma();
|
||||
}
|
||||
}
|
||||
|
||||
String id = registerEvents();
|
||||
|
@ -356,13 +360,13 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
|
|||
if (!thingConfig.getIp().isEmpty() && !thingConfig.getPin().isEmpty()) {
|
||||
try {
|
||||
if (thingConfig.getToken().isEmpty()) {
|
||||
loginTahoma();
|
||||
localToken = getNewLocalToken();
|
||||
logger.debug("Local token retrieved");
|
||||
activateLocalToken();
|
||||
updateConfiguration();
|
||||
} else {
|
||||
localToken = thingConfig.getToken();
|
||||
activateLocalToken();
|
||||
}
|
||||
logger.debug("Local mode initialized, waiting for cloud sync");
|
||||
Thread.sleep(3000);
|
||||
|
|
|
@ -35,12 +35,12 @@
|
|||
<limitToOptions>false</limitToOptions>
|
||||
</parameter>
|
||||
|
||||
<parameter name="email" type="text" required="true">
|
||||
<parameter name="email" type="text">
|
||||
<label>Email Address</label>
|
||||
<description>Email address for the portal</description>
|
||||
</parameter>
|
||||
|
||||
<parameter name="password" type="text" required="true">
|
||||
<parameter name="password" type="text">
|
||||
<context>password</context>
|
||||
<label>Password</label>
|
||||
<description>Password for the portal</description>
|
||||
|
|
Loading…
Reference in New Issue