From 55bf57011d178e3ae9a51f7b86db62c45eb78b8d Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 27 Jul 2020 12:13:11 +0200 Subject: [PATCH 1/2] Awattar: The token is not needed any more for AT --- awattar/integrationpluginawattar.cpp | 41 --------------------------- awattar/integrationpluginawattar.h | 2 -- awattar/integrationpluginawattar.json | 2 +- 3 files changed, 1 insertion(+), 44 deletions(-) diff --git a/awattar/integrationpluginawattar.cpp b/awattar/integrationpluginawattar.cpp index 11b60400..067f2200 100644 --- a/awattar/integrationpluginawattar.cpp +++ b/awattar/integrationpluginawattar.cpp @@ -69,40 +69,6 @@ IntegrationPluginAwattar::~IntegrationPluginAwattar() { } -void IntegrationPluginAwattar::startPairing(ThingPairingInfo *info) -{ - info->finish(Thing::ThingErrorNoError, QT_TR_NOOP("Please enter your token for awattar.com")); -} - -void IntegrationPluginAwattar::confirmPairing(ThingPairingInfo *info, const QString &username, const QString &secret) -{ - Q_UNUSED(username) - - QByteArray data = QString(secret + ":").toUtf8().toBase64(); - QString header = "Basic " + data; - QNetworkRequest request(QUrl("https://api.awattar.com/v1/marketdata")); - request.setRawHeader("Authorization", header.toLocal8Bit()); - request.setSslConfiguration(QSslConfiguration::defaultConfiguration()); - QNetworkReply *reply = hardwareManager()->networkManager()->get(request); - connect(reply, &QNetworkReply::finished, info, [this, reply, info, secret](){ - reply->deleteLater(); - - int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - - // check HTTP status code - if (status != 200) { - //: Error setting up thing with invalid token - info->finish(Thing::ThingErrorAuthenticationFailure, QT_TR_NOOP("This token is not valid.")); - return; - } - - pluginStorage()->beginGroup(info->thingId().toString()); - pluginStorage()->setValue("token", secret); - pluginStorage()->endGroup(); - info->finish(Thing::ThingErrorNoError); - }); -} - void IntegrationPluginAwattar::setupThing(ThingSetupInfo *info) { qCDebug(dcAwattar) << "Setup thing" << info->thing()->name() << info->thing()->params(); @@ -134,14 +100,7 @@ void IntegrationPluginAwattar::onPluginTimer() void IntegrationPluginAwattar::requestPriceData(Thing* thing, ThingSetupInfo *setup) { - pluginStorage()->beginGroup(thing->id().toString()); - QString token = pluginStorage()->value("token").toString(); - pluginStorage()->endGroup(); - - QByteArray data = QString(token + ":").toUtf8().toBase64(); - QString header = "Basic " + data; QNetworkRequest request(QUrl(m_serverUrls.value(thing->thingClassId()))); - request.setRawHeader("Authorization", header.toLocal8Bit()); request.setSslConfiguration(QSslConfiguration::defaultConfiguration()); QNetworkReply *reply = hardwareManager()->networkManager()->get(request); connect(reply, &QNetworkReply::finished, thing, [this, reply, thing, setup](){ diff --git a/awattar/integrationpluginawattar.h b/awattar/integrationpluginawattar.h index 042b7dbc..bda88b48 100644 --- a/awattar/integrationpluginawattar.h +++ b/awattar/integrationpluginawattar.h @@ -50,8 +50,6 @@ public: explicit IntegrationPluginAwattar(); ~IntegrationPluginAwattar(); - void startPairing(ThingPairingInfo *info) override; - void confirmPairing(ThingPairingInfo *info, const QString &username, const QString &secret) override; void setupThing(ThingSetupInfo *info) override; void thingRemoved(Thing *thing) override; diff --git a/awattar/integrationpluginawattar.json b/awattar/integrationpluginawattar.json index 366e58f8..e7b89fe9 100644 --- a/awattar/integrationpluginawattar.json +++ b/awattar/integrationpluginawattar.json @@ -13,7 +13,7 @@ "displayName": "aWATTar AT", "name": "awattarAT", "createMethods": ["user"], - "setupMethod": "displaypin", + "setupMethod": "justAdd", "interfaces": ["connectable"], "stateTypes": [ { From f8dbed2ab6001bfd76d69c2eb03683ec165441ed Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 27 Jul 2020 12:14:49 +0200 Subject: [PATCH 2/2] Update readme --- awattar/README.md | 7 ------- .../9c261c33-d44e-461e-8ec1-68803cb73f12-de.ts | 15 ++------------- .../9c261c33-d44e-461e-8ec1-68803cb73f12-en_US.ts | 15 ++------------- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/awattar/README.md b/awattar/README.md index 1f889f1e..52c2eca4 100644 --- a/awattar/README.md +++ b/awattar/README.md @@ -2,9 +2,6 @@ This integration allows to receive the current energy market price from [aWATTar GmbH](https://www.awattar.com/). aWattar is currently available in Austria and Germany. -The Austrian edition of aWATTar requires to enter the access token from your energy provider. -You can find more information about you accesstoken [here](https://www.awattar.com/api-unser-datenfeed). - ## Supported Things In following chart you can see an example of the market prices from -12 hours to + 12 hours from the current @@ -22,8 +19,6 @@ In the following chart you can see an example of the market prices from -12 hour ## Requirements -* Valid aWATTar access token for aWATTar Austria. - * The German servers do not require a token at this point. * aWattar "Hourly" energy tarif. * Internet access. @@ -31,5 +26,3 @@ In the following chart you can see an example of the market prices from -12 hour * [aWATTar Austria](https://www.awattar.com) * [aWATTar Germany](https://www.awattar.de) - -The aWATTar access token is available [here](https://www.awattar.com/api-unser-datenfeed). diff --git a/awattar/translations/9c261c33-d44e-461e-8ec1-68803cb73f12-de.ts b/awattar/translations/9c261c33-d44e-461e-8ec1-68803cb73f12-de.ts index 7320edca..1102052e 100644 --- a/awattar/translations/9c261c33-d44e-461e-8ec1-68803cb73f12-de.ts +++ b/awattar/translations/9c261c33-d44e-461e-8ec1-68803cb73f12-de.ts @@ -4,23 +4,12 @@ IntegrationPluginAwattar - - Please enter your token for awattar.com - Bitte gib Dein aWATTar.com Token ein - - - - This token is not valid. - Error setting up thing with invalid token - Dieses Token ist ungültig. - - - + Error getting data from server. Fehler beim Laden der Daten vom Server. - + The server returned unexpected data. Der Server liefert unerwartete Daten. diff --git a/awattar/translations/9c261c33-d44e-461e-8ec1-68803cb73f12-en_US.ts b/awattar/translations/9c261c33-d44e-461e-8ec1-68803cb73f12-en_US.ts index 3ebd1e9d..99e8eb6e 100644 --- a/awattar/translations/9c261c33-d44e-461e-8ec1-68803cb73f12-en_US.ts +++ b/awattar/translations/9c261c33-d44e-461e-8ec1-68803cb73f12-en_US.ts @@ -4,23 +4,12 @@ IntegrationPluginAwattar - - Please enter your token for awattar.com - - - - - This token is not valid. - Error setting up thing with invalid token - - - - + Error getting data from server. - + The server returned unexpected data.