diff --git a/homeconnect/README.md b/homeconnect/README.md index a868445a..29f963ab 100644 --- a/homeconnect/README.md +++ b/homeconnect/README.md @@ -20,6 +20,18 @@ Home connected home appliances, like: * Internet connection * Home connect account +## Plug-In Settings + +**Simulation Mode** +HomeConnect has a simulation server, where the home appliances are simulated. This feature is useful for demonstration and development. + +**Control** +The control of the oven for example is only allowed with an authorized API key. The nymea community +API credentials does not have this permission. Enabling this without the permission will result in failing login attempts. + +**Custom client key and secret** +You can register as developer on https://developer.home-connect.com, where you can obtain you own client credentials. The default client credentials are made available through the nymea community API key provider. + ## More Home Connect developer documentation: diff --git a/homeconnect/homeconnect.cpp b/homeconnect/homeconnect.cpp index 17cd1d3b..cb2bb2d0 100644 --- a/homeconnect/homeconnect.cpp +++ b/homeconnect/homeconnect.cpp @@ -224,6 +224,7 @@ void HomeConnect::getAccessTokenFromRefreshToken(const QByteArray &refreshToken) return; } m_accessToken = data.toVariant().toMap().value("access_token").toByteArray(); + emit receivedAccessToken(m_accessToken); if (data.toVariant().toMap().contains("expires_in")) { int expireTime = data.toVariant().toMap().value("expires_in").toInt(); @@ -279,7 +280,9 @@ void HomeConnect::getAccessTokenFromAuthorizationCode(const QByteArray &authoriz return; } m_accessToken = jsonDoc.toVariant().toMap().value("access_token").toByteArray(); + receivedAccessToken(m_accessToken); m_refreshToken = jsonDoc.toVariant().toMap().value("refresh_token").toByteArray(); + receivedRefreshToken(m_refreshToken); if (jsonDoc.toVariant().toMap().contains("expires_in")) { int expireTime = jsonDoc.toVariant().toMap().value("expires_in").toInt(); diff --git a/homeconnect/homeconnect.h b/homeconnect/homeconnect.h index 1a8cf9db..ae2f757f 100644 --- a/homeconnect/homeconnect.h +++ b/homeconnect/homeconnect.h @@ -172,6 +172,8 @@ private slots: signals: void connectionChanged(bool connected); void authenticationStatusChanged(bool authenticated); + void receivedRefreshToken(const QByteArray &refreshToken); + void receivedAccessToken(const QByteArray &accessToken); void commandExecuted(const QUuid &commandId, bool success); void receivedHomeAppliances(const QList &appliances); diff --git a/homeconnect/integrationpluginhomeconnect.cpp b/homeconnect/integrationpluginhomeconnect.cpp index 696fb1a3..45111b74 100644 --- a/homeconnect/integrationpluginhomeconnect.cpp +++ b/homeconnect/integrationpluginhomeconnect.cpp @@ -188,19 +188,8 @@ void IntegrationPluginHomeConnect::confirmPairing(ThingPairingInfo *info, const } qCDebug(dcHomeConnect()) << "Authorization code" << authorizationCode; homeConnect->getAccessTokenFromAuthorizationCode(authorizationCode); - connect(homeConnect, &HomeConnect::authenticationStatusChanged, this, [info, this](bool authenticated){ - HomeConnect *homeConnect = static_cast(sender()); - - if(!authenticated) { - qWarning(dcHomeConnect()) << "Authentication process failed"; - m_setupHomeConnectConnections.remove(info->thingId()); - homeConnect->deleteLater(); - info->finish(Thing::ThingErrorSetupFailed); - return; - } - QByteArray accessToken = homeConnect->accessToken(); - QByteArray refreshToken = homeConnect->refreshToken(); - qCDebug(dcHomeConnect()) << "Token:" << accessToken << refreshToken; + connect(homeConnect, &HomeConnect::receivedRefreshToken, info, [info, this](const QByteArray &refreshToken){ + qCDebug(dcHomeConnect()) << "Token:" << refreshToken; pluginStorage()->beginGroup(info->thingId().toString()); pluginStorage()->setValue("refresh_token", refreshToken); diff --git a/homeconnect/translations/109abdc7-5d53-4f63-a4b2-851e97cea8ea-de.ts b/homeconnect/translations/109abdc7-5d53-4f63-a4b2-851e97cea8ea-de.ts index c981a220..1a1a02ed 100644 --- a/homeconnect/translations/109abdc7-5d53-4f63-a4b2-851e97cea8ea-de.ts +++ b/homeconnect/translations/109abdc7-5d53-4f63-a4b2-851e97cea8ea-de.ts @@ -5,20 +5,20 @@ IntegrationPluginHomeConnect - + Client key and/or seceret is not available. - Client key oder Secret ist nicht verfügbar + Client key oder Secret sind nicht verfügbar - + Refresh token is not available. Refresh token ist nicht verfügbar. - - - - + + + + Please select a program first Bitte wählen Sie zuerst ein Programm aus diff --git a/homeconnect/translations/109abdc7-5d53-4f63-a4b2-851e97cea8ea-en_US.ts b/homeconnect/translations/109abdc7-5d53-4f63-a4b2-851e97cea8ea-en_US.ts index c5e34391..451d2f66 100644 --- a/homeconnect/translations/109abdc7-5d53-4f63-a4b2-851e97cea8ea-en_US.ts +++ b/homeconnect/translations/109abdc7-5d53-4f63-a4b2-851e97cea8ea-en_US.ts @@ -5,20 +5,20 @@ IntegrationPluginHomeConnect - + Client key and/or seceret is not available. - + Refresh token is not available. - - - - + + + + Please select a program first