mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Simplify DateTimeType handling for Wolf Smartset
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
9d72871018
commit
b186639344
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.wolfsmartset.internal.handler;
|
package org.openhab.binding.wolfsmartset.internal.handler;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.measure.Unit;
|
import javax.measure.Unit;
|
||||||
@ -20,7 +19,6 @@ import javax.measure.quantity.Temperature;
|
|||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.core.i18n.TimeZoneProvider;
|
|
||||||
import org.openhab.core.library.types.DateTimeType;
|
import org.openhab.core.library.types.DateTimeType;
|
||||||
import org.openhab.core.library.types.DecimalType;
|
import org.openhab.core.library.types.DecimalType;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
@ -83,9 +81,8 @@ public final class WolfSmartsetUtils {
|
|||||||
return value == null ? UnDefType.UNDEF : new PointType(value);
|
return value == null ? UnDefType.UNDEF : new PointType(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static State undefOrDate(@Nullable Date date, TimeZoneProvider timeZoneProvider) {
|
public static State undefOrDate(@Nullable Date date) {
|
||||||
return date == null ? UnDefType.UNDEF
|
return date == null ? UnDefType.UNDEF : new DateTimeType(date.toInstant());
|
||||||
: new DateTimeType(ZonedDateTime.ofInstant(date.toInstant(), timeZoneProvider.getTimeZone()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isUnknown(Number value) {
|
private static boolean isUnknown(Number value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user