mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[network] Fix last-seen channel being set to UNDEF
at startup (#17971)
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
parent
5a1030b9f5
commit
7bb499b7df
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user