mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +01:00
Simplify DateTimeType handling for Meteo France
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
a1a61ff7c8
commit
daabae72e0
@ -68,6 +68,6 @@ public class MeteoFranceHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
return BRIDGE_TYPE_API.equals(thingTypeUID) ? new MeteoFranceBridgeHandler((Bridge) thing, deserializer)
|
||||
: THING_TYPE_VIGILANCE.equals(thingTypeUID) ? new VigilanceHandler(thing, zoneId, iconProvider)
|
||||
: THING_TYPE_RAIN_FORECAST.equals(thingTypeUID) ? new RainForecastHandler(thing, zoneId) : null;
|
||||
: THING_TYPE_RAIN_FORECAST.equals(thingTypeUID) ? new RainForecastHandler(thing) : null;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ package org.openhab.binding.meteofrance.internal.handler;
|
||||
import static org.openhab.binding.meteofrance.internal.MeteoFranceBindingConstants.*;
|
||||
import static org.openhab.core.types.TimeSeries.Policy.REPLACE;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
@ -58,15 +57,13 @@ import org.slf4j.LoggerFactory;
|
||||
public class RainForecastHandler extends BaseThingHandler implements MeteoFranceChildHandler {
|
||||
private final Logger logger = LoggerFactory.getLogger(RainForecastHandler.class);
|
||||
private final ChannelUID intensityChannelUID;
|
||||
private final ZoneId systemZoneId;
|
||||
|
||||
private Optional<ScheduledFuture<?>> refreshJob = Optional.empty();
|
||||
private Optional<PointType> location = Optional.empty();
|
||||
|
||||
public RainForecastHandler(Thing thing, ZoneId zoneId) {
|
||||
public RainForecastHandler(Thing thing) {
|
||||
super(thing);
|
||||
this.intensityChannelUID = new ChannelUID(getThing().getUID(), INTENSITY);
|
||||
this.systemZoneId = zoneId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -169,9 +166,7 @@ public class RainForecastHandler extends BaseThingHandler implements MeteoFrance
|
||||
|
||||
private void updateDate(String channelId, @Nullable ZonedDateTime zonedDateTime) {
|
||||
if (isLinked(channelId)) {
|
||||
updateState(channelId,
|
||||
zonedDateTime != null ? new DateTimeType(zonedDateTime.withZoneSameInstant(systemZoneId))
|
||||
: UnDefType.NULL);
|
||||
updateState(channelId, zonedDateTime != null ? new DateTimeType(zonedDateTime) : UnDefType.NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class VigilanceHandler extends BaseThingHandler implements MeteoFranceChi
|
||||
|
||||
private void updateDate(String channelId, ZonedDateTime zonedDateTime) {
|
||||
if (isLinked(channelId)) {
|
||||
updateState(channelId, new DateTimeType(zonedDateTime.withZoneSameInstant(systemZoneId)));
|
||||
updateState(channelId, new DateTimeType(zonedDateTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user