From 886f5c49f6eed394970e790709b9e8a1229e0980 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sat, 10 Jul 2021 01:22:27 +0200 Subject: [PATCH] Add O2, PH, ORP, CO and flammable gas sensor interfaces --- libnymea/interfaces/co2sensor.json | 2 +- libnymea/interfaces/cosensor.json | 12 ++++++++++++ libnymea/interfaces/gassensor.json | 12 ++++++++++++ libnymea/interfaces/interfaces.qrc | 21 +++++++++++++-------- libnymea/interfaces/o2sensor.json | 19 +++++++++++++++++++ libnymea/interfaces/orpsensor.json | 12 ++++++++++++ libnymea/interfaces/phsensor.json | 13 +++++++++++++ libnymea/typeutils.h | 3 ++- nymea.pro | 4 ++-- plugins/mock/integrationpluginmock.h | 2 +- plugins/mock/integrationpluginmock.json | 2 +- tests/auto/api.json | 5 +++-- 12 files changed, 91 insertions(+), 16 deletions(-) create mode 100644 libnymea/interfaces/cosensor.json create mode 100644 libnymea/interfaces/gassensor.json create mode 100644 libnymea/interfaces/o2sensor.json create mode 100644 libnymea/interfaces/orpsensor.json create mode 100644 libnymea/interfaces/phsensor.json diff --git a/libnymea/interfaces/co2sensor.json b/libnymea/interfaces/co2sensor.json index e4673292..0d6442b7 100644 --- a/libnymea/interfaces/co2sensor.json +++ b/libnymea/interfaces/co2sensor.json @@ -1,6 +1,6 @@ { "extends": "sensor", - "description": "CO2 sensors. Measures co2 in parts per million.", + "description": "CO2 (carbon dioxide) sensors. Measures co2 in parts per million.", "states": [ { "name": "co2", diff --git a/libnymea/interfaces/cosensor.json b/libnymea/interfaces/cosensor.json new file mode 100644 index 00000000..e758b1cd --- /dev/null +++ b/libnymea/interfaces/cosensor.json @@ -0,0 +1,12 @@ +{ + "extends": "sensor", + "description": "CO (carbon monoxide) sensors. Measures co in parts per million.", + "states": [ + { + "name": "co", + "type": "double", + "unit": "PartsPerMillion", + "logged": true + } + ] +} diff --git a/libnymea/interfaces/gassensor.json b/libnymea/interfaces/gassensor.json new file mode 100644 index 00000000..ccbffe0e --- /dev/null +++ b/libnymea/interfaces/gassensor.json @@ -0,0 +1,12 @@ +{ + "extends": "sensor", + "description": "Flammable gas (LPG, Propane, Methane etc) sensors. Measures co2 in parts per million.", + "states": [ + { + "name": "gas", + "type": "double", + "unit": "PartsPerMillion", + "logged": true + } + ] +} diff --git a/libnymea/interfaces/interfaces.qrc b/libnymea/interfaces/interfaces.qrc index 90739849..5e06a589 100644 --- a/libnymea/interfaces/interfaces.qrc +++ b/libnymea/interfaces/interfaces.qrc @@ -5,7 +5,6 @@ light.json dimmablelight.json account.json - daylightsensor.json colortemperaturelight.json doorbell.json colorlight.json @@ -31,12 +30,24 @@ simplemultibutton.json longpressmultibutton.json sensor.json + daylightsensor.json + closablesensor.json + presencesensor.json + watersensor.json temperaturesensor.json humiditysensor.json pressuresensor.json moisturesensor.json - conductivitysensor.json lightsensor.json + noisesensor.json + windspeedsensor.json + cosensor.json + co2sensor.json + o2sensor.json + gassensor.json + orpsensor.json + conductivitysensor.json + phsensor.json thermostat.json connectable.json wirelessconnectable.json @@ -65,19 +76,13 @@ useraccesscontrol.json heating.json evcharger.json - noisesensor.json - windspeedsensor.json - co2sensor.json - presencesensor.json navigationpad.json extendednavigationpad.json - closablesensor.json powerswitch.json barcodescanner.json irrigation.json venetianblind.json update.json - watersensor.json cleaningrobot.json airquality.json indoorairquality.json diff --git a/libnymea/interfaces/o2sensor.json b/libnymea/interfaces/o2sensor.json new file mode 100644 index 00000000..40a798c8 --- /dev/null +++ b/libnymea/interfaces/o2sensor.json @@ -0,0 +1,19 @@ +{ + "description": "Interface for oxygen sensors. O2 saturation in percentage is mandatory, optionally more advanced sensors may offer O2 values in milligrams per liter (mg/L).", + "extends": "sensor", + "states": [ + { + "name": "o2saturation", + "type": "double", + "unit": "Percentage", + "logged": true + }, + { + "name": "o2", + "type": "double", + "unit": "MilligramPerLiter", + "logged": true, + "optional": true + } + ] +} diff --git a/libnymea/interfaces/orpsensor.json b/libnymea/interfaces/orpsensor.json new file mode 100644 index 00000000..8c2803f5 --- /dev/null +++ b/libnymea/interfaces/orpsensor.json @@ -0,0 +1,12 @@ +{ + "description": "Interface for ORP (Oxidation Reduction Potential) sensors.", + "extends": "sensor", + "states": [ + { + "name": "orp", + "type": "double", + "unit": "MilliVolt", + "logged": true + } + ] +} diff --git a/libnymea/interfaces/phsensor.json b/libnymea/interfaces/phsensor.json new file mode 100644 index 00000000..302e9a84 --- /dev/null +++ b/libnymea/interfaces/phsensor.json @@ -0,0 +1,13 @@ +{ + "description": "Interface for PH sensors.", + "extends": "sensor", + "states": [ + { + "name": "ph", + "type": "double", + "minValue": 0, + "maxValue": 14, + "logged": true + } + ] +} diff --git a/libnymea/typeutils.h b/libnymea/typeutils.h index eaa8cddb..a3da3cda 100644 --- a/libnymea/typeutils.h +++ b/libnymea/typeutils.h @@ -140,7 +140,8 @@ public: UnitDuration, UnitNewton, UnitNewtonMeter, - UnitRpm + UnitRpm, + UnitMilligramPerLiter, }; Q_ENUM(Unit) diff --git a/nymea.pro b/nymea.pro index b20daaa7..0794868b 100644 --- a/nymea.pro +++ b/nymea.pro @@ -5,10 +5,10 @@ NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p" # define protocol versions JSON_PROTOCOL_VERSION_MAJOR=5 -JSON_PROTOCOL_VERSION_MINOR=6 +JSON_PROTOCOL_VERSION_MINOR=7 JSON_PROTOCOL_VERSION="$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}" LIBNYMEA_API_VERSION_MAJOR=7 -LIBNYMEA_API_VERSION_MINOR=1 +LIBNYMEA_API_VERSION_MINOR=2 LIBNYMEA_API_VERSION_PATCH=0 LIBNYMEA_API_VERSION="$${LIBNYMEA_API_VERSION_MAJOR}.$${LIBNYMEA_API_VERSION_MINOR}.$${LIBNYMEA_API_VERSION_PATCH}" diff --git a/plugins/mock/integrationpluginmock.h b/plugins/mock/integrationpluginmock.h index 8e09c13e..1514c42a 100644 --- a/plugins/mock/integrationpluginmock.h +++ b/plugins/mock/integrationpluginmock.h @@ -32,7 +32,7 @@ #define INTEGRATIONPLUGINMOCK_H #include "integrations/integrationplugin.h" - +#include "extern-plugininfo.h" #include class HttpDaemon; diff --git a/plugins/mock/integrationpluginmock.json b/plugins/mock/integrationpluginmock.json index c79d1e90..627e895b 100644 --- a/plugins/mock/integrationpluginmock.json +++ b/plugins/mock/integrationpluginmock.json @@ -37,7 +37,7 @@ { "id": "d222adb4-2f9c-4c3f-8655-76400d0fb6ce", "name": "resultCount", - "displayName": "resultCount", + "displayName": "Result count", "type": "int", "defaultValue": 2, "allowedValues": [1, 2] diff --git a/tests/auto/api.json b/tests/auto/api.json index 343b4cea..9d6b39ad 100644 --- a/tests/auto/api.json +++ b/tests/auto/api.json @@ -1,4 +1,4 @@ -5.6 +5.7 { "enums": { "BasicType": [ @@ -376,7 +376,8 @@ "UnitDuration", "UnitNewton", "UnitNewtonMeter", - "UnitRpm" + "UnitRpm", + "UnitMilligramPerLiter" ], "UserError": [ "UserErrorNoError",