Fix alert not popping up, SUNSET_TIME is not used in API route.

This commit is contained in:
me committed 2026-11-02 20:56:35 -07:00
1 parent 949e1baacd
commit 28c0f61696
1 file changed
+4 -5
+4 -5
View File
@@ -165,8 +165,7 @@ while true; do
CURRENT_TIME=$(date +%s) CURRENT_TIME=$(date +%s)
# Check if we need to fetch new sunset time for a new day. # Check if we need to fetch new sunset time for a new day.
if [[ "$LAST_DATE" != "$TODAY" \ if [[ "$LAST_DATE" != "$TODAY" || "$SUNSET_EPOCH" == 0 ]]
|| "$SUNSET_EPOCH" == 0 || -z "$SUNSET_TIME" ]]
then then
LAST_DATE="$TODAY" LAST_DATE="$TODAY"
@@ -184,7 +183,7 @@ while true; do
continue continue
} }
if [[ -z "$SUNSET_TIME" ]]; then if [[ "$SUNSET_EPOCH" == 0 ]]; then
echo "ERROR: Sunset time is still null. Retrying in 5 minutes." >&2 echo "ERROR: Sunset time is still null. Retrying in 5 minutes." >&2
sleep 300 sleep 300
continue continue
@@ -208,11 +207,11 @@ while true; do
MIDNIGHT=$(date -d "${TODAY} +1 day" +%s) MIDNIGHT=$(date -d "${TODAY} +1 day" +%s)
# Alert while current time is within the window (from window start until midnight). # Alert while current time is within the window (from window start until midnight).
if [[ -n "$SUNSET_TIME" && "$SUNSET_EPOCH" -ge 0 \ if [[ "$SUNSET_EPOCH" -ge 0 \
&& "$CURRENT_TIME" -ge "$ALERT_WINDOW_START" \ && "$CURRENT_TIME" -ge "$ALERT_WINDOW_START" \
&& "$CURRENT_TIME" -lt "$MIDNIGHT" ]] && "$CURRENT_TIME" -lt "$MIDNIGHT" ]]
then then
echo "Alert time has been reached for $SUNSET_TIME, show message." echo "Alert time has been reached, show message."
show_alert show_alert
echo "Alert has been dismissed, sleeping for 5 minutes." echo "Alert has been dismissed, sleeping for 5 minutes."
sleep 290 sleep 290