Skip to content

Commit d7f49f4

Browse files
Copilotlewie
andcommitted
Fix endianness for heatpumpVdAE and heatpumpVdAQ by using INT32_SWAP
Co-authored-by: lewie <5707426+lewie@users.noreply.github.com>
1 parent d2d59c6 commit d7f49f4

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

bundles/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/AbstractBaseParser.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,13 @@ protected Long extractUInt32(ModbusRegisterArray raw, int index, long def) {
154154
protected Long extractInt32(ModbusRegisterArray raw, int index, long def) {
155155
return Objects.requireNonNull(extractOptionalInt32(raw, index).orElse(def));
156156
}
157+
158+
protected Optional<Long> extractOptionalInt32Swap(ModbusRegisterArray raw, int index) {
159+
return ModbusBitUtilities.extractStateFromRegisters(raw, index, ValueType.INT32_SWAP)
160+
.map(DecimalType::longValue).filter(value -> value != 0);
161+
}
162+
163+
protected Long extractInt32Swap(ModbusRegisterArray raw, int index, long def) {
164+
return Objects.requireNonNull(extractOptionalInt32Swap(raw, index).orElse(def));
165+
}
157166
}

bundles/org.openhab.binding.modbus.lambda/src/main/java/org/openhab/binding/modbus/lambda/internal/parser/HeatpumpBlockParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public HeatpumpBlock parse(ModbusRegisterArray raw) {
4848
block.heatpumpRequestTReturn = extractInt16(raw, 17, (short) 0);
4949
block.heatpumpRequestHeatSink = extractInt16(raw, 18, (short) 0);
5050
block.heatpumpRelaisState = extractInt16(raw, 19, (short) 0);
51-
block.heatpumpVdAE = extractInt32(raw, 20, (long) 0);
52-
block.heatpumpVdAQ = extractInt32(raw, 22, (long) 0);
51+
block.heatpumpVdAE = extractInt32Swap(raw, 20, (long) 0);
52+
block.heatpumpVdAQ = extractInt32Swap(raw, 22, (long) 0);
5353
return block;
5454
}
5555
}

0 commit comments

Comments
 (0)