Skip to content

Commit a0bae2f

Browse files
authored
[homewizard] Fix for incorrect thing type id for kWh meter (openhab#18352)
* Fixed toString in several payloads Signed-off-by: Gearrel Welvaart <[email protected]> * Fix for incorrect thing-type id Signed-off-by: Gearrel Welvaart <[email protected]> --------- Signed-off-by: Gearrel Welvaart <[email protected]>
1 parent 77c729b commit a0bae2f

File tree

8 files changed

+15
-14
lines changed

8 files changed

+15
-14
lines changed

bundles/org.openhab.binding.homewizard/src/main/java/org/openhab/binding/homewizard/internal/devices/HomeWizardEnergyMeterMeasurementPayload.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ public String toString() {
250250
voltage: %f voltageL1: %f voltageL2: %f voltageL3: %f
251251
current: %f currentL1: %f currentL2: %f currentL3: %f frequency: %f
252252
]
253-
""", energyImport, energyImportT1, energyExportT2, energyExport, energyExportT1, energyExportT2,
254-
voltage, voltageL1, voltageL2, voltageL3, current, currentL1, currentL2, currentL3, frequency);
253+
""", energyImport, energyImportT1, energyImportT2, energyExport, energyExportT1, energyExportT2, power,
254+
powerL1, powerL2, powerL3, voltage, voltageL1, voltageL2, voltageL3, current, currentL1, currentL2,
255+
currentL3, frequency);
255256
}
256257
}

bundles/org.openhab.binding.homewizard/src/main/java/org/openhab/binding/homewizard/internal/devices/p1_meter/HomeWizardP1MeterMeasurementPayload.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ public double getTotalGasM3() {
160160
@Override
161161
public String toString() {
162162
return super.toString() + " " + String.format("""
163-
Data [protocolVersion: %d meterModel: %s anyPowerFailCount: %f longPowerFailCount: %f"
164-
totalGasM3: %f gasTimestamp: %.0f"
163+
Data [protocolVersion: %d meterModel: %s anyPowerFailCount: %d longPowerFailCount: %d"
164+
totalGasM3: %f gasTimestamp: %d"
165165
166166
""", protocolVersion, meterModel, anyPowerFailCount, longPowerFailCount, totalGasM3, gasTimestamp);
167167
}

bundles/org.openhab.binding.homewizard/src/main/java/org/openhab/binding/homewizard/internal/devices/plug_in_battery/HomeWizardPlugInBatteryMeasurementPayload.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public int getCycles() {
5353
@Override
5454
public String toString() {
5555
return String.format("""
56-
Battery Data [stateOfCharge: %d cycles: %d"]
56+
Battery Data [stateOfCharge: %f cycles: %f"]
5757
""", stateOfCharge, cycles);
5858
}
5959
}

bundles/org.openhab.binding.homewizard/src/main/java/org/openhab/binding/homewizard/internal/devices/water_meter/HomeWizardWaterMeterHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
5757
*/
5858
@Override
5959
protected void handleDataPayload(String data) {
60-
var payload = gson.fromJson(data, HomeWizardWaterMeterDataPayload.class);
60+
var payload = gson.fromJson(data, HomeWizardWaterMeterMeasurementPayload.class);
6161
if (payload != null) {
6262
if (!thing.getThingTypeUID().equals(HomeWizardBindingConstants.THING_TYPE_WATERMETER)) {
6363
updateState(HomeWizardBindingConstants.CHANNEL_GROUP_WATER,
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
*/
2626
@NonNullByDefault
27-
public class HomeWizardWaterMeterDataPayload {
27+
public class HomeWizardWaterMeterMeasurementPayload {
2828

2929
@SerializedName("active_liter_lpm")
3030
private double activeLiter;

bundles/org.openhab.binding.homewizard/src/main/resources/OH-INF/i18n/homewizard.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ addon.homewizard.description = This binding provides access to the data provided
55

66
# thing types
77

8-
thing-type.homewizard.HWE-kwh.label = HomeWizard kWh Meter
9-
thing-type.homewizard.HWE-kwh.description = This thing provides the measurement data that is available through the API of a HomeWizard kWh Meter.
8+
thing-type.homewizard.hwe-kwh.label = HomeWizard kWh Meter
9+
thing-type.homewizard.hwe-kwh.description = This thing provides the measurement data that is available through the API of a HomeWizard kWh Meter.
1010
thing-type.homewizard.energy_socket.label = HomeWizard Energysocket
1111
thing-type.homewizard.energy_socket.description = This thing provides the measurement data that is available through the http interface of a HomeWizard Energysocket.
1212
thing-type.homewizard.hwe-bat.label = HomeWizard Plug-In Battery

bundles/org.openhab.binding.homewizard/src/main/resources/OH-INF/thing/hwe-kwh.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
55
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
66

7-
<thing-type id="HWE-kwh">
7+
<thing-type id="hwe-kwh">
88
<label>HomeWizard kWh Meter</label>
99
<description>This thing provides the measurement data that is available through the API of a HomeWizard
1010
kWh Meter.</description>

bundles/org.openhab.binding.homewizard/src/test/java/org/openhab/binding/homewizard/internal/devices/water_meter/HomeWizardWaterMeterMeasurementPayloadTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public class HomeWizardWaterMeterMeasurementPayloadTest {
3434

3535
@Test
3636
public void deserializeResponse() throws IOException {
37-
HomeWizardWaterMeterDataPayload key = DATA_UTIL.fromJson("response-measurement-water-meter.json",
38-
HomeWizardWaterMeterDataPayload.class);
37+
HomeWizardWaterMeterMeasurementPayload key = DATA_UTIL.fromJson("response-measurement-water-meter.json",
38+
HomeWizardWaterMeterMeasurementPayload.class);
3939
assertThat(key, is(notNullValue()));
4040

4141
assertThat(key.getActiveLiter(), is(7.2));
@@ -44,8 +44,8 @@ public void deserializeResponse() throws IOException {
4444

4545
@Test
4646
public void deserializeResponseEmpty() throws IOException {
47-
HomeWizardWaterMeterDataPayload key = DATA_UTIL.fromJson("response-empty.json",
48-
HomeWizardWaterMeterDataPayload.class);
47+
HomeWizardWaterMeterMeasurementPayload key = DATA_UTIL.fromJson("response-empty.json",
48+
HomeWizardWaterMeterMeasurementPayload.class);
4949
assertThat(key, is(notNullValue()));
5050

5151
assertThat(key.getActiveLiter(), is(0.0));

0 commit comments

Comments
 (0)