From 7c7955b66b880ace9971b0b87cbb356aa6b04926 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 10 Oct 2022 23:11:36 +0200 Subject: [PATCH] Rework air quliaty interfaces Removes the indoorairquality and airquality interfaces as the plugin isn't the right place for these sort of voncersion. Instead, this PR specifies the individual compounds that for the base for air quality measurements and ties them down to export raw data. It's the client apps responsibility to translate those values into Air Quality Index scales based on the location of user. I.e. while Europe would use the CAQI (Common Air Quality Index), the US would use the EPA AQI etc. --- libnymea/interfaces/airquality.json | 24 ----------------------- libnymea/interfaces/cosensor.json | 2 ++ libnymea/interfaces/indoorairquality.json | 24 ----------------------- libnymea/interfaces/interfaces.qrc | 7 +++++-- libnymea/interfaces/no2sensor.json | 14 +++++++++++++ libnymea/interfaces/o3sensor.json | 14 +++++++++++++ libnymea/interfaces/pm10sensor.json | 14 +++++++++++++ libnymea/interfaces/pm25sensor.json | 14 +++++++++++++ libnymea/interfaces/vocsensor.json | 14 +++++++++++++ libnymea/typeutils.h | 2 ++ nymea.pro | 2 +- tests/auto/api.json | 9 ++++++--- 12 files changed, 86 insertions(+), 54 deletions(-) delete mode 100644 libnymea/interfaces/airquality.json delete mode 100644 libnymea/interfaces/indoorairquality.json create mode 100644 libnymea/interfaces/no2sensor.json create mode 100644 libnymea/interfaces/o3sensor.json create mode 100644 libnymea/interfaces/pm10sensor.json create mode 100644 libnymea/interfaces/pm25sensor.json create mode 100644 libnymea/interfaces/vocsensor.json diff --git a/libnymea/interfaces/airquality.json b/libnymea/interfaces/airquality.json deleted file mode 100644 index 9f9ccc4f..00000000 --- a/libnymea/interfaces/airquality.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "description": "Air quality sensors. Describes the current quality of the air. As air quality index the PM2.5 measurment (particles pollution level) will be used.", - "extends": "sensor", - "states": [ - { - "name": "airQuality", - "type": "QString", - "logged": true, - "possibleValues": [ - "Good", - "Moderate", - "Unhealthy for Sensitive Groups", - "Unhealthy", - "Very unhealthy", - "Hazardous" - ] - }, - { - "name": "airQualityIndex", - "type": "uint", - "logged": true - } - ] -} diff --git a/libnymea/interfaces/cosensor.json b/libnymea/interfaces/cosensor.json index e758b1cd..a5218972 100644 --- a/libnymea/interfaces/cosensor.json +++ b/libnymea/interfaces/cosensor.json @@ -6,6 +6,8 @@ "name": "co", "type": "double", "unit": "PartsPerMillion", + "minValue": 0, + "maxValue": 255, "logged": true } ] diff --git a/libnymea/interfaces/indoorairquality.json b/libnymea/interfaces/indoorairquality.json deleted file mode 100644 index f5db0514..00000000 --- a/libnymea/interfaces/indoorairquality.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "description": "Indoor air quality sensors. Describes the current quality of the air in a room. As air quality index the Volatile organic compounds (VOC) measurment will be used.", - "extends": "sensor", - "states": [ - { - "name": "indoorAirQuality", - "type": "QString", - "logged": true, - "possibleValues": [ - "Excellent", - "Good", - "Moderate", - "Poor", - "Unhealthy" - ] - }, - { - "name": "voc", - "type": "uint", - "unit": "PartsPerMillion", - "logged": true - } - ] -} diff --git a/libnymea/interfaces/interfaces.qrc b/libnymea/interfaces/interfaces.qrc index 0d30b72d..dc4c2bbe 100644 --- a/libnymea/interfaces/interfaces.qrc +++ b/libnymea/interfaces/interfaces.qrc @@ -45,6 +45,10 @@ cosensor.json co2sensor.json o2sensor.json + no2sensor.json + o3sensor.json + pm25sensor.json + pm10sensor.json gassensor.json orpsensor.json conductivitysensor.json @@ -87,8 +91,7 @@ venetianblind.json update.json cleaningrobot.json - airquality.json - indoorairquality.json + vocsensor.json energystorage.json heatpump.json smartgridheatpump.json diff --git a/libnymea/interfaces/no2sensor.json b/libnymea/interfaces/no2sensor.json new file mode 100644 index 00000000..5903ea8e --- /dev/null +++ b/libnymea/interfaces/no2sensor.json @@ -0,0 +1,14 @@ +{ + "description": "Interface for nitrogen dioxide sensors. NO2 is measured in µg/m3.", + "extends": "sensor", + "states": [ + { + "name": "no2", + "type": "double", + "unit": "MicroGrammPerCubicalMeter", + "minValue": 0, + "maxValue": 800, + "logged": true + } + ] +} diff --git a/libnymea/interfaces/o3sensor.json b/libnymea/interfaces/o3sensor.json new file mode 100644 index 00000000..fe7183c1 --- /dev/null +++ b/libnymea/interfaces/o3sensor.json @@ -0,0 +1,14 @@ +{ + "extends": "sensor", + "description": "O3 (ozone) sensors. Measures o3 in parts per million.", + "states": [ + { + "name": "o3", + "type": "double", + "unit": "MicroGrammPerCubicalMeter", + "minValue": 0, + "maxValue": 500, + "logged": true + } + ] +} diff --git a/libnymea/interfaces/pm10sensor.json b/libnymea/interfaces/pm10sensor.json new file mode 100644 index 00000000..2d9c1678 --- /dev/null +++ b/libnymea/interfaces/pm10sensor.json @@ -0,0 +1,14 @@ +{ + "extends": "sensor", + "description": "PM10 (Coarse particles) sensors. Measures PM10 particles in µg/m3.", + "states": [ + { + "name": "pm10", + "type": "double", + "unit": "MicroGrammPerCubicalMeter", + "minValue": 0, + "maxValue": 500, + "logged": true + } + ] +} diff --git a/libnymea/interfaces/pm25sensor.json b/libnymea/interfaces/pm25sensor.json new file mode 100644 index 00000000..e5ba889d --- /dev/null +++ b/libnymea/interfaces/pm25sensor.json @@ -0,0 +1,14 @@ +{ + "extends": "sensor", + "description": "PM2.5 (Fine particles) sensors. Measures PM2.5 particles in µg/m3.", + "states": [ + { + "name": "pm25", + "type": "double", + "unit": "MicroGrammPerCubicalMeter", + "minValue": 0, + "maxValue": 500, + "logged": true + } + ] +} diff --git a/libnymea/interfaces/vocsensor.json b/libnymea/interfaces/vocsensor.json new file mode 100644 index 00000000..505f9c8c --- /dev/null +++ b/libnymea/interfaces/vocsensor.json @@ -0,0 +1,14 @@ +{ + "description": "Sensor for volatile organic compounds (VOC).", + "extends": "sensor", + "states": [ + { + "name": "voc", + "type": "uint", + "unit": "PartsPerBillion", + "minValue": 0, + "maxValue": 65353, + "logged": true + } + ] +} diff --git a/libnymea/typeutils.h b/libnymea/typeutils.h index 282e53a2..1615869e 100644 --- a/libnymea/typeutils.h +++ b/libnymea/typeutils.h @@ -126,6 +126,7 @@ public: UnitEuroCentPerKiloWattHour, UnitPercentage, UnitPartsPerMillion, + UnitPartsPerBillion, UnitEuro, UnitDollar, UnitHertz, @@ -144,6 +145,7 @@ public: UnitRpm, UnitMilligramPerLiter, UnitLiter, + UnitMicroGrammPerCubicalMeter, }; Q_ENUM(Unit) diff --git a/nymea.pro b/nymea.pro index 9fec9c53..99042487 100644 --- a/nymea.pro +++ b/nymea.pro @@ -5,7 +5,7 @@ NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p" # define protocol versions JSON_PROTOCOL_VERSION_MAJOR=6 -JSON_PROTOCOL_VERSION_MINOR=1 +JSON_PROTOCOL_VERSION_MINOR=2 JSON_PROTOCOL_VERSION="$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}" LIBNYMEA_API_VERSION_MAJOR=7 LIBNYMEA_API_VERSION_MINOR=3 diff --git a/tests/auto/api.json b/tests/auto/api.json index dffb76d2..e278ea70 100644 --- a/tests/auto/api.json +++ b/tests/auto/api.json @@ -1,4 +1,4 @@ -6.1 +6.2 { "enums": { "BasicType": [ @@ -154,7 +154,8 @@ "NetworkManagerErrorWirelessNetworkingDisabled", "NetworkManagerErrorWirelessConnectionFailed", "NetworkManagerErrorNetworkingDisabled", - "NetworkManagerErrorNetworkManagerNotAvailable" + "NetworkManagerErrorNetworkManagerNotAvailable", + "NetworkManagerErrorInvalidConfiguration" ], "NetworkManagerState": [ "NetworkManagerStateUnknown", @@ -339,6 +340,7 @@ "UnitEuroCentPerKiloWattHour", "UnitPercentage", "UnitPartsPerMillion", + "UnitPartsPerBillion", "UnitEuro", "UnitDollar", "UnitHertz", @@ -356,7 +358,8 @@ "UnitNewtonMeter", "UnitRpm", "UnitMilligramPerLiter", - "UnitLiter" + "UnitLiter", + "UnitMicroGrammPerCubicalMeter" ], "UserError": [ "UserErrorNoError",