mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +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)
|
return BRIDGE_TYPE_API.equals(thingTypeUID) ? new MeteoFranceBridgeHandler((Bridge) thing, deserializer)
|
||||||
: THING_TYPE_VIGILANCE.equals(thingTypeUID) ? new VigilanceHandler(thing, zoneId, iconProvider)
|
: 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.binding.meteofrance.internal.MeteoFranceBindingConstants.*;
|
||||||
import static org.openhab.core.types.TimeSeries.Policy.REPLACE;
|
import static org.openhab.core.types.TimeSeries.Policy.REPLACE;
|
||||||
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -58,15 +57,13 @@ import org.slf4j.LoggerFactory;
|
|||||||
public class RainForecastHandler extends BaseThingHandler implements MeteoFranceChildHandler {
|
public class RainForecastHandler extends BaseThingHandler implements MeteoFranceChildHandler {
|
||||||
private final Logger logger = LoggerFactory.getLogger(RainForecastHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(RainForecastHandler.class);
|
||||||
private final ChannelUID intensityChannelUID;
|
private final ChannelUID intensityChannelUID;
|
||||||
private final ZoneId systemZoneId;
|
|
||||||
|
|
||||||
private Optional<ScheduledFuture<?>> refreshJob = Optional.empty();
|
private Optional<ScheduledFuture<?>> refreshJob = Optional.empty();
|
||||||
private Optional<PointType> location = Optional.empty();
|
private Optional<PointType> location = Optional.empty();
|
||||||
|
|
||||||
public RainForecastHandler(Thing thing, ZoneId zoneId) {
|
public RainForecastHandler(Thing thing) {
|
||||||
super(thing);
|
super(thing);
|
||||||
this.intensityChannelUID = new ChannelUID(getThing().getUID(), INTENSITY);
|
this.intensityChannelUID = new ChannelUID(getThing().getUID(), INTENSITY);
|
||||||
this.systemZoneId = zoneId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -169,9 +166,7 @@ public class RainForecastHandler extends BaseThingHandler implements MeteoFrance
|
|||||||
|
|
||||||
private void updateDate(String channelId, @Nullable ZonedDateTime zonedDateTime) {
|
private void updateDate(String channelId, @Nullable ZonedDateTime zonedDateTime) {
|
||||||
if (isLinked(channelId)) {
|
if (isLinked(channelId)) {
|
||||||
updateState(channelId,
|
updateState(channelId, zonedDateTime != null ? new DateTimeType(zonedDateTime) : UnDefType.NULL);
|
||||||
zonedDateTime != null ? new DateTimeType(zonedDateTime.withZoneSameInstant(systemZoneId))
|
|
||||||
: UnDefType.NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ public class VigilanceHandler extends BaseThingHandler implements MeteoFranceChi
|
|||||||
|
|
||||||
private void updateDate(String channelId, ZonedDateTime zonedDateTime) {
|
private void updateDate(String channelId, ZonedDateTime zonedDateTime) {
|
||||||
if (isLinked(channelId)) {
|
if (isLinked(channelId)) {
|
||||||
updateState(channelId, new DateTimeType(zonedDateTime.withZoneSameInstant(systemZoneId)));
|
updateState(channelId, new DateTimeType(zonedDateTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user