]> git.basschouten.com Git - openhab-addons.git/commitdiff
[amazonechocontrol] proper handling of null values in reminders (#9285)
authorJ-N-K <J-N-K@users.noreply.github.com>
Mon, 7 Dec 2020 23:31:32 +0000 (00:31 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Dec 2020 23:31:32 +0000 (15:31 -0800)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/EchoHandler.java

index 75b344de3935fc5660b4b4f6253657ddbb381223..5e4d26ead4311b4cf97fe6402af9e1aa8fc7a657 100644 (file)
@@ -19,6 +19,7 @@ import java.net.URISyntaxException;
 import java.time.Instant;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.concurrent.ScheduledFuture;
@@ -1278,8 +1279,11 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
                 if ("ON".equals(notification.status)) {
                     if ("Reminder".equals(notification.type)) {
                         String offset = ZoneId.systemDefault().getRules().getOffset(Instant.now()).toString();
-                        ZonedDateTime alarmTime = ZonedDateTime
-                                .parse(notification.originalDate + "T" + notification.originalTime + offset);
+                        String date = notification.originalDate != null ? notification.originalDate
+                                : ZonedDateTime.now().toLocalDate().format(DateTimeFormatter.ISO_LOCAL_DATE);
+                        String time = notification.originalTime != null ? notification.originalTime : "00:00:00";
+                        ZonedDateTime alarmTime = ZonedDateTime.parse(date + "T" + time + offset,
+                                DateTimeFormatter.ISO_DATE_TIME);
                         String recurringPattern = notification.recurringPattern;
                         if (recurringPattern != null && !recurringPattern.isBlank() && alarmTime.isBefore(now)) {
                             continue; // Ignore recurring entry if alarm time is before now