Skip to content

Commit

Permalink
[powermax] TimeZoneProvider passed as parameter to the thing handler (o…
Browse files Browse the repository at this point in the history
…penhab#7882)

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo authored and andrewfg committed Aug 31, 2020
1 parent ece8e34 commit f2500c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f2500c0

Please sign in to comment.