Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[powermax] TimeZoneProvider passed as parameter to the thing handler #7882

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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