[somfytahoma] pure local mode if token provided (#18774)

Signed-off-by: Ondrej Pecta <opecta@gmail.com>
pull/18788/head
Ondrej Pecta 2025-06-08 17:27:08 +02:00 committed by GitHub
parent 17e439cafd
commit dc006338ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 11 deletions

View File

@ -111,4 +111,8 @@ public class SomfyTahomaConfig {
public void setToken(String token) {
this.token = token;
}
public void setDevMode(boolean devMode) {
this.devMode = devMode;
}
}

View File

@ -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);

View File

@ -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>