diff --git a/bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler/NetworkHandler.java b/bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler/NetworkHandler.java index 3f460daa3f8..3b8472de72b 100644 --- a/bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler/NetworkHandler.java +++ b/bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler/NetworkHandler.java @@ -100,11 +100,11 @@ public class NetworkHandler extends BaseThingHandler }); break; case CHANNEL_LASTSEEN: + // We should not set the last seen state to UNDEF, it prevents restoreOnStartup from working + // For reference: https://github.com/openhab/openhab-addons/issues/17404 Instant lastSeen = presenceDetection.getLastSeen(); if (lastSeen != null) { updateState(CHANNEL_LASTSEEN, new DateTimeType(lastSeen)); - } else { - updateState(CHANNEL_LASTSEEN, UnDefType.UNDEF); } break; default: @@ -144,9 +144,9 @@ public class NetworkHandler extends BaseThingHandler Instant lastSeen = presenceDetection.getLastSeen(); if (value.isReachable() && lastSeen != null) { updateState(CHANNEL_LASTSEEN, new DateTimeType(lastSeen)); - } else if (!value.isReachable() && lastSeen == null) { - updateState(CHANNEL_LASTSEEN, UnDefType.UNDEF); } + // We should not set the last seen state to UNDEF, it prevents restoreOnStartup from working + // For reference: https://github.com/openhab/openhab-addons/issues/17404 updateNetworkProperties(); }