From b505a666aaf2827f49bb0d9b65c7102212efb861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20Klo=C3=9F?= Date: Wed, 17 Aug 2022 22:36:56 +0200 Subject: [PATCH] Add transaction to Go-Echarger (#13105) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sascha Kloß Signed-off-by: Andras Uhrin --- bundles/org.openhab.binding.goecharger/README.md | 1 + .../internal/GoEChargerBindingConstants.java | 1 + .../internal/api/GoEStatusResponseV2DTO.java | 3 +++ .../internal/handler/GoEChargerV2Handler.java | 10 ++++++++++ .../main/resources/OH-INF/i18n/goecharger.properties | 2 ++ .../src/main/resources/OH-INF/thing/thing-types.xml | 7 +++++++ 6 files changed, 24 insertions(+) diff --git a/bundles/org.openhab.binding.goecharger/README.md b/bundles/org.openhab.binding.goecharger/README.md index 34008166f7926..d777fb3d73d4b 100644 --- a/bundles/org.openhab.binding.goecharger/README.md +++ b/bundles/org.openhab.binding.goecharger/README.md @@ -44,6 +44,7 @@ Currently available channels are | sessionChargeEnergyLimit | Number:Energy | Wallbox stops charging after defined value, disable with 0 | 1 (r/w), 2 (r/w) | | sessionChargedEnergy | Number:Energy | Amount of energy that has been charged in this session | 1 (r), 2 (r) | | totalChargedEnergy | Number:Energy | Amount of energy that has been charged since installation | 1 (r), 2 (r) | +| transaction | Number | 0 if no card, otherwise card ID | 2 (r/w) | | allowCharging | Switch | If `ON` charging is allowed | 1 (r/w), 2 (r) | | cableCurrent | Number:ElectricCurrent | Specifies the max current that can be charged with that cable | 1 (r), 2 (r) | | temperature | Number:Temperature | Temperature of the curciuit board of the Go-eCharger | 1 (r), 2 (r) | diff --git a/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/GoEChargerBindingConstants.java b/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/GoEChargerBindingConstants.java index cadc624f80691..b05405691e03d 100644 --- a/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/GoEChargerBindingConstants.java +++ b/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/GoEChargerBindingConstants.java @@ -45,6 +45,7 @@ public class GoEChargerBindingConstants { public static final String POWER_L2 = "powerL2"; public static final String POWER_L3 = "powerL3"; public static final String POWER_ALL = "powerAll"; + public static final String TRANSACTION = "transaction"; public static final String ALLOW_CHARGING = "allowCharging"; public static final String CABLE_ENCODING = "cableCurrent"; public static final String PHASES = "phases"; diff --git a/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/api/GoEStatusResponseV2DTO.java b/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/api/GoEStatusResponseV2DTO.java index 08cb88b11af9c..94e59216df6da 100644 --- a/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/api/GoEStatusResponseV2DTO.java +++ b/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/api/GoEStatusResponseV2DTO.java @@ -27,6 +27,9 @@ public class GoEStatusResponseV2DTO extends GoEStatusResponseBaseDTO { @SerializedName("psm") public Integer phases; + @SerializedName("trx") + public Integer transaction; + @SerializedName("alw") public Boolean allowCharging; diff --git a/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/handler/GoEChargerV2Handler.java b/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/handler/GoEChargerV2Handler.java index 5c75822e6e6f4..1a93df2916f36 100644 --- a/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/handler/GoEChargerV2Handler.java +++ b/bundles/org.openhab.binding.goecharger/src/main/java/org/openhab/binding/goecharger/internal/handler/GoEChargerV2Handler.java @@ -136,6 +136,11 @@ protected State getValue(String channelId, GoEStatusResponseBaseDTO goeResponseB default: } return new StringType(error); + case TRANSACTION: + if (goeResponse.transaction == null) { + return UnDefType.UNDEF; + } + return new DecimalType(goeResponse.transaction); case ALLOW_CHARGING: return goeResponse.allowCharging == true ? OnOffType.ON : OnOffType.OFF; case TEMPERATURE_TYPE2_PORT: @@ -269,6 +274,11 @@ public void handleCommand(ChannelUID channelUID, Command command) { if (command instanceof DecimalType) { value = String.valueOf(((DecimalType) command).intValue()); } + case TRANSACTION: + key = "trx"; + if (command instanceof DecimalType) { + value = String.valueOf(((DecimalType) command).intValue()); + } } if (key != null && value != null) { diff --git a/bundles/org.openhab.binding.goecharger/src/main/resources/OH-INF/i18n/goecharger.properties b/bundles/org.openhab.binding.goecharger/src/main/resources/OH-INF/i18n/goecharger.properties index 063d5bf66bb90..ff6ce0f53563a 100644 --- a/bundles/org.openhab.binding.goecharger/src/main/resources/OH-INF/i18n/goecharger.properties +++ b/bundles/org.openhab.binding.goecharger/src/main/resources/OH-INF/i18n/goecharger.properties @@ -19,6 +19,8 @@ thing-type.config.goecharger.goe.refreshInterval.description = Refresh interval # channel types +channel-type.goecharger.trx.label = Transaction +channel-type.goecharger.trx.description = 0 for no card, otherwise card ID channel-type.goecharger.alw.label = Allow Charging channel-type.goecharger.alw.description = If true charging is allowed channel-type.goecharger.ast.label = Access Configuration diff --git a/bundles/org.openhab.binding.goecharger/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.goecharger/src/main/resources/OH-INF/thing/thing-types.xml index 42e7ef79ec2d9..4fbb56988c618 100644 --- a/bundles/org.openhab.binding.goecharger/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.goecharger/src/main/resources/OH-INF/thing/thing-types.xml @@ -23,6 +23,7 @@ + @@ -195,6 +196,12 @@ Amount of energy that has been charged since installation + + Number + + 0 for no card, otherwise card ID + + Switch