From fb7ba1feb17f42f646f5b9294a50c77f8d19ecd0 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sun, 17 Nov 2024 18:18:35 +0100 Subject: [PATCH] Simplify DateTimeType handling for Hydrawise Signed-off-by: Jacob Laursen --- .../internal/handler/HydrawiseControllerHandler.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseControllerHandler.java b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseControllerHandler.java index 218a9ed92ae..fc2037f5bb6 100644 --- a/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseControllerHandler.java +++ b/bundles/org.openhab.binding.hydrawise/src/main/java/org/openhab/binding/hydrawise/internal/handler/HydrawiseControllerHandler.java @@ -16,6 +16,7 @@ import static org.openhab.binding.hydrawise.internal.HydrawiseBindingConstants.* import java.time.Instant; import java.time.OffsetDateTime; +import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -211,20 +212,20 @@ public class HydrawiseControllerHandler extends BaseThingHandler implements Hydr } break; case CHANNEL_ZONE_SUSPENDUNTIL: - if (!(command instanceof DateTimeType)) { + if (!(command instanceof DateTimeType dateTimeCommand)) { logger.warn("Invalid command type for suspend {}", command.getClass().getName()); return; } if (allCommand) { client.suspendAllRelays(controllerId, - ((DateTimeType) command).getZonedDateTime().format(DATE_FORMATTER)); + dateTimeCommand.getZonedDateTime(ZoneId.systemDefault()).format(DATE_FORMATTER)); } else if (zone != null) { client.suspendRelay(zone.id, - ((DateTimeType) command).getZonedDateTime().format(DATE_FORMATTER)); + dateTimeCommand.getZonedDateTime(ZoneId.systemDefault()).format(DATE_FORMATTER)); } break; default: - logger.warn("Uknown channelId {}", channelId); + logger.warn("Unknown channelId {}", channelId); return; } HydrawiseAccountHandler handler = getAccountHandler();