Simplify DateTimeType handling for Gardena

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Jacob Laursen 2024-12-10 22:22:09 +01:00 committed by Ciprian Pascu
parent e950bc7d70
commit 3a6a2a27e9
2 changed files with 3 additions and 8 deletions

View File

@ -59,7 +59,7 @@ public class GardenaHandlerFactory extends BaseThingHandlerFactory {
if (THING_TYPE_ACCOUNT.equals(thing.getThingTypeUID())) {
return new GardenaAccountHandler((Bridge) thing, httpClientFactory, webSocketFactory, timeZoneProvider);
} else {
return new GardenaThingHandler(thing, timeZoneProvider);
return new GardenaThingHandler(thing);
}
}
}

View File

@ -14,7 +14,6 @@ package org.openhab.binding.gardena.internal.handler;
import static org.openhab.binding.gardena.internal.GardenaBindingConstants.*;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -44,7 +43,6 @@ import org.openhab.binding.gardena.internal.model.dto.command.ValveSetCommand.Va
import org.openhab.binding.gardena.internal.util.PropertyUtils;
import org.openhab.binding.gardena.internal.util.StringUtils;
import org.openhab.binding.gardena.internal.util.UidUtils;
import org.openhab.core.i18n.TimeZoneProvider;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
@ -74,13 +72,11 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault
public class GardenaThingHandler extends BaseThingHandler {
private final Logger logger = LoggerFactory.getLogger(GardenaThingHandler.class);
private TimeZoneProvider timeZoneProvider;
private @Nullable ScheduledFuture<?> commandResetFuture;
private Map<String, Integer> commandDurations = new HashMap<>();
public GardenaThingHandler(Thing thing, TimeZoneProvider timeZoneProvider) {
public GardenaThingHandler(Thing thing) {
super(thing);
this.timeZoneProvider = timeZoneProvider;
}
@Override
@ -213,8 +209,7 @@ public class GardenaThingHandler extends BaseThingHandler {
if (date == null) {
return UnDefType.NULL;
} else {
ZonedDateTime zdt = ZonedDateTime.ofInstant(date.toInstant(), timeZoneProvider.getTimeZone());
return new DateTimeType(zdt);
return new DateTimeType(date.toInstant());
}
}
} catch (GardenaException e) {