Skip to content

Commit

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

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo authored and andrewfg committed Aug 31, 2020
1 parent 49ecb52 commit ed94504
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
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

0 comments on commit ed94504

Please sign in to comment.