mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Simplify DateTimeType handling for FMI Weather
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
698939cf46
commit
b74e1e671d
@ -16,8 +16,6 @@ import static org.openhab.binding.fmiweather.internal.BindingConstants.*;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
@ -60,7 +58,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public abstract class AbstractWeatherHandler extends BaseThingHandler {
|
public abstract class AbstractWeatherHandler extends BaseThingHandler {
|
||||||
|
|
||||||
private static final ZoneId UTC = ZoneId.of("UTC");
|
|
||||||
protected static final String PROP_LONGITUDE = "longitude";
|
protected static final String PROP_LONGITUDE = "longitude";
|
||||||
protected static final String PROP_LATITUDE = "latitude";
|
protected static final String PROP_LATITUDE = "latitude";
|
||||||
protected static final String PROP_NAME = "name";
|
protected static final String PROP_NAME = "name";
|
||||||
@ -202,8 +199,7 @@ public abstract class AbstractWeatherHandler extends BaseThingHandler {
|
|||||||
*/
|
*/
|
||||||
protected <T extends Quantity<T>> void updateEpochSecondStateIfLinked(ChannelUID channelUID, long epochSecond) {
|
protected <T extends Quantity<T>> void updateEpochSecondStateIfLinked(ChannelUID channelUID, long epochSecond) {
|
||||||
if (isLinked(channelUID)) {
|
if (isLinked(channelUID)) {
|
||||||
updateState(channelUID, new DateTimeType(ZonedDateTime.ofInstant(Instant.ofEpochSecond(epochSecond), UTC)
|
updateState(channelUID, new DateTimeType(Instant.ofEpochSecond(epochSecond)));
|
||||||
.withZoneSameInstant(ZoneId.systemDefault())));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user