From 7ece8ad86db4aecea7460089ad68819ce7e131be Mon Sep 17 00:00:00 2001 From: lsiepel Date: Sat, 23 Nov 2024 21:16:16 +0100 Subject: [PATCH] [homewizard] Fix `NumberFormatException` (#17792) Signed-off-by: Leo Siepel --- .../homewizard/internal/dto/DataPayload.java | 16 ++++++++-------- .../homewizard/internal/dto/P1PayloadTest.java | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bundles/org.openhab.binding.homewizard/src/main/java/org/openhab/binding/homewizard/internal/dto/DataPayload.java b/bundles/org.openhab.binding.homewizard/src/main/java/org/openhab/binding/homewizard/internal/dto/DataPayload.java index e6154bebfb64f..4769da9e14911 100644 --- a/bundles/org.openhab.binding.homewizard/src/main/java/org/openhab/binding/homewizard/internal/dto/DataPayload.java +++ b/bundles/org.openhab.binding.homewizard/src/main/java/org/openhab/binding/homewizard/internal/dto/DataPayload.java @@ -58,13 +58,13 @@ public class DataPayload { private int longPowerFailCount; @SerializedName("active_voltage_v") - private int activeVoltage; + private double activeVoltage; @SerializedName("active_voltage_l1_v") - private int activeVoltageL1; + private double activeVoltageL1; @SerializedName("active_voltage_l2_v") - private int activeVoltageL2; + private double activeVoltageL2; @SerializedName("active_voltage_l3_v") - private int activeVoltageL3; + private double activeVoltageL3; @SerializedName("active_current_a") private double activeCurrent; @@ -175,7 +175,7 @@ public int getLongPowerFailCount() { * * @return current active voltage */ - public int getActiveVoltage() { + public double getActiveVoltage() { return activeVoltage; } @@ -184,7 +184,7 @@ public int getActiveVoltage() { * * @return active voltage on phase 1 */ - public int getActiveVoltageL1() { + public double getActiveVoltageL1() { return activeVoltageL1; } @@ -193,7 +193,7 @@ public int getActiveVoltageL1() { * * @return active voltage on phase 2 */ - public int getActiveVoltageL2() { + public double getActiveVoltageL2() { return activeVoltageL2; } @@ -202,7 +202,7 @@ public int getActiveVoltageL2() { * * @return active voltage on phase 3 */ - public int getActiveVoltageL3() { + public double getActiveVoltageL3() { return activeVoltageL3; } diff --git a/bundles/org.openhab.binding.homewizard/src/test/java/org/openhab/binding/homewizard/internal/dto/P1PayloadTest.java b/bundles/org.openhab.binding.homewizard/src/test/java/org/openhab/binding/homewizard/internal/dto/P1PayloadTest.java index cf7bdbb59bbbf..33c1c750f03fe 100644 --- a/bundles/org.openhab.binding.homewizard/src/test/java/org/openhab/binding/homewizard/internal/dto/P1PayloadTest.java +++ b/bundles/org.openhab.binding.homewizard/src/test/java/org/openhab/binding/homewizard/internal/dto/P1PayloadTest.java @@ -47,10 +47,10 @@ public void deserializeResponse() throws IOException { assertThat(key.getActivePowerL1W(), is(-676)); assertThat(key.getActivePowerL2W(), is(133)); assertThat(key.getActivePowerL3W(), is(18)); - assertThat(key.getActiveVoltage(), is(220)); - assertThat(key.getActiveVoltageL1(), is(221)); - assertThat(key.getActiveVoltageL2(), is(222)); - assertThat(key.getActiveVoltageL3(), is(223)); + assertThat(key.getActiveVoltage(), is(220.0)); + assertThat(key.getActiveVoltageL1(), is(221.0)); + assertThat(key.getActiveVoltageL2(), is(222.0)); + assertThat(key.getActiveVoltageL3(), is(223.0)); assertThat(key.getTotalEnergyExportT1Kwh(), is(8874.0)); assertThat(key.getTotalEnergyExportT2Kwh(), is(7788.0)); assertThat(key.getTotalEnergyImportT1Kwh(), is(10830.511)); @@ -80,10 +80,10 @@ public void deserializeResponseEmpty() throws IOException { assertThat(key.getActivePowerL1W(), is(0)); assertThat(key.getActivePowerL2W(), is(0)); assertThat(key.getActivePowerL3W(), is(0)); - assertThat(key.getActiveVoltage(), is(0)); - assertThat(key.getActiveVoltageL1(), is(0)); - assertThat(key.getActiveVoltageL2(), is(0)); - assertThat(key.getActiveVoltageL3(), is(0)); + assertThat(key.getActiveVoltage(), is(0.0)); + assertThat(key.getActiveVoltageL1(), is(0.0)); + assertThat(key.getActiveVoltageL2(), is(0.0)); + assertThat(key.getActiveVoltageL3(), is(0.0)); assertThat(key.getAnyPowerFailCount(), is(0)); assertThat(key.getLongPowerFailCount(), is(0)); assertThat(key.getTotalEnergyExportT1Kwh(), is(0.0));