Skip to contents

Main orchestrator: fetches forecasts, detects storms, and sends an email alert if gale-force winds are forecast. If no storms are detected, no email is sent. Uses the same Gmail SMTP pattern as the weekly email report.

Usage

send_storm_alert(
  threshold_knots = NULL,
  recipient = Sys.getenv("GMAIL_USERNAME"),
  sender = Sys.getenv("GMAIL_USERNAME"),
  dry_run = FALSE
)

Arguments

threshold_knots

Numeric threshold in knots (default NULL, uses env var or 34).

recipient

Email recipient (default from GMAIL_USERNAME env var).

sender

Email sender (default from GMAIL_USERNAME env var).

dry_run

Logical; if TRUE, saves HTML preview to tempdir instead of sending.

Value

List with: status ("sent", "no_storms", "preview", "error"), n_storms, stations_affected, preview_file (if dry_run), error (if failed).

Examples

if (FALSE) { # \dontrun{
# Check with very high threshold (likely no storms)
send_storm_alert(threshold_knots = 999)

# Dry run with low threshold (likely produces alert)
send_storm_alert(threshold_knots = 20, dry_run = TRUE)
} # }