mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +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
7e9966989a
commit
50e3ca62c0
@ -100,11 +100,11 @@ public class NetworkHandler extends BaseThingHandler
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case CHANNEL_LASTSEEN:
|
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();
|
Instant lastSeen = presenceDetection.getLastSeen();
|
||||||
if (lastSeen != null) {
|
if (lastSeen != null) {
|
||||||
updateState(CHANNEL_LASTSEEN, new DateTimeType(lastSeen));
|
updateState(CHANNEL_LASTSEEN, new DateTimeType(lastSeen));
|
||||||
} else {
|
|
||||||
updateState(CHANNEL_LASTSEEN, UnDefType.UNDEF);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -144,9 +144,9 @@ public class NetworkHandler extends BaseThingHandler
|
|||||||
Instant lastSeen = presenceDetection.getLastSeen();
|
Instant lastSeen = presenceDetection.getLastSeen();
|
||||||
if (value.isReachable() && lastSeen != null) {
|
if (value.isReachable() && lastSeen != null) {
|
||||||
updateState(CHANNEL_LASTSEEN, new DateTimeType(lastSeen));
|
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();
|
updateNetworkProperties();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user