Simplify DateTimeType handling for OneBusAway

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2024-11-28 21:47:33 +01:00 committed by lsiepel
parent b23cb757c4
commit a989208cc6

View File

@ -15,8 +15,6 @@ package org.openhab.binding.onebusaway.internal.handler;
import static org.openhab.binding.onebusaway.internal.OneBusAwayBindingConstants.*;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
@ -168,8 +166,7 @@ public class RouteHandler extends BaseThingHandler implements RouteDataListener
private void publishChannel(ChannelUID channelUID, Calendar now, long lastUpdateTime,
List<ArrivalAndDeparture> arrivalAndDepartures) {
if (channelUID.getId().equals(CHANNEL_ID_UPDATE)) {
updateState(channelUID, new DateTimeType(
ZonedDateTime.ofInstant(Instant.ofEpochMilli(lastUpdateTime), ZoneId.systemDefault())));
updateState(channelUID, new DateTimeType(Instant.ofEpochMilli(lastUpdateTime)));
return;
}
@ -201,8 +198,7 @@ public class RouteHandler extends BaseThingHandler implements RouteDataListener
logger.debug("Not notifying {} because it is in the past.", channelUID.getId());
continue;
}
updateState(channelUID,
new DateTimeType(ZonedDateTime.ofInstant(time.toInstant(), ZoneId.systemDefault())));
updateState(channelUID, new DateTimeType(time.toInstant()));
// Update properties only when we update arrival information. This is not perfect.
if (channelUID.getId().equals(CHANNEL_ID_ARRIVAL)) {