mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +01:00
Simplify DateTimeType handling for Siemens HVAC
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
96b5ad2e55
commit
7d54e604f9
@ -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());
|
||||
|
@ -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" };
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user