As i was not happy with the data-quality of owm for my region, i decided to to try out DWD (Deutscher Wetterdienst).
A quick search ended without suitable ended with the result, that there are only bindings for warnings available, but none for forecast.
So here is my solution:
Gathering the data directly from DWD is pretty complex, despite of their open data project. Luckily there is Bright Sky (https://brightsky.dev/), who are transforming the DWD data to a json output, which could be used in a rule.
For using the rule you need to have the following bindings installed:
-
http
-
jsonpath transofrmation
the consits of two parts, generating a http string for requesting the data and transforming the data to items.
The rules-File
rule "Bright Sky"
when
Time cron "0 */30 * * * ?"
then
var String lat = "1" //set latitude
var String lon = "3.14" //set longitude
//Get Time Data
var String startDate = now().format(java.time.format.DateTimeFormatter.ofPattern("YYYY-MM-dd'T'HH'%3A'mmZ"))
var String endDate = now().plusHours(24).format(java.time.format.DateTimeFormatter.ofPattern("YYYY-MM-dd'T'HH'%3A'mmZ"))
//Generate URL
startDate = "date=" + startDate.substring(0,21)
startDate = startDate.replace("+","%2B") + "%3A00&"
endDate = "date=" + endDate.substring(0,21)
endDate = endDate.replace("+","%2B") + "%3A00&"
lat = "lat=" + lat + "&"
lon = "lon=" + lon
val String baseurl = "https://api.brightsky.dev/weather?"
val String WeatherString = sendHttpGetRequest(baseurl + startDate + endDate + lat + lon)
//Writing temperature Data for the next 14 hours into corresponding items
var Number i = 0
while (i < 15) {
var Number Forecast = Float::parseFloat(transform("JSONPATH", "$.weather[" + i + "].temperature", WeatherString))
var String DestItem = "WeatherForecast_Temp" + i
sendCommand(DestItem, Forecast.toString)
i = i + 1
}
//writing wind speed, cloud cover an precipitation for the next 3 hours in the corresponding items
i = 0
while (i < 4){
val Number Forecast1 = Float::parseFloat(transform("JSONPATH", "$.weather[" + i + "].wind_speed", WeatherString))
val String DestItem1 = "WeatherForecast_Wind" + i
sendCommand(DestItem1, Forecast1.toString)
val Number Forecast2 = Float::parseFloat(transform("JSONPATH", "$.weather[" + i + "].cloud_cover", WeatherString))
val String DestItem2 = "WeatherForecast_Clouds" + i
sendCommand(DestItem2, Forecast2.toString)
val Number Forecast3 = Float::parseFloat(transform("JSONPATH", "$.weather[" + i + "].precipitation", WeatherString))
val String DestItem3 = "WeatherForecast_Rain" + i
sendCommand(DestItem3, Forecast3.toString)
i = i + 1
}
end
with the corresponding items:
Number WeatherForecast_Temp0 "Aktuelle Temperatur [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp1 "Vorhergesagte Temperatur 1h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp2 "Vorhergesagte Temperatur 2h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp3 "Vorhergesagte Temperatur 3h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp4 "Vorhergesagte Temperatur 4h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp5 "Vorhergesagte Temperatur 5h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp6 "Vorhergesagte Temperatur 6h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp7 "Vorhergesagte Temperatur 7h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp8 "Vorhergesagte Temperatur 8h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp9 "Vorhergesagte Temperatur 9h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp10 "Vorhergesagte Temperatur 10h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp11 "Vorhergesagte Temperatur 11h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp12 "Vorhergesagte Temperatur 12h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp13 "Vorhergesagte Temperatur 13h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Temp14 "Vorhergesagte Temperatur 14h [%.1f °C]" (gWeatherForecast, gWForecast_Temp)
Number WeatherForecast_Wind0 "Aktuelle Windgeschwindigkeit [%.1f km/h]" (gWeatherForecast, gWForecast_Wind)
Number WeatherForecast_Wind1 "Vorhergesagte Windgeschwindigkeit 1h [%.1f km/h]" (gWeatherForecast, gWForecast_Wind)
Number WeatherForecast_Wind2 "Vorhergesagte Windgeschwindigkeit 2h [%.1f km/h]" (gWeatherForecast, gWForecast_Wind)
Number WeatherForecast_Wind3 "Vorhergesagte Windgeschwindigkeit 3h [%.1f km/h]" (gWeatherForecast, gWForecast_Wind)
Number WeatherForecast_Clouds0 "Aktuell Bewölkung [%.2f p]" (gWeatherForecast, gWForecast_Clouds)
Number WeatherForecast_Clouds1 "Vorhergesagte Bewölkung 1h [%.2f p]" (gWeatherForecast, gWForecast_Clouds)
Number WeatherForecast_Clouds2 "Vorhergesagte Bewölkung 2h [%.2f p]" (gWeatherForecast, gWForecast_Clouds)
Number WeatherForecast_Clouds3 "Vorhergesagte Bewölkung 3h [%.2f p]" (gWeatherForecast, gWForecast_Clouds)
the rules is asking the data for the next 24 hours and writing the temperature data for the next 14 hours, and the wind, cloudines and precipitation data for the next 3 hours in the corresponding items.
For usage you have to set your geolocation (longitude/latitude).
More datapoints are documented at the bright sky homepage.
At the moment distingusihing between summer an winter time has to be done manually with the UTCoffset variable (02 for summer, 01 for winter).
Maybe it’s useful for someone
Edit:
Update the rule for automatic switching between summer/winter time according to the idea of Matze0211.
Greets
Alex