Skip to content

Commit

Permalink
Fix too strict validation of ExtendedDeviceState number of bytes. (op…
Browse files Browse the repository at this point in the history
…enhab#11417)

Fixes openhab#11416

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
  • Loading branch information
jlaur authored and Nemer_Daud committed Jan 28, 2022
1 parent 94eb9a4 commit 2819399
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class DishWasherHandler extends MieleApplianceHandler<DishwasherChannelSe

private static final int POWER_CONSUMPTION_BYTE_POSITION = 16;
private static final int WATER_CONSUMPTION_BYTE_POSITION = 18;
private static final int EXTENDED_STATE_SIZE_BYTES = 24;
private static final int EXTENDED_STATE_MIN_SIZE_BYTES = 19;

private final Logger logger = LoggerFactory.getLogger(DishWasherHandler.class);

Expand Down Expand Up @@ -97,8 +97,8 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}

public void onApplianceExtendedStateChanged(byte[] extendedDeviceState) {
if (extendedDeviceState.length != EXTENDED_STATE_SIZE_BYTES) {
logger.error("Unexpected size of extended state: {}", extendedDeviceState);
if (extendedDeviceState.length < EXTENDED_STATE_MIN_SIZE_BYTES) {
logger.warn("Unexpected size of extended state: {}", extendedDeviceState);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class WashingMachineHandler extends MieleApplianceHandler<WashingMachineC

private static final int POWER_CONSUMPTION_BYTE_POSITION = 51;
private static final int WATER_CONSUMPTION_BYTE_POSITION = 53;
private static final int EXTENDED_STATE_SIZE_BYTES = 59;
private static final int EXTENDED_STATE_MIN_SIZE_BYTES = 54;

private final Logger logger = LoggerFactory.getLogger(WashingMachineHandler.class);

Expand Down Expand Up @@ -98,8 +98,8 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}

public void onApplianceExtendedStateChanged(byte[] extendedDeviceState) {
if (extendedDeviceState.length != EXTENDED_STATE_SIZE_BYTES) {
logger.error("Unexpected size of extended state: {}", extendedDeviceState);
if (extendedDeviceState.length < EXTENDED_STATE_MIN_SIZE_BYTES) {
logger.warn("Unexpected size of extended state: {}", extendedDeviceState);
return;
}

Expand Down

0 comments on commit 2819399

Please sign in to comment.