Simplify DateTimeType handling for Helios easyControls

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2024-11-17 21:33:36 +01:00 committed by lsiepel
parent 3361aa41dd
commit 7fd9fc8554

View File

@ -324,7 +324,7 @@ public class HeliosEasyControlsHandler extends BaseThingHandler {
value = command == OnOffType.ON ? "1" : "0"; value = command == OnOffType.ON ? "1" : "0";
} else if (command instanceof DateTimeType dateTimeCommand) { } else if (command instanceof DateTimeType dateTimeCommand) {
try { try {
ZonedDateTime d = dateTimeCommand.getZonedDateTime(); ZonedDateTime d = dateTimeCommand.getZonedDateTime(ZoneId.systemDefault());
if (channelId.equals(HeliosEasyControlsBindingConstants.SYS_DATE)) { if (channelId.equals(HeliosEasyControlsBindingConstants.SYS_DATE)) {
setSysDateTime(d); setSysDateTime(d);
} else if (channelId.equals(HeliosEasyControlsBindingConstants.BYPASS_FROM)) { } else if (channelId.equals(HeliosEasyControlsBindingConstants.BYPASS_FROM)) {
@ -332,7 +332,7 @@ public class HeliosEasyControlsHandler extends BaseThingHandler {
} else if (channelId.equals(HeliosEasyControlsBindingConstants.BYPASS_TO)) { } else if (channelId.equals(HeliosEasyControlsBindingConstants.BYPASS_TO)) {
this.setBypass(false, d.getDayOfMonth(), d.getMonthValue()); this.setBypass(false, d.getDayOfMonth(), d.getMonthValue());
} else { } else {
value = formatDate(channelId, dateTimeCommand.getZonedDateTime()); value = formatDate(channelId, d);
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
logger.debug( logger.debug(
@ -534,11 +534,13 @@ public class HeliosEasyControlsHandler extends BaseThingHandler {
} }
private void updateSysDate(DateTimeType dateTime) { private void updateSysDate(DateTimeType dateTime) {
this.updateSysDateTime(dateTime.getZonedDateTime(), true, sysDate.getOffset().getTotalSeconds() / 60 / 60); this.updateSysDateTime(dateTime.getZonedDateTime(ZoneId.systemDefault()), true,
sysDate.getOffset().getTotalSeconds() / 60 / 60);
} }
private void updateSysTime(DateTimeType dateTime) { private void updateSysTime(DateTimeType dateTime) {
this.updateSysDateTime(dateTime.getZonedDateTime(), false, sysDate.getOffset().getTotalSeconds() / 60 / 60); this.updateSysDateTime(dateTime.getZonedDateTime(ZoneId.systemDefault()), false,
sysDate.getOffset().getTotalSeconds() / 60 / 60);
} }
private void updateUtcOffset(int utcOffset) { private void updateUtcOffset(int utcOffset) {