BLU package cycle fix (#18498)

Signed-off-by: Erik De Boeck <deboeck.erik@gmail.com>
This commit is contained in:
ErikDB87
2025-04-15 20:50:15 +02:00
committed by GitHub
parent 3a67c7f6e0
commit 856c9d7386
@@ -58,6 +58,7 @@ public class ShellyBluApi extends Shelly2ApiRpc {
private boolean connected = false; // true = BLU devices has connected
private ShellySettingsStatus deviceStatus = new ShellySettingsStatus();
private int lastPid = -1;
private final int pidCycleThreshold = 50;
private static final Map<String, String> MAP_INPUT_EVENT_TYPE = Map.of( //
SHELLY2_EVENT_1PUSH, SHELLY_BTNEVENT_1SHORTPUSH, //
@@ -217,7 +218,11 @@ public class ShellyBluApi extends Shelly2ApiRpc {
getString(e.data.addr), getInteger(e.data.pid));
if (e.data.pid != null) {
int pid = e.data.pid;
if (pid == lastPid) {
if (lastPid != -1 && pid < (lastPid - pidCycleThreshold)) {
logger.debug(
"{}: PID={} received is so low that a new cycle has probably begun since lastPID={}",
thingName, pid, lastPid);
} else if (pid <= lastPid) {
logger.debug("{}: Duplicate packet for PID={} received, ignore", thingName, pid);
break;
}