Simplify DateTimeType handling for Bosch Indego

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2024-11-27 23:29:51 +01:00 committed by lsiepel
parent 81f5a7fff9
commit 7feafba285

View File

@ -18,7 +18,6 @@ import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Map;
import java.util.Optional;
@ -448,12 +447,7 @@ public class BoschIndegoHandler extends BaseThingHandler implements Authorizatio
private void refreshLastCuttingTime() throws IndegoAuthenticationException, IndegoException {
if (isLinked(LAST_CUTTING)) {
Instant lastCutting = controller.getPredictiveLastCutting();
if (lastCutting != null) {
updateState(LAST_CUTTING,
new DateTimeType(ZonedDateTime.ofInstant(lastCutting, timeZoneProvider.getTimeZone())));
} else {
updateState(LAST_CUTTING, UnDefType.UNDEF);
}
updateState(LAST_CUTTING, lastCutting == null ? UnDefType.UNDEF : new DateTimeType(lastCutting));
}
}
@ -472,8 +466,7 @@ public class BoschIndegoHandler extends BaseThingHandler implements Authorizatio
if (isLinked(NEXT_CUTTING)) {
Instant nextCutting = controller.getPredictiveNextCutting();
if (nextCutting != null) {
updateState(NEXT_CUTTING,
new DateTimeType(ZonedDateTime.ofInstant(nextCutting, timeZoneProvider.getTimeZone())));
updateState(NEXT_CUTTING, new DateTimeType(nextCutting));
scheduleCuttingTimesRefresh(nextCutting);
} else {
updateState(NEXT_CUTTING, UnDefType.UNDEF);