Skip to content

Commit

Permalink
Limit additionnal properties to Auto Refresh
Browse files Browse the repository at this point in the history
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
  • Loading branch information
clinique committed Mar 25, 2024
1 parent 27ef31a commit e38cbb0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected void updateNAThing(NAThing newData) {

@Override
protected void afterNewData(@Nullable NAObject newData) {
properties.put("probing", Boolean.valueOf(probing()).toString());
properties.put("dataValidity", "%s (probing: %s)".formatted(dataValidity, Boolean.valueOf(probing())));
super.afterNewData(newData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.netatmo.internal.api.dto.NAObject;
import org.openhab.binding.netatmo.internal.handler.CommonInterface;
import org.openhab.core.thing.ThingStatus;
import org.slf4j.Logger;
Expand Down Expand Up @@ -83,14 +82,7 @@ protected Duration calcDelay() {

private void freeJobAndReschedule(@Nullable Duration delay) {
refreshJob.ifPresent(job -> job.cancel(true));
refreshJob = Optional.ofNullable(delay != null
? handler.getScheduler().schedule(() -> proceedWithUpdate(), delay.toSeconds(), TimeUnit.SECONDS)
: null);
}

@Override
protected void afterNewData(@Nullable NAObject newData) {
properties.put("dataValidity", dataValidity.toString());
super.afterNewData(newData);
refreshJob = Optional.ofNullable(delay == null ? null
: handler.getScheduler().schedule(() -> proceedWithUpdate(), delay.toSeconds(), TimeUnit.SECONDS));
}
}

0 comments on commit e38cbb0

Please sign in to comment.