PowerShell/scripts/list-nina-warnings.ps1

49 lines
1.6 KiB
PowerShell
Raw Normal View History

2023-10-31 12:33:36 +01:00
<#
2023-10-30 14:04:09 +01:00
.SYNOPSIS
2024-06-26 08:39:06 +02:00
Lists the current NINA warnings
2023-10-30 14:04:09 +01:00
.DESCRIPTION
2024-06-26 08:39:06 +02:00
This PowerShell script queries the current NINA warnings and lists it.
2023-10-30 14:04:09 +01:00
.EXAMPLE
PS> ./list-nina-warnings.ps1
2024-06-26 08:39:06 +02:00
Official SEVERE WEATHER WARNING of SEVERE THUNDERSTORMS with VERY HEAVY RAIN and HAIL
🕘 2024-06-26T07:53:00+02:00 ... 2024-06-26T08:45:00+02:00 (by DWD, Update, Severe, Immediate)
2023-10-30 14:04:09 +01:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
2024-06-26 08:39:06 +02:00
function ListWarningsOf([string]$source, [string]$URL)
2024-05-14 16:51:44 +02:00
{
2024-06-26 08:39:06 +02:00
Write-Progress "Loading NINA - $source warnings..."
$warnings = (Invoke-WebRequest -URI $URL -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
2023-10-30 14:04:09 +01:00
Write-Progress -completed "Done."
2024-05-14 16:51:44 +02:00
2023-10-30 14:04:09 +01:00
foreach($warning in $warnings) {
2024-06-26 08:39:06 +02:00
$title = $warning.i18nTitle.en
if ("$title" -eq "") { $title = $warning.i18nTitle.de }
2023-10-30 14:04:09 +01:00
$startDate = $warning.startDate
$expiresDate = $warning.expiresDate
$severity = $warning.severity
$urgency = $warning.urgency
$type = $warning.type
2024-06-26 08:39:06 +02:00
Write-Output "⚠️ $title"
Write-Output " 🕘 $($startDate)...$expiresDate (by $source, $type, $severity, $urgency)"
2024-05-14 16:51:44 +02:00
Write-Output ""
2023-10-30 14:04:09 +01:00
}
2024-05-14 16:51:44 +02:00
}
try {
Write-Output ""
2024-06-26 08:39:06 +02:00
ListWarningsOf "Katwarn" "https://warnung.bund.de/api31/katwarn/mapData.json"
ListWarningsOf "DWD" "https://warnung.bund.de/api31/dwd/mapData.json"
ListWarningsOf "Police" "https://warnung.bund.de/api31/police/mapData.json"
ListWarningsOf "LHP" "https://warnung.bund.de/api31/lhp/mapData.json"
ListWarningsOf "Biwapp" "https://warnung.bund.de/api31/biwapp/mapData.json"
2023-10-30 14:04:09 +01:00
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}