From 500f6c6cef4abd9396eb43622263ee3ece980a2b Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 21 Sep 2021 13:40:50 +0200 Subject: [PATCH 1/6] Add energystorage interface --- libnymea/interfaces/battery.json | 10 +++------- libnymea/interfaces/energystorage.json | 12 ++++++++++++ libnymea/interfaces/interfaces.qrc | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 libnymea/interfaces/energystorage.json diff --git a/libnymea/interfaces/battery.json b/libnymea/interfaces/battery.json index 43399cfe..05eeb387 100644 --- a/libnymea/interfaces/battery.json +++ b/libnymea/interfaces/battery.json @@ -20,13 +20,9 @@ "optional": true }, { - "name": "charging", - "type": "bool", - "optional": true - }, - { - "name": "discharging", - "type": "bool", + "name": "chargingState", + "type": "QString", + "allowdValues": ["idle", "charging", "discharging"], "optional": true } ] diff --git a/libnymea/interfaces/energystorage.json b/libnymea/interfaces/energystorage.json new file mode 100644 index 00000000..866024d5 --- /dev/null +++ b/libnymea/interfaces/energystorage.json @@ -0,0 +1,12 @@ +{ + "description": "Interfaces for devices that store electrical energy and can return it at a later point, such as batteries. The currentPower state follows the usual convention that positive is 'consumed' energy and negative values represent 'produced' or in this case 'returned' energy.", + "extends": ["battery", "smartmeter"], + "states": [ + { + "name": "currentPower", + "type": "double", + "unit": "Watt", + "logged": true + } + ] +} diff --git a/libnymea/interfaces/interfaces.qrc b/libnymea/interfaces/interfaces.qrc index d2996531..3d6ee2ca 100644 --- a/libnymea/interfaces/interfaces.qrc +++ b/libnymea/interfaces/interfaces.qrc @@ -88,5 +88,6 @@ cleaningrobot.json airquality.json indoorairquality.json + energystorage.json From d8acacf32256db78e95722284e9b796c0a993c9d Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 23 Sep 2021 01:12:53 +0200 Subject: [PATCH 2/6] Add capacity state --- libnymea/interfaces/energystorage.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libnymea/interfaces/energystorage.json b/libnymea/interfaces/energystorage.json index 866024d5..0bb56c01 100644 --- a/libnymea/interfaces/energystorage.json +++ b/libnymea/interfaces/energystorage.json @@ -7,6 +7,11 @@ "type": "double", "unit": "Watt", "logged": true + }, + { + "name": "capacity", + "type": "double", + "unit": "WattHour" } ] } From d01fb7d16ac0f4a971786577983cb1529c961f5a Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 23 Sep 2021 01:13:03 +0200 Subject: [PATCH 3/6] Log producers/consumers totals --- libnymea/interfaces/smartmeterconsumer.json | 3 ++- libnymea/interfaces/smartmeterproducer.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libnymea/interfaces/smartmeterconsumer.json b/libnymea/interfaces/smartmeterconsumer.json index e95289c5..d3316399 100644 --- a/libnymea/interfaces/smartmeterconsumer.json +++ b/libnymea/interfaces/smartmeterconsumer.json @@ -5,7 +5,8 @@ { "name": "totalEnergyConsumed", "type": "double", - "unit": "KiloWattHour" + "unit": "KiloWattHour", + "logged": true }, { "name": "currentPower", diff --git a/libnymea/interfaces/smartmeterproducer.json b/libnymea/interfaces/smartmeterproducer.json index 5d825406..8e374a97 100644 --- a/libnymea/interfaces/smartmeterproducer.json +++ b/libnymea/interfaces/smartmeterproducer.json @@ -5,7 +5,8 @@ { "name": "totalEnergyProduced", "type": "double", - "unit": "KiloWattHour" + "unit": "KiloWattHour", + "logged": true }, { "name": "currentPower", From 4b4bef28852af28517d4dd477cbbe195e586c201 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 23 Sep 2021 14:27:41 +0200 Subject: [PATCH 4/6] Adjust unit for energystorage --- libnymea/interfaces/energystorage.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnymea/interfaces/energystorage.json b/libnymea/interfaces/energystorage.json index 0bb56c01..1670e974 100644 --- a/libnymea/interfaces/energystorage.json +++ b/libnymea/interfaces/energystorage.json @@ -11,7 +11,7 @@ { "name": "capacity", "type": "double", - "unit": "WattHour" + "unit": "KiloWattHour" } ] } From 20b13bc3edac3e448bcdc8ce95daccbf781747f5 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 23 Sep 2021 14:27:56 +0200 Subject: [PATCH 5/6] Enforce smartmeterconsumer on evchargers --- libnymea/interfaces/evcharger.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnymea/interfaces/evcharger.json b/libnymea/interfaces/evcharger.json index 8de3ba15..ed02972e 100644 --- a/libnymea/interfaces/evcharger.json +++ b/libnymea/interfaces/evcharger.json @@ -1,6 +1,6 @@ { "description": "An EV-charger. Extends the power interface for charging/not charging an electric vehicle. Supports regulation of the max. charging current in addition to be powered on or off.", - "extends": "power", + "extends": ["smartmeterconsumer", "power"], "states": [ { "name": "maxChargingCurrent", From 19b1657f21a2851ffd6f4b1ee081f34e4870766d Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 23 Sep 2021 18:20:41 +0200 Subject: [PATCH 6/6] Make currentPower mandatory for smartmeters --- libnymea/interfaces/smartmeterconsumer.json | 1 - libnymea/interfaces/smartmeterproducer.json | 1 - 2 files changed, 2 deletions(-) diff --git a/libnymea/interfaces/smartmeterconsumer.json b/libnymea/interfaces/smartmeterconsumer.json index d3316399..69456283 100644 --- a/libnymea/interfaces/smartmeterconsumer.json +++ b/libnymea/interfaces/smartmeterconsumer.json @@ -12,7 +12,6 @@ "name": "currentPower", "type": "double", "unit": "Watt", - "optional": true, "logged": true } ] diff --git a/libnymea/interfaces/smartmeterproducer.json b/libnymea/interfaces/smartmeterproducer.json index 8e374a97..442542ba 100644 --- a/libnymea/interfaces/smartmeterproducer.json +++ b/libnymea/interfaces/smartmeterproducer.json @@ -12,7 +12,6 @@ "name": "currentPower", "type": "double", "unit": "Watt", - "optional": true, "logged": true } ]