[gardena] Adaptation of the login for API version 1.1 (#13050)
* Adaptation of the login for API version 1.1 * Fixed logging statement * Fixed logging message * Reverted changes in the german translation Signed-off-by: Gerhard Riegler <gerhard.riegler@gmail.com>
This commit is contained in:
parent
b7df5abe8c
commit
ad9b4fbf79
@ -26,16 +26,15 @@ An account must be specified, all things for an account are discovered automatic
|
|||||||
There are several settings for an account:
|
There are several settings for an account:
|
||||||
|
|
||||||
| Name | Required | Description |
|
| Name | Required | Description |
|
||||||
|-----------------------|----------|-----------------------------------------------------------------------------------------------------|
|
|-----------------------|----------|-----------------------------------------------------------------------------------------------|
|
||||||
| **email** | yes | The email address for logging into the Gardena smart system |
|
| **apiSecret** | yes | The Gardena smart system integration API secret |
|
||||||
| **password** | yes | The password for logging into the Gardena smart system |
|
|
||||||
| **apiKey** | yes | The Gardena smart system integration API key |
|
| **apiKey** | yes | The Gardena smart system integration API key |
|
||||||
| **connectionTimeout** | no | The timeout in seconds for connections to Gardena smart system integration API (default = 10) |
|
| **connectionTimeout** | no | The timeout in seconds for connections to Gardena smart system integration API (default = 10) |
|
||||||
|
|
||||||
### Obtaining your API Key
|
### Obtaining your API Key
|
||||||
|
|
||||||
1. Goto https://developer.husqvarnagroup.cloud/, sign in using your GARDENA smart system account and accept the terms of use
|
1. Goto https://developer.husqvarnagroup.cloud/, sign in using your GARDENA smart system account and accept the terms of use
|
||||||
2. Create and save a new application via the 'Create application' button
|
2. Create and save a new application via the 'Create application' button. The Redirect URLs do not matter, you can enter what you want (e.g. http://localhost:8080)
|
||||||
3. Connect both _Authentication API_ and _GARDENA smart system API_ to your application via the 'Connect new API' button
|
3. Connect both _Authentication API_ and _GARDENA smart system API_ to your application via the 'Connect new API' button
|
||||||
4. Copy the application key to use with this binding as _apiKey_
|
4. Copy the application key to use with this binding as _apiKey_
|
||||||
|
|
||||||
@ -46,14 +45,14 @@ There are several settings for an account:
|
|||||||
Minimal Thing configuration:
|
Minimal Thing configuration:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Bridge gardena:account:home [ email="...", password="...", apiKey="..." ]
|
Bridge gardena:account:home [ apiSecret="...", apiKey="..." ]
|
||||||
```
|
```
|
||||||
|
|
||||||
Configuration of multiple bridges:
|
Configuration of multiple bridges:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Bridge gardena:account:home1 [ email="...", password="...", apiKey="..." ]
|
Bridge gardena:account:home1 [ apiSecret="...", apiKey="..." ]
|
||||||
Bridge gardena:account:home2 [ email="...", password="...", apiKey="..." ]
|
Bridge gardena:account:home2 [ apiSecret="...", apiKey="..." ]
|
||||||
```
|
```
|
||||||
|
|
||||||
Once a connection to an account is established, connected Things are discovered automatically.
|
Once a connection to an account is established, connected Things are discovered automatically.
|
||||||
@ -61,7 +60,7 @@ Once a connection to an account is established, connected Things are discovered
|
|||||||
Alternatively, you can manually configure Things:
|
Alternatively, you can manually configure Things:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Bridge gardena:account:home [ email="...", password="...", apiKey="..." ]
|
Bridge gardena:account:home [ apiSecret="...", apiKey="..." ]
|
||||||
{
|
{
|
||||||
Thing mower myMower [ deviceId="c81ad682-6e45-42ce-bed1-6b4eff5620c8" ]
|
Thing mower myMower [ deviceId="c81ad682-6e45-42ce-bed1-6b4eff5620c8" ]
|
||||||
Thing water_control myWaterControl [ deviceId="c81ad682-6e45-42ce-bed1-6b4eff5620c8" ]
|
Thing water_control myWaterControl [ deviceId="c81ad682-6e45-42ce-bed1-6b4eff5620c8" ]
|
||||||
|
|||||||
@ -241,11 +241,10 @@ public class GardenaSmartImpl implements GardenaSmart, GardenaSmartWebSocketList
|
|||||||
PostOAuth2Response token = this.token;
|
PostOAuth2Response token = this.token;
|
||||||
if (token == null || token.isRefreshTokenExpired()) {
|
if (token == null || token.isRefreshTokenExpired()) {
|
||||||
// new token
|
// new token
|
||||||
logger.debug("Gardena API login using password, reason: {}",
|
logger.debug("Gardena API login using apiSecret, reason: {}",
|
||||||
token == null ? "no token available" : "refresh token expired");
|
token == null ? "no token available" : "refresh token expired");
|
||||||
fields.add("grant_type", "password");
|
fields.add("grant_type", "client_credentials");
|
||||||
fields.add("username", config.getEmail());
|
fields.add("client_secret", config.getApiSecret());
|
||||||
fields.add("password", config.getPassword());
|
|
||||||
token = executeRequest(HttpMethod.POST, URL_API_TOKEN, fields, PostOAuth2Response.class);
|
token = executeRequest(HttpMethod.POST, URL_API_TOKEN, fields, PostOAuth2Response.class);
|
||||||
token.postProcess();
|
token.postProcess();
|
||||||
this.token = token;
|
this.token = token;
|
||||||
|
|||||||
@ -24,8 +24,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
public class GardenaConfig {
|
public class GardenaConfig {
|
||||||
private static final Integer DEFAULT_CONNECTION_TIMEOUT = 10;
|
private static final Integer DEFAULT_CONNECTION_TIMEOUT = 10;
|
||||||
|
|
||||||
private @Nullable String email;
|
private @Nullable String apiSecret;
|
||||||
private @Nullable String password;
|
|
||||||
private @Nullable String apiKey;
|
private @Nullable String apiKey;
|
||||||
|
|
||||||
private transient Integer connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
|
private transient Integer connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
|
||||||
@ -33,37 +32,23 @@ public class GardenaConfig {
|
|||||||
public GardenaConfig() {
|
public GardenaConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GardenaConfig(String email, String password) {
|
public GardenaConfig(String apiKey, String apiSecret) {
|
||||||
this.email = email;
|
this.apiKey = apiKey;
|
||||||
this.password = password;
|
this.apiSecret = apiSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the email to connect to Gardena smart system.
|
* Returns the apiSecret to connect to Gardena smart system.
|
||||||
*/
|
*/
|
||||||
public @Nullable String getEmail() {
|
public @Nullable String getApiSecret() {
|
||||||
return email;
|
return apiSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the email to connect to Gardena smart system.
|
* Sets the apiSecret to connect to Gardena smart system.
|
||||||
*/
|
*/
|
||||||
public void setEmail(String email) {
|
public void setApiSecret(String apiSecret) {
|
||||||
this.email = email;
|
this.apiSecret = apiSecret;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the password to connect to Gardena smart system.
|
|
||||||
*/
|
|
||||||
public @Nullable String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the password to connect to Gardena smart system.
|
|
||||||
*/
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,17 +83,14 @@ public class GardenaConfig {
|
|||||||
* Validate the config if email, password and apiKey is specified.
|
* Validate the config if email, password and apiKey is specified.
|
||||||
*/
|
*/
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
final String email = this.email;
|
final String apiSecret = this.apiSecret;
|
||||||
final String password = this.password;
|
|
||||||
final String apiKey = this.apiKey;
|
final String apiKey = this.apiKey;
|
||||||
return email != null && !email.isBlank() && password != null && !password.isBlank() && apiKey != null
|
return apiSecret != null && !apiSecret.isBlank() && apiKey != null && !apiKey.isBlank();
|
||||||
&& !apiKey.isBlank();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder(GardenaConfig.class.getSimpleName()).append("[");
|
StringBuilder sb = new StringBuilder(GardenaConfig.class.getSimpleName()).append("[");
|
||||||
sb.append("email: ").append(email).append(", ");
|
|
||||||
sb.append("connectionTimeout: ").append(connectionTimeout).append(", ");
|
sb.append("connectionTimeout: ").append(connectionTimeout).append(", ");
|
||||||
sb.append("apiKey: ").append(apiKey);
|
sb.append("apiKey: ").append(apiKey);
|
||||||
return sb.append("]").toString();
|
return sb.append("]").toString();
|
||||||
|
|||||||
@ -38,10 +38,8 @@ thing-type.config.gardena.account.apiKey.label = API Key
|
|||||||
thing-type.config.gardena.account.apiKey.description = The Gardena smart system integration API key
|
thing-type.config.gardena.account.apiKey.description = The Gardena smart system integration API key
|
||||||
thing-type.config.gardena.account.connectionTimeout.label = Connection Timeout
|
thing-type.config.gardena.account.connectionTimeout.label = Connection Timeout
|
||||||
thing-type.config.gardena.account.connectionTimeout.description = The timeout in seconds for connections to Gardena smart system integration API
|
thing-type.config.gardena.account.connectionTimeout.description = The timeout in seconds for connections to Gardena smart system integration API
|
||||||
thing-type.config.gardena.account.email.label = Email
|
thing-type.config.gardena.account.apiSecret.label = API Secret
|
||||||
thing-type.config.gardena.account.email.description = Email address for logging in to Gardena smart system
|
thing-type.config.gardena.account.apiSecret.description = The Gardena smart system integration API secret
|
||||||
thing-type.config.gardena.account.password.label = Password
|
|
||||||
thing-type.config.gardena.account.password.description = Password for logging in to Gardena smart system
|
|
||||||
|
|
||||||
# channel group types
|
# channel group types
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ thing-type.config.gardena.account.apiKey.description = Der Gardena Smart System
|
|||||||
thing-type.config.gardena.account.connectionTimeout.label = Verbindungszeitüberschreitung
|
thing-type.config.gardena.account.connectionTimeout.label = Verbindungszeitüberschreitung
|
||||||
thing-type.config.gardena.account.connectionTimeout.description = Der Timeout in Sekunden für Verbindungen zur Gardena Smart System Integrations API
|
thing-type.config.gardena.account.connectionTimeout.description = Der Timeout in Sekunden für Verbindungen zur Gardena Smart System Integrations API
|
||||||
thing-type.config.gardena.account.email.label = E-Mail
|
thing-type.config.gardena.account.email.label = E-Mail
|
||||||
thing-type.config.gardena.account.email.description = E-Mail-Adresse für die Anmeldung im Gardena Smart System
|
thing-type.config.gardena.account.email.description = E-Mail-Adresse für die Anmeldung im Gardena Smart System
|
||||||
thing-type.config.gardena.account.password.label = Passwort
|
thing-type.config.gardena.account.password.label = Passwort
|
||||||
thing-type.config.gardena.account.password.description = Passwort zur Anmeldung im Gardena Smart System
|
thing-type.config.gardena.account.password.description = Passwort zur Anmeldung im Gardena Smart System
|
||||||
|
|
||||||
|
|||||||
@ -10,14 +10,10 @@
|
|||||||
<description>The Gardena smart system account</description>
|
<description>The Gardena smart system account</description>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="email" type="text" required="true">
|
<parameter name="apiSecret" type="text" required="true">
|
||||||
<label>Email</label>
|
<label>API Secret</label>
|
||||||
<description>Email address for logging in to Gardena smart system</description>
|
|
||||||
</parameter>
|
|
||||||
<parameter name="password" type="text" required="true">
|
|
||||||
<label>Password</label>
|
|
||||||
<context>password</context>
|
<context>password</context>
|
||||||
<description>Password for logging in to Gardena smart system</description>
|
<description>The Gardena smart system integration API secret</description>
|
||||||
</parameter>
|
</parameter>
|
||||||
<parameter name="apiKey" type="text" required="true">
|
<parameter name="apiKey" type="text" required="true">
|
||||||
<label>API Key</label>
|
<label>API Key</label>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user