Salü
Da das Schweizer Wetter mit keiner sinnvollen Integration vertreten ist und mir die original Wetterkarte einfach zu wenig Stati bietet, hab ich mich mal rangesetzt und ein wenig selbst Hand angelegt. SwissMeteo kennt 42 Stati von Wetterzuständen, mit Meteocons von Bas Milius hier bin ich aber schon nah dran
Basis der Daten sind die nicht ganz offiziellen APIs von Swiss Meteo und des AlertSwiss Systems, man kommt ran mit ein bisschen Reverseengineering der Android-Apps
Das ganze lass ich über eine kleine REST-API aufwerten die in einem Powershell Docker Container läuft. Da war für mich wesentlich einfacher als mir jetzt noch Python anzutun plus dem Gebastel was man machen muss (HACS Addons etc) um alles aus Python rausholen zu können.
Ergebnis:
Leider kann die Apex-Card noch keine Range-Area, dann bräuchte es die gestrichelten Linien nicht
Original
Die Vorhersage
Das Original
Unwetterwarnungen können detailliert angeschaut werden
Ich werde noch eine Alarmierung bei Stufe 4 Ereignisse einbauen
Da es keine AlertSwiss Meldungen in ZH hat, hab ich mir mal eine aus Basel-Landschaft geborgt
Wenn es mit erträglichen Aufwand möglich ist Polygone in die Map zu zeichnen folgt noch die Map der Gegend.
Die ganzen Cards bestehen in der Regel aus einer Markdown-Card mit HTML/CSS frisiert und der Apex-Chart Card. Ein paar kleine Details sind aber noch zu machen.
Der Rest-Sensor (fürs Wetter)
- platform: rest
name: WeatherDatafrom0000XXXV2
unique_id: weatherdatafrom0000xxxV2
json_attributes_path: $..
scan_interval: 120
json_attributes:
- Current
- forecast
- Condition
- Icon
- GraphIcons3h
- GraphwindDirection3h
- GraphwindSpeed3h
- GraphtemperatureMin1h
- GraphtemperatureMean1h
- GraphtemperatureMax1h
- GraphprecipitationMax1h
resource: http://192.168.xxx.1:1080/api/swissmeteov2/0000/00/XXX
value_template: "{{ value_json.Condition }}"
icon: mdi:weather-sunny
das Powershell was alles aufhübscht und das per Rest zur Verfügung stellt
Function Get-SwissMeteoDataV2()
{
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)]
[String]$PLZ,
[Parameter(Mandatory=$true)]
[String]$PLZZusatz,
[Parameter(Mandatory=$true)]
[String]$StationCode
)
# PLZ und Zusatz -> https://www.geoportal.ch/ch/map/1503
$JSONBase = @{}
$WeatherIconList = New-Object System.Collections.ArrayList
$WeatherIconList.Add(@{"1"="clear-day";}) | Out-Null
$WeatherIconList.Add(@{"2"="partly-cloudy-day";"3"="partly-cloudy-day";}) | Out-Null
$WeatherIconList.Add(@{"4"="overcast-day"}) | Out-Null
$WeatherIconList.Add(@{"5"="extreme";}) | Out-Null
$WeatherIconList.Add(@{"6"="extreme-day-drizzle";}) | Out-Null
$WeatherIconList.Add(@{"7"="extreme-day-sleet";"10"="extreme-day-sleet";}) | Out-Null
$WeatherIconList.Add(@{"8"="extreme-day-snow";"11"="extreme-day-snow";}) | Out-Null
$WeatherIconList.Add(@{"9"="extreme-day-rain";}) | Out-Null
$WeatherIconList.Add(@{"12"="thunderstorms-day";}) | Out-Null
$WeatherIconList.Add(@{"13"="thunderstorms-day-extreme-rain";}) | Out-Null
$WeatherIconList.Add(@{"14"="extreme-drizzle";}) | Out-Null
$WeatherIconList.Add(@{"15"="extreme-sleet";"18"="extreme-sleet";"21"="extreme-sleet";}) | Out-Null
$WeatherIconList.Add(@{"16"="extreme-snow";"19"="extreme-snow";"22"="extreme-snow";}) | Out-Null
$WeatherIconList.Add(@{"17"="extreme-rain";"20"="extreme-rain";}) | Out-Null
$WeatherIconList.Add(@{"23"="thunderstorms-extreme-rain";"24"="thunderstorms-extreme-rain";"25"="thunderstorms-extreme-rain";}) | Out-Null
$WeatherIconList.Add(@{"26"="dust-day";}) | Out-Null
$WeatherIconList.Add(@{"27"="fog-day";}) | Out-Null
$WeatherIconList.Add(@{"28"="mist";}) | Out-Null
$WeatherIconList.Add(@{"29"="partly-cloudy-day-drizzle";}) | Out-Null
$WeatherIconList.Add(@{"30"="partly-cloudy-day-snow";}) | Out-Null
$WeatherIconList.Add(@{"31"="partly-cloudy-day-sleet";"34"="partly-cloudy-day-sleet";}) | Out-Null
$WeatherIconList.Add(@{"32"="partly-cloudy-day-rain";"33"="partly-cloudy-day-rain";}) | Out-Null
$WeatherIconList.Add(@{"35"="overcast";}) | Out-Null
$WeatherIconList.Add(@{"36"="thunderstorms-day-rain";}) | Out-Null
$WeatherIconList.Add(@{"37"="thunderstorms-day-snow";}) | Out-Null
$WeatherIconList.Add(@{"38"="thunderstorms-day-overcast-rain";}) | Out-Null
$WeatherIconList.Add(@{"39"="thunderstorms-day-overcast-snow";}) | Out-Null
$WeatherIconList.Add(@{"40"="thunderstorms-extreme";}) | Out-Null
$WeatherIconList.Add(@{"41"="thunderstorms-day-overcast";}) | Out-Null
$WeatherIconList.Add(@{"42"="thunderstorms-extreme-snow";}) | Out-Null
$WeatherIconList.Add(@{"101"="clear-night";}) | Out-Null
$WeatherIconList.Add(@{"102"="partly-cloudy-night";"103"="partly-cloudy-night";}) | Out-Null
$WeatherIconList.Add(@{"104"="overcast-night"}) | Out-Null
$WeatherIconList.Add(@{"105"="extreme";}) | Out-Null
$WeatherIconList.Add(@{"106"="extreme-night-drizzle";}) | Out-Null
$WeatherIconList.Add(@{"107"="extreme-night-sleet";"110"="extreme-night-sleet";}) | Out-Null
$WeatherIconList.Add(@{"108"="extreme-night-snow";"111"="extreme-night-snow";}) | Out-Null
$WeatherIconList.Add(@{"109"="extreme-night-rain";}) | Out-Null
$WeatherIconList.Add(@{"112"="thunderstorms-night";}) | Out-Null
$WeatherIconList.Add(@{"113"="thunderstorms-night-extreme-rain";}) | Out-Null
$WeatherIconList.Add(@{"114"="extreme-drizzle";}) | Out-Null
$WeatherIconList.Add(@{"115"="extreme-sleet";"118"="extreme-sleet";"121"="extreme-sleet";}) | Out-Null
$WeatherIconList.Add(@{"116"="extreme-snow";"119"="extreme-snow";"122"="extreme-snow";}) | Out-Null
$WeatherIconList.Add(@{"117"="extreme-rain";"120"="extreme-rain";}) | Out-Null
$WeatherIconList.Add(@{"123"="thunderstorms-extreme-rain";"124"="thunderstorms-extreme-rain";"125"="thunderstorms-extreme-rain";}) | Out-Null
$WeatherIconList.Add(@{"126"="dust-night";}) | Out-Null
$WeatherIconList.Add(@{"127"="fog-night";}) | Out-Null
$WeatherIconList.Add(@{"128"="mist";}) | Out-Null
$WeatherIconList.Add(@{"129"="partly-cloudy-night-drizzle";}) | Out-Null
$WeatherIconList.Add(@{"130"="partly-cloudy-night-snow";}) | Out-Null
$WeatherIconList.Add(@{"131"="partly-cloudy-night-sleet";"134"="partly-cloudy-night-sleet";}) | Out-Null
$WeatherIconList.Add(@{"132"="partly-cloudy-night-rain";"133"="partly-cloudy-night-rain";}) | Out-Null
$WeatherIconList.Add(@{"135"="overcast";}) | Out-Null
$WeatherIconList.Add(@{"136"="thunderstorms-night-rain";}) | Out-Null
$WeatherIconList.Add(@{"137"="thunderstorms-night-snow";}) | Out-Null
$WeatherIconList.Add(@{"138"="thunderstorms-night-overcast-rain";}) | Out-Null
$WeatherIconList.Add(@{"139"="thunderstorms-night-overcast-snow";}) | Out-Null
$WeatherIconList.Add(@{"140"="thunderstorms-extreme";}) | Out-Null
$WeatherIconList.Add(@{"141"="thunderstorms-day-overcast";}) | Out-Null
$WeatherIconList.Add(@{"142"="thunderstorms-extreme-snow";}) | Out-Null
$WeatherDescList = New-Object System.Collections.ArrayList
$WeatherDescList.Add(@{"1"="sunnig";}) | Out-Null
$WeatherDescList.Add(@{"2"="liecht bewölkt";"102"="liecht bewölkt";}) | Out-Null
$WeatherDescList.Add(@{"3"="wulkig";"103"="wulkig";}) | Out-Null
$WeatherDescList.Add(@{"4"="wechselend bewölkt";"104"="wechselend bewölkt";}) | Out-Null
$WeatherDescList.Add(@{"5"="bedeckt";"105"="bedeckt";}) | Out-Null
$WeatherDescList.Add(@{"6"="teilwiis sunnig mit einzelne Rägeschüüre";}) | Out-Null
$WeatherDescList.Add(@{"7"="teilwiis sunnig mit einzelne Räge- oder Schneeschuure";}) | Out-Null
$WeatherDescList.Add(@{"8"="teilwiis sunnig mit einzelne Schneeschuure";}) | Out-Null
$WeatherDescList.Add(@{"9"="bewölkt mit einige Rägeschüüre";"109"="bewölkt mit einige Rägeschüüre";}) | Out-Null
$WeatherDescList.Add(@{"10"="bewölkt mit einige Räge- oder Schneeschuure";"110"="bewölkt mit einige Räge- oder Schneeschuure";}) | Out-Null
$WeatherDescList.Add(@{"11"="bewölkt mit einige Schneeschuure";"111"="bewölkt mit einige Schneeschuure";}) | Out-Null
$WeatherDescList.Add(@{"12"="teilwiis sunnig und liecht gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"13"="teilwiis sunnig und gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"14"="stark bewölkt und schwacher Räge";"114"="stark bewölkt und schwacher Räge";}) | Out-Null
$WeatherDescList.Add(@{"15"="stark bewölkt und schwache Schneerge";"115"="stark bewölkt und schwache Schneerge";}) | Out-Null
$WeatherDescList.Add(@{"16"="stark bewölkt und schwacher Schnee";"116"="stark bewölkt und schwacher Schnee";}) | Out-Null
$WeatherDescList.Add(@{"17"="stark bewölkt und zitwiis Räge";"117"="stark bewölkt und zitwiis Räge";}) | Out-Null
$WeatherDescList.Add(@{"18"="stark bewölkt und zitwiis Schneerge";"118"="stark bewölkt und zitwiis Schneerge";}) | Out-Null
$WeatherDescList.Add(@{"19"="stark bewölkt und zitwiis Schnee";"119"="stark bewölkt und zitwiis schnee";}) | Out-Null
$WeatherDescList.Add(@{"20"="stark bewölkt und anhaltender Räge";"120"="stark bewölkt und anhaltender Räge";}) | Out-Null
$WeatherDescList.Add(@{"21"="stark bewölkt und anhaltender Schneerge";"121"="stark bewölkt und anhaltender Schneerge";}) | Out-Null
$WeatherDescList.Add(@{"22"="stark bewölkt und anhaltender Schnee";"122"="stark bewölkt und anhaltender Schnee";}) | Out-Null
$WeatherDescList.Add(@{"23"="stark bewölkt und liecht gwitterhaft";"123"="stark bewölkt und liecht gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"24"="stark bewölkt und gwitterhaft";"124"="stark bewölkt und gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"25"="stark bewölkt und starch gwitterhaft";"125"="stark bewölkt und starch gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"26"="Höchi Bewölkig oder Dunscht";"126"="Höchi Bewölkig oder Dunscht";}) | Out-Null
$WeatherDescList.Add(@{"27"="Hochnebel";"127"="Hochnebel";}) | Out-Null
$WeatherDescList.Add(@{"28"="Nebel";"128"="Nebel";}) | Out-Null
$WeatherDescList.Add(@{"29"="liecht bewölkt mit einzelne Rägeschüüre";"129"="liecht bewölkt mit einzelne Rägeschüüre";}) | Out-Null
$WeatherDescList.Add(@{"30"="liecht bewölkt und liechter Schneefall";"130"="liecht bewölkt und liechter schneefall";}) | Out-Null
$WeatherDescList.Add(@{"31"="teilwiis sunnig mit einige Schnee- oder Rägeschüüre";}) | Out-Null
$WeatherDescList.Add(@{"32"="teilwiis sunnig mit einige Rägeschuure";}) | Out-Null
$WeatherDescList.Add(@{"33"="bewölkt mit hüüfige Rägeschüüre";"133"="bewölkt mit hüüfige Rägeschüüre";}) | Out-Null
$WeatherDescList.Add(@{"34"="bewölkt mit hüüfige Schneeschuure";"134"="bewölkt mit hüüfige Schneeschuure";}) | Out-Null
$WeatherDescList.Add(@{"35"="bedeckt und troche";"135"="bedeckt und troche";}) | Out-Null
$WeatherDescList.Add(@{"36"="teilwiis sunnig und gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"37"="teilwiis sunnig mit gwitter und Schneeschuure";}) | Out-Null
$WeatherDescList.Add(@{"38"="bewölkt mit Gwitter und hüfigi Rägeschüüre";"138"="bewölkt mit Gwitter und hüfigi Rägeschüüre";}) | Out-Null
$WeatherDescList.Add(@{"39"="bewölkt mit Gwitter und hüfigi Schneeschuure";"139"="bewölkt mit Gwitter und hüfigi Schneeschuure";}) | Out-Null
$WeatherDescList.Add(@{"40"="stark bewölkt und liecht gwitterhaft";"140"="stark bewölkt und liecht gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"41"="bewölkt und liecht gwitterhaft";"141"="bewölkt und liecht gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"42"="stark bewölkt mit Gwitter und hüüfige Schneeschuure";"142"="stark bewölkt mit Gwitter und hüüfige Schneeschuure";}) | Out-Null
$WeatherDescList.Add(@{"101"="klar";}) | Out-Null
$WeatherDescList.Add(@{"106"="teilwiis klar mit einzelne Rägeschüüre";}) | Out-Null
$WeatherDescList.Add(@{"107"="teilwiis klar mit einzelne Räge- oder Schneeschuure";}) | Out-Null
$WeatherDescList.Add(@{"108"="teilwiis klar mit einzelne Schneeschuure";}) | Out-Null
$WeatherDescList.Add(@{"112"="teilwiis klar und liecht gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"113"="teilwiis klar und gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"131"="teilwiis klar mit einige Schnee- oder Rägeschüüre";}) | Out-Null
$WeatherDescList.Add(@{"132"="teilwiis klar mit einige Rägeschüüre";}) | Out-Null
$WeatherDescList.Add(@{"136"="teilwiis klar und gwitterhaft";}) | Out-Null
$WeatherDescList.Add(@{"137"="teilwiis klar mit gwitter und Schneeschuure";}) | Out-Null
$WebClient = New-Object System.Net.WebClient
$WebClient.Encoding = [System.Text.Encoding]::UTF8
$WebClient.Headers.Add("Accept-Language", "de-de,de;q=0.8,en-us;q=0.5,en;q=0.3")
$WeatherCurrent = ($WebClient.DownloadString("https://app-prod-ws.meteoswiss-app.ch/v1/currentweather?ws=$($StationCode)") | ConvertFrom-Json)
$WeatherForecast = ($WebClient.DownloadString("https://app-prod-ws.meteoswiss-app.ch/v2/plzDetail?plz=$($PLZ)$($PLZZusatz)") | ConvertFrom-Json)
$JSONForecast = New-Object System.Collections.ArrayList
foreach($Forecast in ($WeatherForecast.forecast))
{
$JSONForecast.Add(@{"datetime"=$($Forecast.dayDate);"condition"=$($WeatherDescList.values.item($([int]$WeatherDescList.keys.IndexOf("$($Forecast.iconDay)"))));"icon"=$($WeatherIconList.values.item($([int]$WeatherIconList.keys.IndexOf("$($Forecast.iconDay)"))));"temperature"=$($Forecast.temperatureMax);"templow"=$($Forecast.temperatureMin);"precipitation_probability"=$($Forecast.precipitation);}) | Out-Null
}
$GraphIcons = New-Object System.Collections.ArrayList
$TodayIconMidNight = [DateTime]("$(Get-Date -Format 'yyyy-MM-dd') 00:00:00")
foreach($Graph in ($WeatherForecast.graph.weatherIcon3hV2))
{
$GraphIcons.Add(@{"datetime"="$(Get-Date $TodayIconMidNight -Format 'yyyy')-$(Get-Date $TodayIconMidNight -Format 'MM')-$(Get-Date $TodayIconMidNight -Format 'dd') $(Get-Date $TodayIconMidNight -Format 'HH'):00:00";"icon"=$($WeatherIconList.values.item($([int]$WeatherIconList.keys.IndexOf("$($Graph)"))));}) | Out-Null
$TodayIconMidNight = $TodayIconMidNight.AddHours(3)
}
$GraphTemperatureMin = New-Object System.Collections.ArrayList
$TodayTempMidNight = [DateTime]("$(Get-Date -Format 'yyyy-MM-dd') 00:00:00")
foreach($Graph in ($WeatherForecast.graph.temperatureMin1h))
{
$GraphTemperatureMin.Add(@{"datetime"="$(Get-Date $TodayTempMidNight -Format 'yyyy')-$(Get-Date $TodayTempMidNight -Format 'MM')-$(Get-Date $TodayTempMidNight -Format 'dd') $(Get-Date $TodayTempMidNight -Format 'HH'):00:00";"temp"=$Graph;}) | Out-Null
$TodayTempMidNight = $TodayTempMidNight.AddHours(1)
}
$GraphTemperatureMean = New-Object System.Collections.ArrayList
$TodayTempMidNight = [DateTime]("$(Get-Date -Format 'yyyy-MM-dd') 00:00:00")
foreach($Graph in ($WeatherForecast.graph.temperatureMean1h))
{
$GraphTemperatureMean.Add(@{"datetime"="$(Get-Date $TodayTempMidNight -Format 'yyyy')-$(Get-Date $TodayTempMidNight -Format 'MM')-$(Get-Date $TodayTempMidNight -Format 'dd') $(Get-Date $TodayTempMidNight -Format 'HH'):00:00";"temp"=$Graph;}) | Out-Null
$TodayTempMidNight = $TodayTempMidNight.AddHours(1)
}
$GraphTemperatureMax = New-Object System.Collections.ArrayList
$TodayTempMidNight = [DateTime]("$(Get-Date -Format 'yyyy-MM-dd') 00:00:00")
foreach($Graph in ($WeatherForecast.graph.temperatureMax1h))
{
$GraphTemperatureMax.Add(@{"datetime"="$(Get-Date $TodayTempMidNight -Format 'yyyy')-$(Get-Date $TodayTempMidNight -Format 'MM')-$(Get-Date $TodayTempMidNight -Format 'dd') $(Get-Date $TodayTempMidNight -Format 'HH'):00:00";"temp"=$Graph;}) | Out-Null
$TodayTempMidNight = $TodayTempMidNight.AddHours(1)
}
$GraphPrecipitation = New-Object System.Collections.ArrayList
$TodayPrecMidNight = [DateTime]("$((Get-Date -Format 'yyyy-MM-dd')) 00:00:00")
foreach($Graph in ($WeatherForecast.graph.precipitationMax10m))
{
$GraphPrecipitation.Add(@{"datetime"="$(Get-Date $TodayPrecMidNight -Format 'yyyy')-$(Get-Date $TodayPrecMidNight -Format 'MM')-$(Get-Date $TodayPrecMidNight -Format 'dd') $(Get-Date $TodayPrecMidNight -Format 'HH'):$(Get-Date $TodayPrecMidNight -Format 'mm'):00";"precipitation"=$Graph;}) | Out-Null
$TodayPrecMidNight = $TodayPrecMidNight.AddMinutes(10)
}
$TodayPrecMidNight = [DateTime]("$(Get-Date $TodayPrecMidNight -Format 'yyyy')-$(Get-Date $TodayPrecMidNight -Format 'MM')-$(Get-Date $TodayPrecMidNight -Format 'dd') $(Get-Date $TodayPrecMidNight -Format 'HH'):00:00")
$TodayPrecMidNight = $TodayPrecMidNight.AddHours(1)
foreach($Graph in ($WeatherForecast.graph.precipitationMax1h))
{
$GraphPrecipitation.Add(@{"datetime"="$(Get-Date $TodayPrecMidNight -Format 'yyyy')-$(Get-Date $TodayPrecMidNight -Format 'MM')-$(Get-Date $TodayPrecMidNight -Format 'dd') $(Get-Date $TodayPrecMidNight -Format 'HH'):00:00";"precipitation"=$Graph;}) | Out-Null
$TodayPrecMidNight = $TodayPrecMidNight.AddHours(1)
}
$GraphWindDirection = New-Object System.Collections.ArrayList
$TodayWDMidNight = [DateTime]("$(Get-Date -Format 'yyyy-MM-dd') 00:00:00")
foreach($Graph in ($WeatherForecast.graph.windDirection3h))
{
$GraphWindDirection.Add(@{"datetime"="$(Get-Date $TodayWDMidNight -Format 'yyyy')-$(Get-Date $TodayWDMidNight -Format 'MM')-$(Get-Date $TodayWDMidNight -Format 'dd') $(Get-Date $TodayWDMidNight -Format 'HH'):00:00";"direction"=$Graph;}) | Out-Null
$TodayWDMidNight = $TodayWDMidNight.AddHours(3)
}
$GraphWindSpeed = New-Object System.Collections.ArrayList
$TodayWSMidNight = [DateTime]("$(Get-Date -Format 'yyyy-MM-dd') 00:00:00")
foreach($Graph in ($WeatherForecast.graph.windSpeed3h))
{
$GraphWindSpeed.Add(@{"datetime"="$(Get-Date $TodayWSMidNight -Format 'yyyy')-$(Get-Date $TodayWSMidNight -Format 'MM')-$(Get-Date $TodayWSMidNight -Format 'dd') $(Get-Date $TodayWSMidNight -Format 'HH'):00:00";"speed"=$Graph;}) | Out-Null
$TodayWSMidNight = $TodayWSMidNight.AddHours(3)
}
$JSONBase.Add("Condition", $WeatherDescList.values.item($([int]$WeatherDescList.keys.IndexOf("$($WeatherForecast.currentWeather.icon)"))))
$JSONBase.Add("Icon", $WeatherIconList.values.item($([int]$WeatherIconList.keys.IndexOf("$($WeatherForecast.currentWeather.icon)"))))
$JSONBase.Add("GraphtemperatureMin1h", $GraphTemperatureMin)
$JSONBase.Add("GraphtemperatureMean1h", $GraphTemperatureMean)
$JSONBase.Add("GraphtemperatureMax1h", $GraphTemperatureMax)
$JSONBase.Add("GraphprecipitationMax1h", $GraphPrecipitation)
$JSONBase.Add("GraphwindSpeed3h", $GraphWindSpeed)
$JSONBase.Add("GraphwindDirection3h", $GraphWindDirection)
$JSONBase.Add("GraphIcons3h", $GraphIcons)
$JSONBase.Add("Current", $WeatherCurrent)
$JSONBase.Add("forecast", $JSONForecast)
Return $JSONBase | ConvertTo-Json -Depth 10
}