mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Simplify DateTimeType handling for Gardena
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
dd6c1f6d93
commit
000f8d7c6b
@ -59,7 +59,7 @@ public class GardenaHandlerFactory extends BaseThingHandlerFactory {
|
|||||||
if (THING_TYPE_ACCOUNT.equals(thing.getThingTypeUID())) {
|
if (THING_TYPE_ACCOUNT.equals(thing.getThingTypeUID())) {
|
||||||
return new GardenaAccountHandler((Bridge) thing, httpClientFactory, webSocketFactory, timeZoneProvider);
|
return new GardenaAccountHandler((Bridge) thing, httpClientFactory, webSocketFactory, timeZoneProvider);
|
||||||
} else {
|
} else {
|
||||||
return new GardenaThingHandler(thing, timeZoneProvider);
|
return new GardenaThingHandler(thing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ package org.openhab.binding.gardena.internal.handler;
|
|||||||
|
|
||||||
import static org.openhab.binding.gardena.internal.GardenaBindingConstants.*;
|
import static org.openhab.binding.gardena.internal.GardenaBindingConstants.*;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
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.PropertyUtils;
|
||||||
import org.openhab.binding.gardena.internal.util.StringUtils;
|
import org.openhab.binding.gardena.internal.util.StringUtils;
|
||||||
import org.openhab.binding.gardena.internal.util.UidUtils;
|
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.DateTimeType;
|
||||||
import org.openhab.core.library.types.DecimalType;
|
import org.openhab.core.library.types.DecimalType;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
@ -74,13 +72,11 @@ import org.slf4j.LoggerFactory;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class GardenaThingHandler extends BaseThingHandler {
|
public class GardenaThingHandler extends BaseThingHandler {
|
||||||
private final Logger logger = LoggerFactory.getLogger(GardenaThingHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(GardenaThingHandler.class);
|
||||||
private TimeZoneProvider timeZoneProvider;
|
|
||||||
private @Nullable ScheduledFuture<?> commandResetFuture;
|
private @Nullable ScheduledFuture<?> commandResetFuture;
|
||||||
private Map<String, Integer> commandDurations = new HashMap<>();
|
private Map<String, Integer> commandDurations = new HashMap<>();
|
||||||
|
|
||||||
public GardenaThingHandler(Thing thing, TimeZoneProvider timeZoneProvider) {
|
public GardenaThingHandler(Thing thing) {
|
||||||
super(thing);
|
super(thing);
|
||||||
this.timeZoneProvider = timeZoneProvider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -213,8 +209,7 @@ public class GardenaThingHandler extends BaseThingHandler {
|
|||||||
if (date == null) {
|
if (date == null) {
|
||||||
return UnDefType.NULL;
|
return UnDefType.NULL;
|
||||||
} else {
|
} else {
|
||||||
ZonedDateTime zdt = ZonedDateTime.ofInstant(date.toInstant(), timeZoneProvider.getTimeZone());
|
return new DateTimeType(date.toInstant());
|
||||||
return new DateTimeType(zdt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (GardenaException e) {
|
} catch (GardenaException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user