diff --git a/aqi/README.md b/aqi/README.md
index a58e3a2e..4f75693a 100644
--- a/aqi/README.md
+++ b/aqi/README.md
@@ -32,16 +32,10 @@ inform you what precautions should be taken.
## Requirements
* Valid "Air Quality Index" API Key
- * This might be provided through the nymea community API Key provider or an own key in the nymead.conf file.
+ * This might be provided through the nymea community API Key provider or by setting a custom API Key in the plug-in settings.
* The package "nymea-plugin-airqualityindex" must be installed
* Internet connection
## More
More about the different Air Quality Levels: https://www.airnow.gov/index.cfm?action=aqibasics.aqi
-
-Personal API Key settings in 'nymead.conf':
-'''
-[aqi]
-apiKey="123456789abcdfgh"
-'''
diff --git a/aqi/airqualityindex.cpp b/aqi/airqualityindex.cpp
index de4481f2..c7837e92 100644
--- a/aqi/airqualityindex.cpp
+++ b/aqi/airqualityindex.cpp
@@ -202,6 +202,14 @@ bool AirQualityIndex::parseData(QUuid requestId, const QByteArray &data)
qCWarning(dcAirQualityIndex()) << "Received invalide JSON object";
return false;
}
+
+ if (doc.toVariant().toMap().contains("status")) {
+ if (doc.toVariant().toMap().value("status") == "error") {
+ qCWarning(dcAirQualityIndex()) << "Server responded with error:" << doc.toVariant().toMap().value("data").toString();
+ return false;
+ }
+ }
+
Station station;
station.aqi = doc.toVariant().toMap().value("data").toMap().value("aqi").toInt();
station.idx = doc.toVariant().toMap().value("data").toMap().value("idx").toInt();
diff --git a/aqi/integrationpluginaqi.cpp b/aqi/integrationpluginaqi.cpp
index 5c0c836d..a8682103 100644
--- a/aqi/integrationpluginaqi.cpp
+++ b/aqi/integrationpluginaqi.cpp
@@ -39,8 +39,10 @@ IntegrationPluginAqi::IntegrationPluginAqi()
connect(this, &IntegrationPluginAqi::configValueChanged, this, [this] (const ParamTypeId ¶mTypeId, const QVariant &value) {
if (paramTypeId == airQualityIndexPluginApiKeyParamTypeId && m_aqiConnection) {
- if (!value.toString().isEmpty())
+ if (!value.toString().isEmpty()) {
+ qCDebug(dcAirQualityIndex()) << "Custom API key updated";
m_aqiConnection->setApiKey(value.toString());
+ }
}
});
}
@@ -48,7 +50,7 @@ IntegrationPluginAqi::IntegrationPluginAqi()
void IntegrationPluginAqi::discoverThings(ThingDiscoveryInfo *info)
{
if (!m_aqiConnection) {
- if(createAqiConnection()) {
+ if(!createAqiConnection()) {
return info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("API key is not available."));
}
connect(info, &ThingDiscoveryInfo::aborted, [this] {
@@ -69,7 +71,7 @@ void IntegrationPluginAqi::setupThing(ThingSetupInfo *info)
{
if (info->thing()->thingClassId() == airQualityIndexThingClassId) {
if (!m_aqiConnection) {
- if(createAqiConnection()) {
+ if(!createAqiConnection()) {
return info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("API key is not available."));
}
double longitude = info->thing()->paramValue(airQualityIndexThingLongitudeParamTypeId).toDouble();
diff --git a/aqi/integrationpluginaqi.json b/aqi/integrationpluginaqi.json
index d2f9c138..349b79ab 100644
--- a/aqi/integrationpluginaqi.json
+++ b/aqi/integrationpluginaqi.json
@@ -6,7 +6,7 @@
{
"id": "b6861adb-7ed5-445f-b500-4df9eab866ef",
"name": "apiKey",
- "displayName": "API key",
+ "displayName": "Custom API key",
"type": "QString",
"defaultValue": ""
}
diff --git a/aqi/translations/57d69b76-4d2d-41ec-bef6-949a79ffbe6b-de.ts b/aqi/translations/57d69b76-4d2d-41ec-bef6-949a79ffbe6b-de.ts
index b9c20e05..1a8522dd 100644
--- a/aqi/translations/57d69b76-4d2d-41ec-bef6-949a79ffbe6b-de.ts
+++ b/aqi/translations/57d69b76-4d2d-41ec-bef6-949a79ffbe6b-de.ts
@@ -5,13 +5,7 @@
AirQualityIndex
- API key
- The name of the ParamType (ThingClass: airQualityIndex, Type: plugin, ID: {b6861adb-7ed5-445f-b500-4df9eab866ef})
- API-Key
-
-
- Air qualityThe name of the ParamType (ThingClass: airQualityIndex, EventType: airQuality, ID: {33a3329a-4117-4488-aa18-91c76056ed6e})
----------
@@ -19,15 +13,15 @@ The name of the StateType ({33a3329a-4117-4488-aa18-91c76056ed6e}) of ThingClass
Luftqualität
-
+ Air quality changedThe name of the EventType ({33a3329a-4117-4488-aa18-91c76056ed6e}) of ThingClass airQualityIndexLuftqualität geändert
+
- Air quality indexThe name of the ThingClass ({23ea32c9-38b0-4155-bacc-3afa8c09f6ee})
----------
@@ -37,8 +31,8 @@ The name of the plugin AirQualityIndex ({57d69b76-4d2d-41ec-bef6-949a79ffbe6b})<
Air quality index
+
- Carbon monoxide level (CO)The name of the ParamType (ThingClass: airQualityIndex, EventType: co, ID: {54ac72f3-6444-46a8-a43d-210c2a6fbfb5})
----------
@@ -46,14 +40,14 @@ The name of the StateType ({54ac72f3-6444-46a8-a43d-210c2a6fbfb5}) of ThingClass
Kohlenmonoxidgehalt (CO)
-
+ Carbon monoxide level (CO) changedThe name of the EventType ({54ac72f3-6444-46a8-a43d-210c2a6fbfb5}) of ThingClass airQualityIndexKohlenmonoxidgehalt (CO) geändert
+
- Cautionary statementThe name of the ParamType (ThingClass: airQualityIndex, EventType: cautionaryStatement, ID: {cfece671-4e88-4c49-9456-e3f8f7c79ab3})
----------
@@ -61,14 +55,14 @@ The name of the StateType ({cfece671-4e88-4c49-9456-e3f8f7c79ab3}) of ThingClass
Warnhinweis
-
+ Cautionary statement changedThe name of the EventType ({cfece671-4e88-4c49-9456-e3f8f7c79ab3}) of ThingClass airQualityIndexWarnhinweis geändert
+
- Coarse dust particles pollution level (PM10)The name of the ParamType (ThingClass: airQualityIndex, EventType: pm10, ID: {24b41ec4-e26b-4dfb-b52c-8e2b1bbdafc6})
----------
@@ -76,14 +70,14 @@ The name of the StateType ({24b41ec4-e26b-4dfb-b52c-8e2b1bbdafc6}) of ThingClass
Verschmutzungsgrad der groben Staubpartikel (PM10)
-
+ Coarse dust particles pollution level (PM10) changedThe name of the EventType ({24b41ec4-e26b-4dfb-b52c-8e2b1bbdafc6}) of ThingClass airQualityIndexVerschmutzungsgrad der groben Staubpartikel (PM10) geändert
+
- ConnectedThe name of the ParamType (ThingClass: airQualityIndex, EventType: connected, ID: {7b9135cd-2461-4d33-b2b3-3dc600983895})
----------
@@ -91,11 +85,17 @@ The name of the StateType ({7b9135cd-2461-4d33-b2b3-3dc600983895}) of ThingClass
Verbunden
-
+ Connected changedThe name of the EventType ({7b9135cd-2461-4d33-b2b3-3dc600983895}) of ThingClass airQualityIndexVerbunden geändert
+
+
+ Custom API key
+ The name of the ParamType (ThingClass: airQualityIndex, Type: plugin, ID: {b6861adb-7ed5-445f-b500-4df9eab866ef})
+ Benutzerdefinierter API Key
+
@@ -247,39 +247,39 @@ The name of the StateType ({c4366608-2511-428b-964e-2ad9e37f8f3c}) of ThingClass
IntegrationPluginAqi
-
-
+
+ API key is not available.API-Key ist nicht verfügbar.
-
+ NoneKeine
-
-
+
+ Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion.Aktive Kinder und Erwachsene sowie Menschen mit Atemwegserkrankungen wie Asthma sollten eine längere Belastung im Freien begrenzen.
-
+ Active children and adults, and people with respiratory disease, such as asthma, should avoid prolonged outdoor exertion; everyone else, especially children, should limit prolonged outdoor exertionAktive Kinder und Erwachsene sowie Menschen mit Atemwegserkrankungen wie Asthma sollten eine längere Anstrengung im Freien vermeiden. Alle anderen, insbesondere Kinder, sollten längere Belastungen im Freien begrenzen
-
+ Active children and adults, and people with respiratory disease, such as asthma, should avoid all outdoor exertion; everyone else, especially children, should limit outdoor exertion.Aktive Kinder und Erwachsene sowie Menschen mit Atemwegserkrankungen wie Asthma sollten jede Anstrengung im Freien vermeiden. Alle anderen, insbesondere Kinder, sollten die Anstrengung im Freien einschränken.
-
+ Everyone should avoid all outdoor exertionJeder sollte jede Anstrengung im Freien vermeiden.
-
+ Air quality index server not available, please check your internet connection.Air quality index Server nicht verfügbar, bitte überprüfe die Internetverbindung.
diff --git a/aqi/translations/57d69b76-4d2d-41ec-bef6-949a79ffbe6b-en_US.ts b/aqi/translations/57d69b76-4d2d-41ec-bef6-949a79ffbe6b-en_US.ts
index 5676866d..dee39a99 100644
--- a/aqi/translations/57d69b76-4d2d-41ec-bef6-949a79ffbe6b-en_US.ts
+++ b/aqi/translations/57d69b76-4d2d-41ec-bef6-949a79ffbe6b-en_US.ts
@@ -5,13 +5,7 @@
AirQualityIndex
- API key
- The name of the ParamType (ThingClass: airQualityIndex, Type: plugin, ID: {b6861adb-7ed5-445f-b500-4df9eab866ef})
-
-
-
- Air qualityThe name of the ParamType (ThingClass: airQualityIndex, EventType: airQuality, ID: {33a3329a-4117-4488-aa18-91c76056ed6e})
----------
@@ -19,15 +13,15 @@ The name of the StateType ({33a3329a-4117-4488-aa18-91c76056ed6e}) of ThingClass
-
+ Air quality changedThe name of the EventType ({33a3329a-4117-4488-aa18-91c76056ed6e}) of ThingClass airQualityIndex
+
- Air quality indexThe name of the ThingClass ({23ea32c9-38b0-4155-bacc-3afa8c09f6ee})
----------
@@ -37,8 +31,8 @@ The name of the plugin AirQualityIndex ({57d69b76-4d2d-41ec-bef6-949a79ffbe6b})<
+
- Carbon monoxide level (CO)The name of the ParamType (ThingClass: airQualityIndex, EventType: co, ID: {54ac72f3-6444-46a8-a43d-210c2a6fbfb5})
----------
@@ -46,14 +40,14 @@ The name of the StateType ({54ac72f3-6444-46a8-a43d-210c2a6fbfb5}) of ThingClass
-
+ Carbon monoxide level (CO) changedThe name of the EventType ({54ac72f3-6444-46a8-a43d-210c2a6fbfb5}) of ThingClass airQualityIndex
+
- Cautionary statementThe name of the ParamType (ThingClass: airQualityIndex, EventType: cautionaryStatement, ID: {cfece671-4e88-4c49-9456-e3f8f7c79ab3})
----------
@@ -61,14 +55,14 @@ The name of the StateType ({cfece671-4e88-4c49-9456-e3f8f7c79ab3}) of ThingClass
-
+ Cautionary statement changedThe name of the EventType ({cfece671-4e88-4c49-9456-e3f8f7c79ab3}) of ThingClass airQualityIndex
+
- Coarse dust particles pollution level (PM10)The name of the ParamType (ThingClass: airQualityIndex, EventType: pm10, ID: {24b41ec4-e26b-4dfb-b52c-8e2b1bbdafc6})
----------
@@ -76,14 +70,14 @@ The name of the StateType ({24b41ec4-e26b-4dfb-b52c-8e2b1bbdafc6}) of ThingClass
-
+ Coarse dust particles pollution level (PM10) changedThe name of the EventType ({24b41ec4-e26b-4dfb-b52c-8e2b1bbdafc6}) of ThingClass airQualityIndex
+
- ConnectedThe name of the ParamType (ThingClass: airQualityIndex, EventType: connected, ID: {7b9135cd-2461-4d33-b2b3-3dc600983895})
----------
@@ -91,11 +85,17 @@ The name of the StateType ({7b9135cd-2461-4d33-b2b3-3dc600983895}) of ThingClass
-
+ Connected changedThe name of the EventType ({7b9135cd-2461-4d33-b2b3-3dc600983895}) of ThingClass airQualityIndex
+
+
+ Custom API key
+ The name of the ParamType (ThingClass: airQualityIndex, Type: plugin, ID: {b6861adb-7ed5-445f-b500-4df9eab866ef})
+
+
@@ -247,39 +247,39 @@ The name of the StateType ({c4366608-2511-428b-964e-2ad9e37f8f3c}) of ThingClass
IntegrationPluginAqi
-
-
+
+ API key is not available.
-
+ None
-
-
+
+ Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion.
-
+ Active children and adults, and people with respiratory disease, such as asthma, should avoid prolonged outdoor exertion; everyone else, especially children, should limit prolonged outdoor exertion
-
+ Active children and adults, and people with respiratory disease, such as asthma, should avoid all outdoor exertion; everyone else, especially children, should limit outdoor exertion.
-
+ Everyone should avoid all outdoor exertion
-
+ Air quality index server not available, please check your internet connection.