Simplify DateTimeType handling for OJElectronics

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2024-11-17 21:46:54 +01:00 committed by lsiepel
parent e60fc3e40c
commit b23cb757c4

View File

@ -212,7 +212,7 @@ public class ThermostatHandler extends BaseThingHandler {
private void updateBoostEndTime(Command command) {
if (command instanceof DateTimeType dateTimeCommand) {
getCurrentThermostat().boostEndTime = Date.from(dateTimeCommand.getZonedDateTime().toInstant());
getCurrentThermostat().boostEndTime = Date.from(dateTimeCommand.getInstant());
} else {
logger.warn("Unable to set value {}", command);
}
@ -225,8 +225,7 @@ public class ThermostatHandler extends BaseThingHandler {
private void updateComfortEndTime(Command command) {
if (command instanceof DateTimeType dateTimeCommand) {
getCurrentThermostat().comfortEndTime = Objects
.requireNonNull(Date.from(dateTimeCommand.getZonedDateTime().toInstant()));
getCurrentThermostat().comfortEndTime = Objects.requireNonNull(Date.from(dateTimeCommand.getInstant()));
} else {
logger.warn("Unable to set value {}", command);
}
@ -329,7 +328,7 @@ public class ThermostatHandler extends BaseThingHandler {
private void updateVacationBeginDay(Command command) {
if (command instanceof DateTimeType dateTimeCommand) {
getCurrentThermostat().vacationBeginDay = Date
.from(dateTimeCommand.getZonedDateTime().toInstant().truncatedTo(ChronoUnit.DAYS));
.from(dateTimeCommand.getInstant().truncatedTo(ChronoUnit.DAYS));
} else {
logger.warn("Unable to set value {}", command);
}
@ -345,7 +344,7 @@ public class ThermostatHandler extends BaseThingHandler {
private void updateVacationEndDay(Command command) {
if (command instanceof DateTimeType dateTimeCommand) {
getCurrentThermostat().vacationEndDay = Date
.from(dateTimeCommand.getZonedDateTime().toInstant().truncatedTo(ChronoUnit.DAYS));
.from(dateTimeCommand.getInstant().truncatedTo(ChronoUnit.DAYS));
} else {
logger.warn("Unable to set value {}", command);
}