[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) {
|
public void setToken(String token) {
|
||||||
this.token = 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() {
|
public synchronized void login() {
|
||||||
if (thingConfig.getEmail().isEmpty() || thingConfig.getPassword().isEmpty()) {
|
if (thingConfig.getEmail().isEmpty() || thingConfig.getPassword().isEmpty()) {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
if (!thingConfig.isDevMode() || (thingConfig.isDevMode() && thingConfig.getToken().isEmpty())) {
|
||||||
"Can not access device as username and/or password are null");
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||||
return;
|
"Can not access device as username and/or password are null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tooManyRequests || Instant.now().minusSeconds(LOGIN_LIMIT_TIME).isBefore(lastLoginTimestamp)) {
|
if (tooManyRequests || Instant.now().minusSeconds(LOGIN_LIMIT_TIME).isBefore(lastLoginTimestamp)) {
|
||||||
|
@ -269,15 +271,17 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
|
||||||
lastLoginTimestamp = Instant.now();
|
lastLoginTimestamp = Instant.now();
|
||||||
|
|
||||||
if (thingConfig.getCloudPortal().equalsIgnoreCase(COZYTOUCH_PORTAL)) {
|
if (thingConfig.getCloudPortal().equalsIgnoreCase(COZYTOUCH_PORTAL)) {
|
||||||
|
// make sure all requests will be sent to cloud
|
||||||
|
thingConfig.setDevMode(false);
|
||||||
if (!loginCozyTouch()) {
|
if (!loginCozyTouch()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
loginTahoma();
|
if (thingConfig.isDevMode()) {
|
||||||
}
|
initializeLocalMode();
|
||||||
|
} else {
|
||||||
if (thingConfig.isDevMode()) {
|
loginTahoma();
|
||||||
initializeLocalMode();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = registerEvents();
|
String id = registerEvents();
|
||||||
|
@ -356,13 +360,13 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
|
||||||
if (!thingConfig.getIp().isEmpty() && !thingConfig.getPin().isEmpty()) {
|
if (!thingConfig.getIp().isEmpty() && !thingConfig.getPin().isEmpty()) {
|
||||||
try {
|
try {
|
||||||
if (thingConfig.getToken().isEmpty()) {
|
if (thingConfig.getToken().isEmpty()) {
|
||||||
|
loginTahoma();
|
||||||
localToken = getNewLocalToken();
|
localToken = getNewLocalToken();
|
||||||
logger.debug("Local token retrieved");
|
logger.debug("Local token retrieved");
|
||||||
activateLocalToken();
|
activateLocalToken();
|
||||||
updateConfiguration();
|
updateConfiguration();
|
||||||
} else {
|
} else {
|
||||||
localToken = thingConfig.getToken();
|
localToken = thingConfig.getToken();
|
||||||
activateLocalToken();
|
|
||||||
}
|
}
|
||||||
logger.debug("Local mode initialized, waiting for cloud sync");
|
logger.debug("Local mode initialized, waiting for cloud sync");
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
|
|
|
@ -35,12 +35,12 @@
|
||||||
<limitToOptions>false</limitToOptions>
|
<limitToOptions>false</limitToOptions>
|
||||||
</parameter>
|
</parameter>
|
||||||
|
|
||||||
<parameter name="email" type="text" required="true">
|
<parameter name="email" type="text">
|
||||||
<label>Email Address</label>
|
<label>Email Address</label>
|
||||||
<description>Email address for the portal</description>
|
<description>Email address for the portal</description>
|
||||||
</parameter>
|
</parameter>
|
||||||
|
|
||||||
<parameter name="password" type="text" required="true">
|
<parameter name="password" type="text">
|
||||||
<context>password</context>
|
<context>password</context>
|
||||||
<label>Password</label>
|
<label>Password</label>
|
||||||
<description>Password for the portal</description>
|
<description>Password for the portal</description>
|
||||||
|
|
Loading…
Reference in New Issue