Skip to content

Commit e1f95e5

Browse files
committed
Fix techem WZ date range.
Apparently techem reports december (or maybe january) as month 0.
1 parent 704ae42 commit e1f95e5

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

org.openhab.binding.wmbus/src/main/java/org/openhab/binding/wmbus/device/techem/decoder/AbstractTechemFrameDecoder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ protected final LocalDateTime parseCurrentDate(byte[] buffer, int index) {
8383
HexUtils.bytesToHex(read(buffer, index, index + 1)));
8484
day = 1;
8585
}
86+
if (month <= 0) {
87+
logger.trace("Detected invalid month number {} in byte representation: {}, changing to last month of year", month,
88+
HexUtils.bytesToHex(read(buffer, index, index + 1)));
89+
month = 12;
90+
}
8691

8792
LocalDateTime dateTime = LocalDateTime.now().withMonth(month).withDayOfMonth(day);
8893
return dateTime.truncatedTo(ChronoUnit.SECONDS);

0 commit comments

Comments
 (0)