1
0
mirror of https://github.com/fleschutz/PowerShell.git synced 2025-05-05 16:14:42 +02:00

Update list-weather.ps1

This commit is contained in:
Markus Fleschutz 2022-11-26 12:04:48 +01:00
parent c3b3b492d4
commit 2d34c18010

View File

@ -17,22 +17,23 @@ param([string]$Location = "") # empty means determine automatically
function GetDescription { param([string]$Text) function GetDescription { param([string]$Text)
switch($Text) { switch($Text) {
"Blizzard" { return "❄️ blizzard" } "Blizzard" { return "❄️ blizzard ⚠️" }
"Clear" { return "🌙 clear " } "Clear" { return "🌙 clear" }
"Cloudy" { return "☁️ cloudy " } "Cloudy" { return "☁️ cloudy" }
"Heavy snow" { return "❄️ heavy snow" } "Fog" { return "🌫 fog" }
"Heavy snow" { return "❄️ heavy snow ⚠️" }
"Light drizzle" { return "💧 light drizzle" } "Light drizzle" { return "💧 light drizzle" }
"Light rain" { return "💧 light rain " } "Light rain" { return "💧 light rain" }
"Light rain shower" { return "💧 light rain shower" } "Light rain shower" { return "💧 light rain shower" }
"Light sleet" { return "❄️ light sleet" } "Light sleet" { return "❄️ light sleet" }
"Light snow" { return "❄️ light snow" } "Light snow" { return "❄️ light snow" }
"Moderate snow" { return "❄️ moderate snow" } "Moderate snow" { return "❄️ moderate snow" }
"Mist" { return "🌫 misty " } "Mist" { return "🌫 misty" }
"Overcast" { return "☁️ overcast " } "Overcast" { return "☁️ overcast" }
"Partly cloudy" { return "partly cloudy" } "Partly cloudy" { return "partly cloudy" }
"Patchy light rain" { return "💧 patchy light rain" } "Patchy light rain" { return "💧 patchy light rain" }
"Patchy rain possible" { return "💧 patchy rain possible" } "Patchy rain possible" { return "💧 patchy rain possible" }
"Sunny" { return "☀️ sunny " } "Sunny" { return "☀️ sunny" }
"Thundery outbreaks possible" { return "thundery outbreaks possible" } "Thundery outbreaks possible" { return "thundery outbreaks possible" }
default { return "$Text" } default { return "$Text" }
} }
@ -40,13 +41,14 @@ function GetDescription { param([string]$Text)
function GetWindDir { param([string]$Text) function GetWindDir { param([string]$Text)
switch($Text) { switch($Text) {
"NW" { return "" }
"NNW" { return "" } "NNW" { return "" }
"N" { return "" } "N" { return "" }
"NNE" { return "" } "NNE" { return "" }
"NE" { return "" } "NE" { return "" }
"ENE" { return "" } "ENE" { return "" }
"E" { return "" } "E" { return "" }
"ESE" { return "" } "ESE" { return "" }
"SE" { return "" } "SE" { return "" }
"SSE" { return "" } "SSE" { return "" }
"S" { return "" } "S" { return "" }
@ -67,19 +69,19 @@ try {
[int]$Day = 0 [int]$Day = 0
foreach($Hourly in $Weather.weather.hourly) { foreach($Hourly in $Weather.weather.hourly) {
$Hour = $Hourly.time / 100 $Hour = $Hourly.time / 100
$Temp = $Hourly.tempC $Temp = $(($Hourly.tempC.toString()).PadLeft(2))
$Precip = $Hourly.precipMM $Precip = $Hourly.precipMM
$Humidity = $Hourly.humidity $Humidity = $Hourly.humidity
$Pressure = $Hourly.pressure $Pressure = $Hourly.pressure
$WindSpeed = $Hourly.windspeedKmph $WindSpeed = $(($Hourly.windspeedKmph.toString()).PadLeft(2))
$WindDir = GetWindDir $Hourly.winddir16Point $WindDir = GetWindDir $Hourly.winddir16Point
$UV = $Hourly.uvIndex $UV = $Hourly.uvIndex
$Clouds = $Hourly.cloudcover $Clouds = $Hourly.cloudcover
$Visib = $Hourly.visibility $Visib = $(($Hourly.visibility.toString()).PadLeft(2))
$Desc = GetDescription $Hourly.weatherDesc.value $Desc = GetDescription $Hourly.weatherDesc.value
if ($Hour -eq 0) { if ($Hour -eq 0) {
if ($Day -eq 0) { if ($Day -eq 0) {
Write-Host -foregroundColor green "TODAY 🌡°C mm 💧 💨km/h UV ☁️ at $Area ($Region, $Country)" Write-Host -foregroundColor green "TODAY 🌡°C mm 💧 💨km/h ☀UV ☁️ 👁km at $Area ($Region, $Country)"
} elseif ($Day -eq 1) { } elseif ($Day -eq 1) {
Write-Host -foregroundColor green "TOMORROW" Write-Host -foregroundColor green "TOMORROW"
} else { } else {
@ -87,7 +89,7 @@ try {
} }
$Day++ $Day++
} }
"$(($Hour.toString()).PadLeft(2))°° $(($Temp.toString()).PadLeft(2))° $($Precip) $(($Humidity.toString()).PadLeft(3))% $(($WindSpeed.toString()).PadLeft(2)) $WindDir`t$($UV) $(($Clouds.toString()).PadLeft(3))% $Desc" "$(($Hour.toString()).PadLeft(2))°° $($Temp)° $($Precip) $(($Humidity.toString()).PadLeft(3))% $(($WindSpeed.toString()).PadLeft(2)) $WindDir $UV $(($Clouds.toString()).PadLeft(3))% $Visib $Desc"
$Hour++ $Hour++
} }
exit 0 # success exit 0 # success