diff --git a/netatmo/integrationpluginnetatmo.cpp b/netatmo/integrationpluginnetatmo.cpp index cc792f7b..1d4ae0ac 100644 --- a/netatmo/integrationpluginnetatmo.cpp +++ b/netatmo/integrationpluginnetatmo.cpp @@ -63,7 +63,7 @@ void IntegrationPluginNetatmo::confirmPairing(ThingPairingInfo *info, const QStr pluginStorage()->endGroup(); info->finish(Thing::ThingErrorNoError); } else { - info->finish(Thing::ThingErrorAuthenticationFailure, "Wrong username of password"); + info->finish(Thing::ThingErrorAuthenticationFailure, QT_TR_NOOP("Wrong username or password")); } }); authentication->startAuthentication(); @@ -104,20 +104,28 @@ void IntegrationPluginNetatmo::setupThing(ThingSetupInfo *info) thing->setParamValue(ParamTypeId("c0d892d6-f359-4782-9d7d-8f74a3b53e3e"), ""); } - OAuth2 *authentication = new OAuth2("561c015d49c75f0d1cce6e13", "GuvKkdtu7JQlPD47qTTepRR9hQ0CUPAj4Tae3Ohcq", this); - authentication->setUrl(QUrl("https://api.netatmo.net/oauth2/token")); - authentication->setUsername(username); - authentication->setPassword(password); - authentication->setScope("read_station read_thermostat write_thermostat"); - m_authentications.insert(authentication, thing); + OAuth2 *authentication; + if (m_authentications.values().contains(thing)) { + qCDebug(dcNetatmo()) << "Re-Discovery, not creating a new authentication"; + authentication = m_authentications.key(thing); + authentication->setUsername(username); + authentication->setPassword(password); + } else { + authentication = new OAuth2("561c015d49c75f0d1cce6e13", "GuvKkdtu7JQlPD47qTTepRR9hQ0CUPAj4Tae3Ohcq", this); + authentication->setUrl(QUrl("https://api.netatmo.net/oauth2/token")); + authentication->setUsername(username); + authentication->setPassword(password); + authentication->setScope("read_station read_thermostat write_thermostat"); + m_authentications.insert(authentication, thing); - // Update thing connected state based on OAuth connected state - connect(authentication, &OAuth2::authenticationChanged, thing, [this, thing, authentication](){ - thing->setStateValue(netatmoConnectionConnectedStateTypeId, authentication->authenticated()); - if (authentication->authenticated()) { - refreshData(thing, authentication->token()); - } - }); + // Update thing connected state based on OAuth connected state + connect(authentication, &OAuth2::authenticationChanged, thing, [this, thing, authentication](){ + thing->setStateValue(netatmoConnectionConnectedStateTypeId, authentication->authenticated()); + if (authentication->authenticated()) { + refreshData(thing, authentication->token()); + } + }); + } authentication->startAuthentication(); // Report thing setup finished when authentication reports success @@ -127,7 +135,6 @@ void IntegrationPluginNetatmo::setupThing(ThingSetupInfo *info) info->finish(Thing::ThingErrorAuthenticationFailure, QT_TR_NOOP("Error logging in to Netatmo server.")); return; } - info->finish(Thing::ThingErrorNoError); }); @@ -394,5 +401,3 @@ void IntegrationPluginNetatmo::onOutdoorStatesChanged() thing->setStateValue(outdoorBatteryLevelStateTypeId, outdoor->battery()); thing->setStateValue(outdoorBatteryCriticalStateTypeId, outdoor->battery() < 10); } - - diff --git a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-cs.ts b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-cs.ts index db926c3f..470b37b3 100644 --- a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-cs.ts +++ b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-cs.ts @@ -4,12 +4,17 @@ IntegrationPluginNetatmo - + Please enter the login credentials for your Netatmo account. - + + Wrong username or password + + + + Error logging in to Netatmo server. diff --git a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-da.ts b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-da.ts index 1a2f33ff..23771d92 100644 --- a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-da.ts +++ b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-da.ts @@ -4,12 +4,17 @@ IntegrationPluginNetatmo - + Please enter the login credentials for your Netatmo account. - + + Wrong username or password + + + + Error logging in to Netatmo server. diff --git a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-de_DE.ts b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-de_DE.ts index cde593bc..7c176ae4 100644 --- a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-de_DE.ts +++ b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-de_DE.ts @@ -4,12 +4,17 @@ IntegrationPluginNetatmo - + Please enter the login credentials for your Netatmo account. Bitte geben Sie die Anmeldeinformationen für Ihr Netatmo-Konto ein. - + + Wrong username or password + Benutzername oder Passwort falsch + + + Error logging in to Netatmo server. Fehler beim Anmelden am Netatmo-Server. diff --git a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-en_US.ts b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-en_US.ts index bf5347f2..a7c44584 100644 --- a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-en_US.ts +++ b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-en_US.ts @@ -4,12 +4,17 @@ IntegrationPluginNetatmo - + Please enter the login credentials for your Netatmo account. - + + Wrong username or password + + + + Error logging in to Netatmo server. diff --git a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-es.ts b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-es.ts index 79a276b8..1f721732 100644 --- a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-es.ts +++ b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-es.ts @@ -4,12 +4,17 @@ IntegrationPluginNetatmo - + Please enter the login credentials for your Netatmo account. - + + Wrong username or password + + + + Error logging in to Netatmo server. diff --git a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-fr.ts b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-fr.ts index d13d8042..3faf455c 100644 --- a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-fr.ts +++ b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-fr.ts @@ -4,12 +4,17 @@ IntegrationPluginNetatmo - + Please enter the login credentials for your Netatmo account. - + + Wrong username or password + + + + Error logging in to Netatmo server. diff --git a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-it.ts b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-it.ts index a476d1c3..fc7b44e6 100644 --- a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-it.ts +++ b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-it.ts @@ -4,12 +4,17 @@ IntegrationPluginNetatmo - + Please enter the login credentials for your Netatmo account. - + + Wrong username or password + + + + Error logging in to Netatmo server. diff --git a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-nl.ts b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-nl.ts index 7bea1ce4..e0fea15b 100644 --- a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-nl.ts +++ b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-nl.ts @@ -4,12 +4,17 @@ IntegrationPluginNetatmo - + Please enter the login credentials for your Netatmo account. - + + Wrong username or password + + + + Error logging in to Netatmo server. diff --git a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-pt.ts b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-pt.ts index 86b1d842..c1cf5134 100644 --- a/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-pt.ts +++ b/netatmo/translations/69d14951-0c02-4877-bcef-dffdf48b7ccb-pt.ts @@ -4,12 +4,17 @@ IntegrationPluginNetatmo - + Please enter the login credentials for your Netatmo account. - + + Wrong username or password + + + + Error logging in to Netatmo server.