From 5d6bf54efec24889e94c5ea843145ea76b3fffd8 Mon Sep 17 00:00:00 2001 From: Laurent Garnier Date: Tue, 9 Jun 2020 08:47:15 +0200 Subject: [PATCH] [powermax] TimeZoneProvider passed as parameter to the thing handler Signed-off-by: Laurent Garnier --- .../powermax/internal/PowermaxHandlerFactory.java | 2 +- .../internal/handler/PowermaxThingHandler.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.powermax/src/main/java/org/openhab/binding/powermax/internal/PowermaxHandlerFactory.java b/bundles/org.openhab.binding.powermax/src/main/java/org/openhab/binding/powermax/internal/PowermaxHandlerFactory.java index 0c17458af4162..16093c263fbde 100644 --- a/bundles/org.openhab.binding.powermax/src/main/java/org/openhab/binding/powermax/internal/PowermaxHandlerFactory.java +++ b/bundles/org.openhab.binding.powermax/src/main/java/org/openhab/binding/powermax/internal/PowermaxHandlerFactory.java @@ -93,7 +93,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { registerDiscoveryService(handler); return handler; } else if (SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) { - return new PowermaxThingHandler(thing, timeZoneProvider.getTimeZone()); + return new PowermaxThingHandler(thing, timeZoneProvider); } return null; diff --git a/bundles/org.openhab.binding.powermax/src/main/java/org/openhab/binding/powermax/internal/handler/PowermaxThingHandler.java b/bundles/org.openhab.binding.powermax/src/main/java/org/openhab/binding/powermax/internal/handler/PowermaxThingHandler.java index 57a3ae82a231f..e8f100f43f113 100644 --- a/bundles/org.openhab.binding.powermax/src/main/java/org/openhab/binding/powermax/internal/handler/PowermaxThingHandler.java +++ b/bundles/org.openhab.binding.powermax/src/main/java/org/openhab/binding/powermax/internal/handler/PowermaxThingHandler.java @@ -15,9 +15,9 @@ import static org.openhab.binding.powermax.internal.PowermaxBindingConstants.*; import java.time.Instant; -import java.time.ZoneId; import java.time.ZonedDateTime; +import org.eclipse.smarthome.core.i18n.TimeZoneProvider; import org.eclipse.smarthome.core.library.types.DateTimeType; import org.eclipse.smarthome.core.library.types.OnOffType; import org.eclipse.smarthome.core.library.types.OpenClosedType; @@ -56,13 +56,13 @@ public class PowermaxThingHandler extends BaseThingHandler implements PowermaxPa private static final int X10_NR_MIN = 1; private static final int X10_NR_MAX = 16; - private final ZoneId zoneId; + private final TimeZoneProvider timeZoneProvider; private PowermaxBridgeHandler bridgeHandler; - public PowermaxThingHandler(Thing thing, ZoneId zoneId) { + public PowermaxThingHandler(Thing thing, TimeZoneProvider timeZoneProvider) { super(thing); - this.zoneId = zoneId; + this.timeZoneProvider = timeZoneProvider; } @Override @@ -184,7 +184,7 @@ public void updateChannelFromAlarmState(String channel, PowermaxState state) { updateState(TRIPPED, state.isSensorTripped(num) ? OpenClosedType.OPEN : OpenClosedType.CLOSED); } else if (channel.equals(LAST_TRIP) && (state.getSensorLastTripped(num) != null)) { ZonedDateTime zoned = ZonedDateTime.ofInstant(Instant.ofEpochMilli(state.getSensorLastTripped(num)), - zoneId); + timeZoneProvider.getTimeZone()); updateState(LAST_TRIP, new DateTimeType(zoned)); } else if (channel.equals(BYPASSED) && (state.isSensorBypassed(num) != null)) { updateState(BYPASSED, state.isSensorBypassed(num) ? OnOffType.ON : OnOffType.OFF);