Skip to content

Commit 50e3ca6

Browse files
authored
[network] Fix last-seen channel being set to UNDEF at startup (openhab#17971)
Signed-off-by: Leo Siepel <[email protected]>
1 parent 7e99669 commit 50e3ca6

File tree

1 file changed

+4
-4
lines changed
  • bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler

1 file changed

+4
-4
lines changed

bundles/org.openhab.binding.network/src/main/java/org/openhab/binding/network/internal/handler/NetworkHandler.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ private void refreshValue(ChannelUID channelUID) {
100100
});
101101
break;
102102
case CHANNEL_LASTSEEN:
103+
// We should not set the last seen state to UNDEF, it prevents restoreOnStartup from working
104+
// For reference: https://github.com/openhab/openhab-addons/issues/17404
103105
Instant lastSeen = presenceDetection.getLastSeen();
104106
if (lastSeen != null) {
105107
updateState(CHANNEL_LASTSEEN, new DateTimeType(lastSeen));
106-
} else {
107-
updateState(CHANNEL_LASTSEEN, UnDefType.UNDEF);
108108
}
109109
break;
110110
default:
@@ -144,9 +144,9 @@ public void finalDetectionResult(PresenceDetectionValue value) {
144144
Instant lastSeen = presenceDetection.getLastSeen();
145145
if (value.isReachable() && lastSeen != null) {
146146
updateState(CHANNEL_LASTSEEN, new DateTimeType(lastSeen));
147-
} else if (!value.isReachable() && lastSeen == null) {
148-
updateState(CHANNEL_LASTSEEN, UnDefType.UNDEF);
149147
}
148+
// We should not set the last seen state to UNDEF, it prevents restoreOnStartup from working
149+
// For reference: https://github.com/openhab/openhab-addons/issues/17404
150150

151151
updateNetworkProperties();
152152
}

0 commit comments

Comments
 (0)