From f15aec8e2d2da5669036d87520ddbafbc7fc74df Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 16 Apr 2025 00:59:27 -0400 Subject: [PATCH] Fix log spam when wife's work schedule is not in the calendar --- time-based/work-tomorrow.js | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/time-based/work-tomorrow.js b/time-based/work-tomorrow.js index 7b6e314..82625da 100644 --- a/time-based/work-tomorrow.js +++ b/time-based/work-tomorrow.js @@ -3,16 +3,34 @@ let today = msg.today let number = {} let work_tomorrow = {} -if (tomorrow > 0) { - work_tomorrow = "true" - if (today == 0) { - number = 0 - } else { - number = 1 - } -} else { +// Check if calendar data exists +if (!msg.payload || msg.payload.length === 0) { + msg.payload = [{ + date: "No Data", + eventStart: "No Data", + eventEnd: "No Data", + summary: "No Data", + location: "No Data", + isRecurring: "No Data", + allDay: "No Data", + calendarName: "No Data", + countdown: "No Data", + uid: { date: "No Data" } + }] work_tomorrow = "false" number = 0 +} else { + if (tomorrow > 0) { + work_tomorrow = "true" + if (today == 0) { + number = 0 + } else { + number = 1 + } + } else { + work_tomorrow = "false" + number = 0 + } } msg.work_tomorrow = work_tomorrow