From d46ef1c5faa43f6fc5d186d2c9beffaf3185563a Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 9 Mar 2021 23:56:05 +0100 Subject: [PATCH] Rework battery interface --- libnymea/interfaces/battery.json | 24 ++++++++++++++++++++ libnymea/interfaces/batterylevel.json | 12 ---------- libnymea/interfaces/interfaces.qrc | 1 - plugins/mock/integrationpluginmock.json | 2 +- tests/auto/devices/testdevices.cpp | 2 +- tests/auto/integrations/testintegrations.cpp | 2 +- 6 files changed, 27 insertions(+), 16 deletions(-) delete mode 100644 libnymea/interfaces/batterylevel.json diff --git a/libnymea/interfaces/battery.json b/libnymea/interfaces/battery.json index e6c0e3b2..43399cfe 100644 --- a/libnymea/interfaces/battery.json +++ b/libnymea/interfaces/battery.json @@ -4,6 +4,30 @@ "name": "batteryCritical", "type": "bool", "logged": true + }, + { + "name": "batteryLevel", + "type": "int", + "minValue": 0, + "maxValue": 100, + "unit": "Percentage", + "optional": true, + "logged": true + }, + { + "name": "pluggedIn", + "type": "bool", + "optional": true + }, + { + "name": "charging", + "type": "bool", + "optional": true + }, + { + "name": "discharging", + "type": "bool", + "optional": true } ] } diff --git a/libnymea/interfaces/batterylevel.json b/libnymea/interfaces/batterylevel.json deleted file mode 100644 index e9533acb..00000000 --- a/libnymea/interfaces/batterylevel.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "battery", - "states": [ - { - "name": "batteryLevel", - "type": "int", - "minValue": 0, - "maxValue": 100, - "unit": "Percentage" - } - ] -} diff --git a/libnymea/interfaces/interfaces.qrc b/libnymea/interfaces/interfaces.qrc index 89d82f1e..ca9219f0 100644 --- a/libnymea/interfaces/interfaces.qrc +++ b/libnymea/interfaces/interfaces.qrc @@ -24,7 +24,6 @@ mediametadataprovider.json mediaplayer.json battery.json - batterylevel.json button.json multibutton.json simplebutton.json diff --git a/plugins/mock/integrationpluginmock.json b/plugins/mock/integrationpluginmock.json index 360bd45e..c79d1e90 100644 --- a/plugins/mock/integrationpluginmock.json +++ b/plugins/mock/integrationpluginmock.json @@ -30,7 +30,7 @@ "id": "753f0d32-0468-4d08-82ed-1964aab03298", "name": "mock", "displayName": "Mock Thing", - "interfaces": ["system", "light", "batterylevel", "wirelessconnectable", "update"], + "interfaces": ["system", "light", "battery", "wirelessconnectable", "update"], "createMethods": ["user", "discovery"], "browsable": true, "discoveryParamTypes": [ diff --git a/tests/auto/devices/testdevices.cpp b/tests/auto/devices/testdevices.cpp index 1c65300b..546c4791 100644 --- a/tests/auto/devices/testdevices.cpp +++ b/tests/auto/devices/testdevices.cpp @@ -327,7 +327,7 @@ void TestDevices::verifyInterfaces() QVERIFY(!mockDevice.isEmpty()); QVariantList interfaces = mockDevice.value("interfaces").toList(); - QVariantList expectedInterfaces = {"system", "light", "power", "batterylevel", "battery", "wirelessconnectable", "connectable", "update"}; + QVariantList expectedInterfaces = {"system", "light", "power", "battery", "wirelessconnectable", "connectable", "update"}; qCDebug(dcTests()) << interfaces; qCDebug(dcTests()) << expectedInterfaces; QCOMPARE(interfaces, expectedInterfaces); diff --git a/tests/auto/integrations/testintegrations.cpp b/tests/auto/integrations/testintegrations.cpp index c59ac6ea..ce2d6c82 100644 --- a/tests/auto/integrations/testintegrations.cpp +++ b/tests/auto/integrations/testintegrations.cpp @@ -339,7 +339,7 @@ void TestIntegrations::verifyInterfaces() QVERIFY(!mock.isEmpty()); QVariantList interfaces = mock.value("interfaces").toList(); - QVariantList expectedInterfaces = {"system", "light", "power", "batterylevel", "battery", "wirelessconnectable", "connectable", "update"}; + QVariantList expectedInterfaces = {"system", "light", "power", "battery", "wirelessconnectable", "connectable", "update"}; qCDebug(dcTests()) << interfaces; qCDebug(dcTests()) << expectedInterfaces; QCOMPARE(interfaces, expectedInterfaces);