From 7d54e604f9cbc9d21d3395c4a4bbc4d4908b36db Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sun, 10 Nov 2024 21:18:09 +0100 Subject: [PATCH] Simplify DateTimeType handling for Siemens HVAC Signed-off-by: Jacob Laursen --- .../internal/converter/ConverterFactory.java | 2 +- .../internal/converter/type/DateTimeTypeConverter.java | 2 +- .../converter/type/TimeOfDayTypeConverter.java | 10 +--------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/ConverterFactory.java b/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/ConverterFactory.java index 757c8eed4cd..6500f39bf8d 100644 --- a/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/ConverterFactory.java +++ b/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/ConverterFactory.java @@ -44,7 +44,7 @@ public class ConverterFactory { registerConverter(SiemensHvacBindingConstants.DPT_TYPE_NUMERIC, new NumericTypeConverter()); registerConverter(SiemensHvacBindingConstants.DPT_TYPE_RADIO, new RadioTypeConverter()); registerConverter(SiemensHvacBindingConstants.DPT_TYPE_STRING, new StringTypeConverter()); - registerConverter(SiemensHvacBindingConstants.DPT_TYPE_TIMEOFDAY, new TimeOfDayTypeConverter(timeZoneProvider)); + registerConverter(SiemensHvacBindingConstants.DPT_TYPE_TIMEOFDAY, new TimeOfDayTypeConverter()); registerConverter(SiemensHvacBindingConstants.DPT_TYPE_CHECKBOX, new CheckboxTypeConverter()); registerConverter(SiemensHvacBindingConstants.DPT_TYPE_SCHEDULER, new SchedulerTypeConverter()); diff --git a/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/type/DateTimeTypeConverter.java b/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/type/DateTimeTypeConverter.java index 9d6ae69e365..30cf9e1a527 100644 --- a/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/type/DateTimeTypeConverter.java +++ b/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/type/DateTimeTypeConverter.java @@ -70,7 +70,7 @@ public class DateTimeTypeConverter extends AbstractTypeConverter { protected DateTimeType fromBinding(JsonElement value, String unit, String type, ChannelType tp, Locale locale) throws ConverterException { if ("----".equals(value.getAsString())) { - return new DateTimeType(ZonedDateTime.now(this.timeZoneProvider.getTimeZone())); + return new DateTimeType(); } else { String[] formats = { "EEEE, d. LLLL yyyy HH:mm[:ss]", "d. LLLL yyyy HH:mm[:ss]", "d. LLLL yyyy", "d. LLLL" }; diff --git a/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/type/TimeOfDayTypeConverter.java b/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/type/TimeOfDayTypeConverter.java index a821816daae..c287df27ea8 100644 --- a/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/type/TimeOfDayTypeConverter.java +++ b/bundles/org.openhab.binding.siemenshvac/src/main/java/org/openhab/binding/siemenshvac/internal/converter/type/TimeOfDayTypeConverter.java @@ -12,7 +12,6 @@ */ package org.openhab.binding.siemenshvac.internal.converter.type; -import java.time.ZonedDateTime; import java.util.Locale; import javax.measure.Unit; @@ -22,7 +21,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.siemenshvac.internal.converter.ConverterException; import org.openhab.binding.siemenshvac.internal.metadata.SiemensHvacMetadataDataPoint; -import org.openhab.core.i18n.TimeZoneProvider; import org.openhab.core.library.CoreItemFactory; import org.openhab.core.library.types.DateTimeType; import org.openhab.core.library.types.QuantityType; @@ -40,12 +38,6 @@ import com.google.gson.JsonElement; */ @NonNullByDefault public class TimeOfDayTypeConverter extends AbstractTypeConverter { - private final TimeZoneProvider timeZoneProvider; - - public TimeOfDayTypeConverter(final TimeZoneProvider timeZoneProvider) { - this.timeZoneProvider = timeZoneProvider; - } - @Override protected boolean toBindingValidation(Type type) { return true; @@ -71,7 +63,7 @@ public class TimeOfDayTypeConverter extends AbstractTypeConverter { protected State fromBinding(JsonElement value, String unit, String type, ChannelType tp, Locale locale) throws ConverterException { if ("----".equals(value.getAsString())) { - return new DateTimeType(ZonedDateTime.now(this.timeZoneProvider.getTimeZone())); + return new DateTimeType(); } else { if ("h:m".equals(unit)) { String st = value.getAsString();