Merge PR #300: Awattar: The token is not needed any more for AT
This commit is contained in:
commit
e543919200
@ -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.
|
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
|
## Supported Things
|
||||||
|
|
||||||
In following chart you can see an example of the market prices from -12 hours to + 12 hours from the current
|
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
|
## Requirements
|
||||||
|
|
||||||
* Valid aWATTar access token for aWATTar Austria.
|
|
||||||
* The German servers do not require a token at this point.
|
|
||||||
* aWattar "Hourly" energy tarif.
|
* aWattar "Hourly" energy tarif.
|
||||||
* Internet access.
|
* 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 Austria](https://www.awattar.com)
|
||||||
* [aWATTar Germany](https://www.awattar.de)
|
* [aWATTar Germany](https://www.awattar.de)
|
||||||
|
|
||||||
The aWATTar access token is available [here](https://www.awattar.com/api-unser-datenfeed).
|
|
||||||
|
|||||||
@ -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)
|
void IntegrationPluginAwattar::setupThing(ThingSetupInfo *info)
|
||||||
{
|
{
|
||||||
qCDebug(dcAwattar) << "Setup thing" << info->thing()->name() << info->thing()->params();
|
qCDebug(dcAwattar) << "Setup thing" << info->thing()->name() << info->thing()->params();
|
||||||
@ -134,14 +100,7 @@ void IntegrationPluginAwattar::onPluginTimer()
|
|||||||
|
|
||||||
void IntegrationPluginAwattar::requestPriceData(Thing* thing, ThingSetupInfo *setup)
|
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())));
|
QNetworkRequest request(QUrl(m_serverUrls.value(thing->thingClassId())));
|
||||||
request.setRawHeader("Authorization", header.toLocal8Bit());
|
|
||||||
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||||
QNetworkReply *reply = hardwareManager()->networkManager()->get(request);
|
QNetworkReply *reply = hardwareManager()->networkManager()->get(request);
|
||||||
connect(reply, &QNetworkReply::finished, thing, [this, reply, thing, setup](){
|
connect(reply, &QNetworkReply::finished, thing, [this, reply, thing, setup](){
|
||||||
|
|||||||
@ -50,8 +50,6 @@ public:
|
|||||||
explicit IntegrationPluginAwattar();
|
explicit IntegrationPluginAwattar();
|
||||||
~IntegrationPluginAwattar();
|
~IntegrationPluginAwattar();
|
||||||
|
|
||||||
void startPairing(ThingPairingInfo *info) override;
|
|
||||||
void confirmPairing(ThingPairingInfo *info, const QString &username, const QString &secret) override;
|
|
||||||
void setupThing(ThingSetupInfo *info) override;
|
void setupThing(ThingSetupInfo *info) override;
|
||||||
void thingRemoved(Thing *thing) override;
|
void thingRemoved(Thing *thing) override;
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
"displayName": "aWATTar AT",
|
"displayName": "aWATTar AT",
|
||||||
"name": "awattarAT",
|
"name": "awattarAT",
|
||||||
"createMethods": ["user"],
|
"createMethods": ["user"],
|
||||||
"setupMethod": "displaypin",
|
"setupMethod": "justAdd",
|
||||||
"interfaces": ["connectable"],
|
"interfaces": ["connectable"],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,23 +4,12 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>IntegrationPluginAwattar</name>
|
<name>IntegrationPluginAwattar</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationpluginawattar.cpp" line="74"/>
|
<location filename="../integrationpluginawattar.cpp" line="114"/>
|
||||||
<source>Please enter your token for awattar.com</source>
|
|
||||||
<translation>Bitte gib Dein aWATTar.com Token ein</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../integrationpluginawattar.cpp" line="95"/>
|
|
||||||
<source>This token is not valid.</source>
|
|
||||||
<extracomment>Error setting up thing with invalid token</extracomment>
|
|
||||||
<translation>Dieses Token ist ungültig.</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../integrationpluginawattar.cpp" line="155"/>
|
|
||||||
<source>Error getting data from server.</source>
|
<source>Error getting data from server.</source>
|
||||||
<translation>Fehler beim Laden der Daten vom Server.</translation>
|
<translation>Fehler beim Laden der Daten vom Server.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationpluginawattar.cpp" line="167"/>
|
<location filename="../integrationpluginawattar.cpp" line="126"/>
|
||||||
<source>The server returned unexpected data.</source>
|
<source>The server returned unexpected data.</source>
|
||||||
<translation>Der Server liefert unerwartete Daten.</translation>
|
<translation>Der Server liefert unerwartete Daten.</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|||||||
@ -4,23 +4,12 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>IntegrationPluginAwattar</name>
|
<name>IntegrationPluginAwattar</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationpluginawattar.cpp" line="74"/>
|
<location filename="../integrationpluginawattar.cpp" line="114"/>
|
||||||
<source>Please enter your token for awattar.com</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../integrationpluginawattar.cpp" line="95"/>
|
|
||||||
<source>This token is not valid.</source>
|
|
||||||
<extracomment>Error setting up thing with invalid token</extracomment>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../integrationpluginawattar.cpp" line="155"/>
|
|
||||||
<source>Error getting data from server.</source>
|
<source>Error getting data from server.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationpluginawattar.cpp" line="167"/>
|
<location filename="../integrationpluginawattar.cpp" line="126"/>
|
||||||
<source>The server returned unexpected data.</source>
|
<source>The server returned unexpected data.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user