[amazonechocontrol] proper handling of null values in reminders (#9285)

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K 2020-12-08 00:31:32 +01:00 committed by GitHub
parent 25ea32e2bf
commit 4453a04eea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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