added more debug information
parent
4e69b26888
commit
58e65a0420
|
|
@ -45,15 +45,17 @@ IntegrationPluginTado::IntegrationPluginTado()
|
||||||
|
|
||||||
void IntegrationPluginTado::startPairing(ThingPairingInfo *info)
|
void IntegrationPluginTado::startPairing(ThingPairingInfo *info)
|
||||||
{
|
{
|
||||||
// Checking the internet connection
|
qCDebug(dcTado()) << "Start pairing process, checking the internet connection ...";
|
||||||
NetworkAccessManager *network = hardwareManager()->networkManager();
|
NetworkAccessManager *network = hardwareManager()->networkManager();
|
||||||
QNetworkReply *reply = network->get(QNetworkRequest(QUrl("https://my.tado.com/api/v2")));
|
QNetworkReply *reply = network->get(QNetworkRequest(QUrl("https://my.tado.com/api/v2")));
|
||||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||||
connect(reply, &QNetworkReply::finished, info, [reply, info] {
|
connect(reply, &QNetworkReply::finished, info, [reply, info] {
|
||||||
|
|
||||||
if (reply->error() == QNetworkReply::NetworkError::HostNotFoundError) {
|
if (reply->error() == QNetworkReply::NetworkError::HostNotFoundError) {
|
||||||
|
qCWarning(dcTado()) << "Tado server is not reachable, likely because of a missing internet connection.";
|
||||||
info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("Tado server is not reachable."));
|
info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("Tado server is not reachable."));
|
||||||
} else {
|
} else {
|
||||||
|
qCDebug(dcTado()) << "Internet connection available";
|
||||||
info->finish(Thing::ThingErrorNoError, QT_TR_NOOP("Please enter the login credentials for your Tado account."));
|
info->finish(Thing::ThingErrorNoError, QT_TR_NOOP("Please enter the login credentials for your Tado account."));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -72,9 +74,13 @@ void IntegrationPluginTado::confirmPairing(ThingPairingInfo *info, const QString
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(tado, &Tado::connectionError, info, [info] (QNetworkReply::NetworkError error){
|
connect(tado, &Tado::connectionError, info, [info] (QNetworkReply::NetworkError error){
|
||||||
if (error != QNetworkReply::NetworkError::NoError){
|
|
||||||
|
if (error == QNetworkReply::NetworkError::ProtocolInvalidOperationError) {
|
||||||
|
qCWarning(dcTado()) << "Confirm pairing failed, wrong username or password";
|
||||||
|
info->finish(Thing::ThingErrorSetupFailed, QT_TR_NOOP("Wrong username or password."));
|
||||||
|
} else if (error != QNetworkReply::NetworkError::NoError){
|
||||||
qCWarning(dcTado()) << "Confirm pairing failed" << error;
|
qCWarning(dcTado()) << "Confirm pairing failed" << error;
|
||||||
info->finish(Thing::ThingErrorSetupFailed, tr("Connection error"));
|
info->finish(Thing::ThingErrorSetupFailed, QT_TR_NOOP("Connection error"));
|
||||||
}
|
}
|
||||||
// info->finish(success) will be called after the token has been received
|
// info->finish(success) will be called after the token has been received
|
||||||
});
|
});
|
||||||
|
|
@ -83,7 +89,7 @@ void IntegrationPluginTado::confirmPairing(ThingPairingInfo *info, const QString
|
||||||
if (success) {
|
if (success) {
|
||||||
tado->getToken(password);
|
tado->getToken(password);
|
||||||
} else {
|
} else {
|
||||||
info->finish(Thing::ThingErrorAuthenticationFailure, "Client credentials not found, the plug-in version might be outdated.");
|
info->finish(Thing::ThingErrorAuthenticationFailure, QT_TR_NOOP("Client credentials not found, the plug-in version might be outdated."));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -138,13 +144,21 @@ void IntegrationPluginTado::setupThing(ThingSetupInfo *info)
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(tado, &Tado::connectionError, info, [this, info] (QNetworkReply::NetworkError error){
|
connect(tado, &Tado::connectionError, info, [this, info] (QNetworkReply::NetworkError error) {
|
||||||
|
|
||||||
if (error != QNetworkReply::NetworkError::NoError){
|
if (error != QNetworkReply::NetworkError::NoError){
|
||||||
|
|
||||||
if (m_tadoAccounts.contains(info->thing()->id())) {
|
if (m_tadoAccounts.contains(info->thing()->id())) {
|
||||||
Tado *tado = m_tadoAccounts.take(info->thing()->id());
|
Tado *tado = m_tadoAccounts.take(info->thing()->id());
|
||||||
tado->deleteLater();
|
tado->deleteLater();
|
||||||
}
|
}
|
||||||
info->finish(Thing::ThingErrorSetupFailed);
|
if (error == QNetworkReply::NetworkError::ProtocolInvalidOperationError) {
|
||||||
|
qCWarning(dcTado()) << "Confirm pairing failed, wrong username or password";
|
||||||
|
info->finish(Thing::ThingErrorSetupFailed, QT_TR_NOOP("Wrong username or password."));
|
||||||
|
} else {
|
||||||
|
qCWarning(dcTado()) << "Confirm pairing failed" << error;
|
||||||
|
info->finish(Thing::ThingErrorSetupFailed, QT_TR_NOOP("Connection error"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tado->getApiCredentials();
|
tado->getApiCredentials();
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,32 @@
|
||||||
<context>
|
<context>
|
||||||
<name>IntegrationPluginTado</name>
|
<name>IntegrationPluginTado</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationplugintado.cpp" line="55"/>
|
<location filename="../integrationplugintado.cpp" line="56"/>
|
||||||
<source>Tado server is not reachable.</source>
|
<source>Tado server is not reachable.</source>
|
||||||
<translation>Tado-Server ist nicht erreichbar.</translation>
|
<translation>Tado-Server ist nicht erreichbar.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationplugintado.cpp" line="57"/>
|
<location filename="../integrationplugintado.cpp" line="59"/>
|
||||||
<source>Please enter the login credentials for your Tado account.</source>
|
<source>Please enter the login credentials for your Tado account.</source>
|
||||||
<translation>Bitte geben Sie die Anmeldeinformationen für Ihr Tado-Konto ein.</translation>
|
<translation>Bitte geben Sie die Anmeldeinformationen für Ihr Tado-Konto ein.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationplugintado.cpp" line="77"/>
|
<location filename="../integrationplugintado.cpp" line="80"/>
|
||||||
|
<location filename="../integrationplugintado.cpp" line="157"/>
|
||||||
|
<source>Wrong username or password.</source>
|
||||||
|
<translation>Fascher Benutzername oder Passwort.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../integrationplugintado.cpp" line="83"/>
|
||||||
|
<location filename="../integrationplugintado.cpp" line="160"/>
|
||||||
<source>Connection error</source>
|
<source>Connection error</source>
|
||||||
<translation>Verbindungsfehler</translation>
|
<translation>Verbindungsfehler</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../integrationplugintado.cpp" line="92"/>
|
||||||
|
<source>Client credentials not found, the plug-in version might be outdated.</source>
|
||||||
|
<translation>Client-Anmeldeinformationen nicht gefunden, die Plug-In-Version ist möglicherweise veraltet.</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>Tado</name>
|
<name>Tado</name>
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,32 @@
|
||||||
<context>
|
<context>
|
||||||
<name>IntegrationPluginTado</name>
|
<name>IntegrationPluginTado</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationplugintado.cpp" line="55"/>
|
<location filename="../integrationplugintado.cpp" line="56"/>
|
||||||
<source>Tado server is not reachable.</source>
|
<source>Tado server is not reachable.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationplugintado.cpp" line="57"/>
|
<location filename="../integrationplugintado.cpp" line="59"/>
|
||||||
<source>Please enter the login credentials for your Tado account.</source>
|
<source>Please enter the login credentials for your Tado account.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../integrationplugintado.cpp" line="77"/>
|
<location filename="../integrationplugintado.cpp" line="80"/>
|
||||||
|
<location filename="../integrationplugintado.cpp" line="157"/>
|
||||||
|
<source>Wrong username or password.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../integrationplugintado.cpp" line="83"/>
|
||||||
|
<location filename="../integrationplugintado.cpp" line="160"/>
|
||||||
<source>Connection error</source>
|
<source>Connection error</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../integrationplugintado.cpp" line="92"/>
|
||||||
|
<source>Client credentials not found, the plug-in version might be outdated.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>Tado</name>
|
<name>Tado</name>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue