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

[freebox] TimeZoneProvider passed as parameter to the thing handler #7881

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 @@ -124,7 +124,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
registerDiscoveryService(handler);
return handler;
} else if (FreeboxBindingConstants.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
FreeboxThingHandler handler = new FreeboxThingHandler(thing, timeZoneProvider.getTimeZone());
FreeboxThingHandler handler = new FreeboxThingHandler(thing, timeZoneProvider);
if (FreeboxBindingConstants.FREEBOX_THING_TYPE_AIRPLAY.equals(thingTypeUID)) {
registerAudioSink(handler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import static org.openhab.binding.freebox.internal.FreeboxBindingConstants.*;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Collections;
Expand All @@ -24,6 +23,7 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import org.eclipse.smarthome.core.i18n.TimeZoneProvider;
import org.eclipse.smarthome.core.library.types.DateTimeType;
import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.library.types.OnOffType;
Expand Down Expand Up @@ -62,7 +62,8 @@ public class FreeboxThingHandler extends BaseThingHandler {

private final Logger logger = LoggerFactory.getLogger(FreeboxThingHandler.class);

private final ZoneId zoneId;
private final TimeZoneProvider timeZoneProvider;

private ScheduledFuture<?> phoneJob;
private ScheduledFuture<?> callsJob;
private FreeboxHandler bridgeHandler;
Expand All @@ -71,9 +72,9 @@ public class FreeboxThingHandler extends BaseThingHandler {
private String airPlayName;
private String airPlayPassword;

public FreeboxThingHandler(Thing thing, ZoneId zoneId) {
public FreeboxThingHandler(Thing thing, TimeZoneProvider timeZoneProvider) {
super(thing);
this.zoneId = zoneId;
this.timeZoneProvider = timeZoneProvider;
}

@Override
Expand Down Expand Up @@ -262,7 +263,7 @@ private void updateCall(FreeboxCallEntry call, String channelGroup) {
updateGroupChannelStringState(channelGroup, CALLNUMBER, call.getNumber());
updateGroupChannelDecimalState(channelGroup, CALLDURATION, call.getDuration());
ZonedDateTime zoned = ZonedDateTime.ofInstant(Instant.ofEpochMilli(call.getTimeStamp().getTimeInMillis()),
zoneId);
timeZoneProvider.getTimeZone());
updateGroupChannelDateTimeState(channelGroup, CALLTIMESTAMP, zoned);
updateGroupChannelStringState(channelGroup, CALLNAME, call.getName());
if (channelGroup.equals(ANY)) {
Expand Down