Skip to content

Commit

Permalink
Simplify DateTimeType handling for OJElectronics
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Laursen <[email protected]>
  • Loading branch information
jlaur committed Nov 17, 2024
1 parent d4173ca commit 2a79387
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private void updateBoostEndTime(ThermostatModel thermostat) {

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);
}
Expand All @@ -225,8 +225,7 @@ private void updateComfortEndTime(ThermostatModel thermostat) {

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);
}
Expand Down Expand Up @@ -329,7 +328,7 @@ private void updateVacationBeginDay(ThermostatModel thermostat) {
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);
}
Expand All @@ -345,7 +344,7 @@ private void updateVacationEndDay(ThermostatModel thermostat) {
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);
}
Expand Down

0 comments on commit 2a79387

Please sign in to comment.