2021-12-13 11:11:45 +01:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Checks the wind conditions
|
|
|
|
|
.DESCRIPTION
|
2022-01-29 12:47:46 +01:00
|
|
|
|
This PowerShell script determines the current wind conditions and replies by text-to-speech (TTS).
|
2021-12-13 11:11:45 +01:00
|
|
|
|
.PARAMETER location
|
|
|
|
|
Specifies the location to use (determined automatically per default)
|
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> ./check-wind
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
2022-09-06 21:42:04 +02:00
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
2021-12-13 11:11:45 +01:00
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
param([string]$location = "") # empty means determine automatically
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$Weather = (Invoke-WebRequest http://wttr.in/${location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
|
|
|
|
|
$WindSpeed = $Weather.current_condition.windspeedKmph
|
|
|
|
|
$WindDir = $Weather.current_condition.winddir16Point
|
|
|
|
|
$Area = $Weather.nearest_area.areaName.value
|
|
|
|
|
$Region = $Weather.nearest_area.region.value
|
|
|
|
|
|
|
|
|
|
& "$PSScriptRoot/give-reply.ps1" "$($WindSpeed)km/h wind from $WindDir at $Area ($Region)."
|
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
2022-04-13 12:06:32 +02:00
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2021-12-13 11:11:45 +01:00
|
|
|
|
exit 1
|
|
|
|
|
}
|