From cb6936261eabd6e15c17de8dc390a8b27dffb1f6 Mon Sep 17 00:00:00 2001 From: Boernsman Date: Mon, 23 Dec 2019 15:34:40 +0100 Subject: [PATCH] added windspeed as main interface --- aqi/devicepluginaqi.cpp | 23 ++-- aqi/devicepluginaqi.json | 11 +- ...69b76-4d2d-41ec-bef6-949a79ffbe6b-en_US.ts | 105 ++++++++++++------ debian/control | 1 + 4 files changed, 97 insertions(+), 43 deletions(-) diff --git a/aqi/devicepluginaqi.cpp b/aqi/devicepluginaqi.cpp index 359677eb..37ab21f5 100644 --- a/aqi/devicepluginaqi.cpp +++ b/aqi/devicepluginaqi.cpp @@ -39,9 +39,11 @@ void DevicePluginAqi::setupDevice(DeviceSetupInfo *info) { if (info->device()->deviceClassId() == airQualityIndexDeviceClassId) { - if (myDevices().filterByDeviceClassId(info->device()->deviceClassId()).count() > 1) { - info->finish(Device::DeviceErrorSetupFailed, tr("Service is already in use")); - return; + if (!myDevices().filterByDeviceClassId(info->device()->deviceClassId()).isEmpty()) { + if (!myDevices().findById(info->device()->id())) { + info->finish(Device::DeviceErrorSetupFailed, tr("Service is already in use.")); + return; + } } QUrl url; @@ -123,7 +125,6 @@ void DevicePluginAqi::getDataByIp() qDebug(dcAirQualityIndex()) << "Received invalide JSON object"; return; } - qCDebug(dcAirQualityIndex()) << data.toJson(); QVariantMap city = data.toVariant().toMap().value("data").toMap().value("city").toMap(); //double lat = city["geo"].toList().takeAt(0).toDouble(); //double lng = city["geo"].toList().takeAt(1).toDouble(); @@ -140,6 +141,7 @@ void DevicePluginAqi::getDataByIp() double o3 = iaqi["o3"].toMap().value("v").toDouble(); double co = iaqi["co"].toMap().value("v").toDouble(); double temperature = iaqi["t"].toMap().value("v").toDouble(); + double windSpeed = iaqi["w"].toMap().value("v").toDouble(); foreach (Device *device, myDevices().filterByDeviceClassId(airQualityIndexDeviceClassId)) { device->setStateValue(airQualityIndexStationNameStateTypeId, name); @@ -153,25 +155,26 @@ void DevicePluginAqi::getDataByIp() device->setStateValue(airQualityIndexSo2StateTypeId, so2); device->setStateValue(airQualityIndexPm10StateTypeId, pm10); device->setStateValue(airQualityIndexPm25StateTypeId, pm25); + device->setStateValue(airQualityIndexWindSpeedStateTypeId, windSpeed); if (pm25 <= 50.00) { device->setStateValue(airQualityIndexAirQualityStateTypeId, "Good"); - device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, "None"); + device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, tr("None")); } else if ((pm25 > 50.00) && (pm25 <= 100.00)) { device->setStateValue(airQualityIndexAirQualityStateTypeId, "Moderate"); - device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, "Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion."); + device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, tr("Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion.")); } else if ((pm25 > 100.00) && (pm25 <= 150.00)) { device->setStateValue(airQualityIndexAirQualityStateTypeId, "Unhealthy for Sensitive Groups"); - device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, "Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion."); + device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, tr("Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion.")); } else if ((pm25 > 150.00) && (pm25 <= 200.00)) { device->setStateValue(airQualityIndexAirQualityStateTypeId, "Unhealthy"); - device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, "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"); + device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, tr("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")); } else if ((pm25 > 200.00) && (pm25 <= 300.00)) { device->setStateValue(airQualityIndexAirQualityStateTypeId, "Very Unhealthy"); - device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, "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."); + device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, tr("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.")); } else { device->setStateValue(airQualityIndexAirQualityStateTypeId, "Hazardous"); - device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, "Everyone should avoid all outdoor exertion"); + device->setStateValue(airQualityIndexCautionaryStatementStateTypeId, tr("Everyone should avoid all outdoor exertion")); } } }); diff --git a/aqi/devicepluginaqi.json b/aqi/devicepluginaqi.json index 4a5aa233..91a52ba7 100644 --- a/aqi/devicepluginaqi.json +++ b/aqi/devicepluginaqi.json @@ -21,7 +21,7 @@ "id": "23ea32c9-38b0-4155-bacc-3afa8c09f6ee", "name": "airQualityIndex", "displayName": "Air quality index", - "interfaces": ["humiditysensor", "pressuresensor", "temperaturesensor", "connectable"], + "interfaces": ["windspeedsensor", "humiditysensor", "pressuresensor", "temperaturesensor", "connectable"], "createMethods": ["user"], "paramTypes": [ ], @@ -147,6 +147,15 @@ "unit": "HectoPascal", "type": "double", "defaultValue": 0 + }, + { + "id": "c4366608-2511-428b-964e-2ad9e37f8f3c", + "name": "windSpeed", + "displayName": "Wind speed", + "displayNameEvent": "Wind speed changed", + "unit": "MeterPerSecond", + "type": "double", + "defaultValue": 0 } ] } 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 740476c8..0278aa05 100644 --- a/aqi/translations/57d69b76-4d2d-41ec-bef6-949a79ffbe6b-en_US.ts +++ b/aqi/translations/57d69b76-4d2d-41ec-bef6-949a79ffbe6b-en_US.ts @@ -4,20 +4,20 @@ AirQualityIndex - + API key The name of the ParamType (DeviceClass: airQualityIndex, Type: plugin, ID: {a3525f8a-18be-4739-b0ea-ef3af0c7f280}) - + Air Quality Index The name of the vendor ({6c8e2ded-0a33-4e77-b76c-ea02168741ec}) - + Air quality The name of the ParamType (DeviceClass: airQualityIndex, EventType: airQuality, ID: {33a3329a-4117-4488-aa18-91c76056ed6e}) ---------- @@ -25,26 +25,26 @@ The name of the StateType ({33a3329a-4117-4488-aa18-91c76056ed6e}) of DeviceClas - + Air quality changed The name of the EventType ({33a3329a-4117-4488-aa18-91c76056ed6e}) of DeviceClass airQualityIndex - + Air quality index The name of the DeviceClass ({23ea32c9-38b0-4155-bacc-3afa8c09f6ee}) - + AirQualityIndex The name of the plugin AirQualityIndex ({57d69b76-4d2d-41ec-bef6-949a79ffbe6b}) - + Carbon monoxide level (CO) The name of the ParamType (DeviceClass: airQualityIndex, EventType: co, ID: {54ac72f3-6444-46a8-a43d-210c2a6fbfb5}) ---------- @@ -52,14 +52,14 @@ The name of the StateType ({54ac72f3-6444-46a8-a43d-210c2a6fbfb5}) of DeviceClas - + Carbon monoxide level (CO) changed The name of the EventType ({54ac72f3-6444-46a8-a43d-210c2a6fbfb5}) of DeviceClass airQualityIndex - + Cautionary statement The name of the ParamType (DeviceClass: airQualityIndex, EventType: cautionaryStatement, ID: {cfece671-4e88-4c49-9456-e3f8f7c79ab3}) ---------- @@ -67,14 +67,14 @@ The name of the StateType ({cfece671-4e88-4c49-9456-e3f8f7c79ab3}) of DeviceClas - + Cautionary statement changed The name of the EventType ({cfece671-4e88-4c49-9456-e3f8f7c79ab3}) of DeviceClass airQualityIndex - + Coarse dust particles pollution level (PM10) The name of the ParamType (DeviceClass: airQualityIndex, EventType: pm10, ID: {24b41ec4-e26b-4dfb-b52c-8e2b1bbdafc6}) ---------- @@ -82,14 +82,14 @@ The name of the StateType ({24b41ec4-e26b-4dfb-b52c-8e2b1bbdafc6}) of DeviceClas - + Coarse dust particles pollution level (PM10) changed The name of the EventType ({24b41ec4-e26b-4dfb-b52c-8e2b1bbdafc6}) of DeviceClass airQualityIndex - + Connected The name of the ParamType (DeviceClass: airQualityIndex, EventType: connected, ID: {7b9135cd-2461-4d33-b2b3-3dc600983895}) ---------- @@ -97,14 +97,14 @@ The name of the StateType ({7b9135cd-2461-4d33-b2b3-3dc600983895}) of DeviceClas - + Connected changed The name of the EventType ({7b9135cd-2461-4d33-b2b3-3dc600983895}) of DeviceClass airQualityIndex - + Fine particles pollution level (PM2.5) The name of the ParamType (DeviceClass: airQualityIndex, EventType: pm25, ID: {bc8c4c83-d229-4be4-8732-bc4f2390f399}) ---------- @@ -112,14 +112,14 @@ The name of the StateType ({bc8c4c83-d229-4be4-8732-bc4f2390f399}) of DeviceClas - + Fine particles pollution level (PM2.5) changed The name of the EventType ({bc8c4c83-d229-4be4-8732-bc4f2390f399}) of DeviceClass airQualityIndex - + Humidity The name of the ParamType (DeviceClass: airQualityIndex, EventType: humidity, ID: {4fc45fca-25ab-45a0-b862-817eea1f51e3}) ---------- @@ -127,14 +127,14 @@ The name of the StateType ({4fc45fca-25ab-45a0-b862-817eea1f51e3}) of DeviceClas - + Humidity changed The name of the EventType ({4fc45fca-25ab-45a0-b862-817eea1f51e3}) of DeviceClass airQualityIndex - + Nitrogen Dioxide level (NO2) The name of the ParamType (DeviceClass: airQualityIndex, EventType: no2, ID: {6ed6c505-f36e-44c4-a982-f395b04e539b}) ---------- @@ -142,14 +142,14 @@ The name of the StateType ({6ed6c505-f36e-44c4-a982-f395b04e539b}) of DeviceClas - + Nitrogen Dioxide level (NO2) changed The name of the EventType ({6ed6c505-f36e-44c4-a982-f395b04e539b}) of DeviceClass airQualityIndex - + Ozone level (O3) The name of the ParamType (DeviceClass: airQualityIndex, EventType: o3, ID: {4e88526d-009f-4820-9a84-09b3646d23c9}) ---------- @@ -157,14 +157,14 @@ The name of the StateType ({4e88526d-009f-4820-9a84-09b3646d23c9}) of DeviceClas - + Ozone level (O3) changed The name of the EventType ({4e88526d-009f-4820-9a84-09b3646d23c9}) of DeviceClass airQualityIndex - + Pressure The name of the ParamType (DeviceClass: airQualityIndex, EventType: pressure, ID: {5f799040-08f8-44d1-aa0a-4cab7caad839}) ---------- @@ -172,14 +172,14 @@ The name of the StateType ({5f799040-08f8-44d1-aa0a-4cab7caad839}) of DeviceClas - + Pressure changed The name of the EventType ({5f799040-08f8-44d1-aa0a-4cab7caad839}) of DeviceClass airQualityIndex - + Station name The name of the ParamType (DeviceClass: airQualityIndex, EventType: stationName, ID: {8385f3d5-62f7-482e-927c-b5d61a70d607}) ---------- @@ -187,14 +187,14 @@ The name of the StateType ({8385f3d5-62f7-482e-927c-b5d61a70d607}) of DeviceClas - + Station name changed The name of the EventType ({8385f3d5-62f7-482e-927c-b5d61a70d607}) of DeviceClass airQualityIndex - + Sulfur dioxide level (SO2) The name of the ParamType (DeviceClass: airQualityIndex, EventType: so2, ID: {f3a05e65-a9b3-48fd-be43-688d4c293cc9}) ---------- @@ -202,14 +202,14 @@ The name of the StateType ({f3a05e65-a9b3-48fd-be43-688d4c293cc9}) of DeviceClas - + Sulfur dioxide level (SO2) changed The name of the EventType ({f3a05e65-a9b3-48fd-be43-688d4c293cc9}) of DeviceClass airQualityIndex - + Temperature The name of the ParamType (DeviceClass: airQualityIndex, EventType: temperature, ID: {94219802-0a82-4761-99b3-c6b6dfc096db}) ---------- @@ -217,17 +217,58 @@ The name of the StateType ({94219802-0a82-4761-99b3-c6b6dfc096db}) of DeviceClas - + Temperature changed The name of the EventType ({94219802-0a82-4761-99b3-c6b6dfc096db}) of DeviceClass airQualityIndex + + + + Wind speed + The name of the ParamType (DeviceClass: airQualityIndex, EventType: windSpeed, ID: {c4366608-2511-428b-964e-2ad9e37f8f3c}) +---------- +The name of the StateType ({c4366608-2511-428b-964e-2ad9e37f8f3c}) of DeviceClass airQualityIndex + + + + + Wind speed changed + The name of the EventType ({c4366608-2511-428b-964e-2ad9e37f8f3c}) of DeviceClass airQualityIndex + + DevicePluginAqi - - Service is already in use + + Service is already in use. + + + + + 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 diff --git a/debian/control b/debian/control index 8140a7d4..20f9b769 100644 --- a/debian/control +++ b/debian/control @@ -976,6 +976,7 @@ Package: nymea-plugins Section: libs Architecture: all Depends: nymea-plugin-anel, + nymea-plugin-aqi, nymea-plugin-awattar, nymea-plugin-bose, nymea-plugin-datetime,