Howto: Road Reconnaissance Report for german roads

Important: it’s only for german roads!

Hey there,
i integrated road data from the DWD (German Weather Service) into my OH2 instance. It’s important for me, because i commute a lot. Therefore, data from is retrieved every 60 minutes and parsed. The data format is a very custom one and called “SH10”, it cost me a lot of time to make the regular expression (in a rule) work.

You wanna see a SH10-example?

P912 111 10149 20149 3//// 5//// 70///
222 10206 2//// 30194 4//// 5//// 620/0=

What a beauty. The following screenshot is the more beautiful result:

I have implemented it based on a rule and the HTTP binding and REGEX transformation. Because of the complicated setup it would certainly make sense to develop a binding.

How to do it?

  1. Find the road sensors you are interested:
    Therefore, copy “Kennung” and “GDS-Verzeichnis”, for example “P808” and “FN” for the sensors in Memmingen Süd. Trivia: GDS is the name of the DWD data center, that aggregates the sensor data. In our case, it’s Freimann.

  2. Create items to retrieve the data.
    Important: Replace XX with your “GDS-Verzeichnis”

Group gWeather_DWD_SWS (gWeather)
String Weather_DWD_SWS_XX (gWeather_DWD_SWS) { http="<[*))]"}

In our case, the GDS is “FN” for DWD Freimann:

Group gWeather_DWD_SWS (gWeather)
String Weather_DWD_SWS_FN (gWeather_DWD_SWS) { http="<[*))]"}
  1. Add data items for every “Kennung” / road sensor. Items have to follow a schema: Weather_DWD_SWS_XX_KK_MeasureType. Remind: XX is your “GDS” as above, KK is your “Kennung”. The following MeasureTypes are allowed:
Number:Temperature Weather_DWD_SWS_FN_P808_TTT "Temperatur [%.1f %unit%]" <temperature> (gWeather_DWD_SWS)
Number:Temperature Weather_DWD_SWS_FN_P808_TTTd "Taupunkt [%.1f %unit%]" <temperature> (gWeather_DWD_SWS)
Number:Length Weather_DWD_SWS_FN_P808_VVVV "Sichtweite [%.0f m]" <zoom> (gWeather_DWD_SWS)
//Number:Angle            Weather_DWD_SWS_FN_P808_DD "Windrichtung [MAP(]" (gWeather_DWD_SWS)
//Number:Speed            Weather_DWD_SWS_FN_P808_FF "Windgeschwindigkeit [%.2f m/s]" (gWeather_DWD_SWS)
Number:Dimensionless    Weather_DWD_SWS_FN_P808_W "Niederschlagsart [MAP(]" <rain> (gWeather_DWD_SWS)
//Number:Dimensionless    Weather_DWD_SWS_FN_P808_RR (gWeather_DWD_SWS)
//Number:Dimensionless    Weather_DWD_SWS_FN_P808_RRK (gWeather_DWD_SWS)
Number:Temperature Weather_DWD_SWS_FN_P808_TTTb "Belagstemperatur [%.1f %unit%]" <temperature> (gWeather_DWD_SWS)
Number:Temperature Weather_DWD_SWS_FN_P808_TTTu "Untergrundtemperatur [%.1f %unit%]" <temperature> (gWeather_DWD_SWS)
Number:Length Weather_DWD_SWS_FN_P808_hh "Wasserfilmdicke [%.0f cm]" (gWeather_DWD_SWS)
Number:Dimensionless Weather_DWD_SWS_FN_P808_hhK "Wasserfilmdickeklasse [%.0f]" (gWeather_DWD_SWS)
Number:Dimensionless Weather_DWD_SWS_FN_P808_m "Hersteller [MAP(]" (gWeather_DWD_SWS)
Number:Dimensionless Weather_DWD_SWS_FN_P808_F "Funktionszustand [MAP(]" <qualityofservice> (gWeather_DWD_SWS)
Number:Dimensionless Weather_DWD_SWS_FN_P808_S "Straßenzustand [MAP(]" <qualityofservice> (gWeather_DWD_SWS)
  1. Create the rule to do the magic
import java.util.regex.Pattern
import java.util.regex.Matcher

rule "DWD Wetterupdate SWS"
    Item Weather_DWD_SWS_FN received update //changed
    // get valid stations from here:
    /*  Format Description

        P912 111 10149 20149 3//// 5//// 70///
        222 10206 2//// 30194 4//// 5//// 620/0=


    val String regexHead = "SH\\/\\/10 DWFN (\\d{10})\\s"
    val String regexData = "(?<Station>\\w\\d{3}) .*?" + 
                            "111 1(?>(?<vTTT>\\d)|\\/)(?>(?<TTT>\\d{3})|\\/\\/\\/) " +
                            "2(?>(?<vTTTd>\\d)|\\/)(?>(?<TTTd>\\d{3})|\\/\\/\\/) " +
                            "3(?>(?<VVVV>\\d{4})|\\/\\/\\/\\/) " +
                            "5(?>(?<DD>\\d{2})|\\/\\/)(?>(?<FF>\\d{2})|\\/\\/)(?>.){0,4} " + 
                            "7(?>(?<W>\\d)|\\/)(?>(?<RR>\\d{2})|\\/\\/)(?>(?<RRK>\\d)|\\/)\\s" + 
                            "\\W*222 1(?>(?<vTTTb>\\d)|\\/)(?>(?<TTTb>\\d{3})|\\/\\/\\/) " +
                            "2(?>(?<vTTTb2>\\d)|\\/)(?>(?<TTTb2>\\d{3})|\\/\\/\\/) " +
                            "3(?>(?<vTTTu>\\d)|\\/)(?>(?<TTTu>\\d{3})|\\/\\/\\/) " +
                            "4(?>(?<vTTTu2>\\d)|\\/)(?>(?<TTTu2>\\d{3})|\\/\\/\\/) " +
                            "5(?>(?<hh>\\d{2})\\/(?<hhK>\\d{1})|\\/\\/\\/\\/) " +
    val String swsResult = Weather_DWD_SWS_FN.state.toString

    var Pattern patternHead = Pattern::compile(regexHead, Pattern::MULTILINE)
	var Matcher mHead = patternHead.matcher(swsResult)
    if(mHead.find()) {
		//logInfo("[DWD_SWS]", "Found SH10 Header with Date:" +
        swsResult.replace(,"")    // remove header
        var Pattern patternData = Pattern::compile(regexData, Pattern::MULTILINE)
        var Matcher mData = patternData.matcher(swsResult)
        while(mData.find()) {
            val stationName ="Station")
            //logInfo("[DWD_SWS]", "Found SH10 Data for Station:" + stationName)
            //logInfo("[DWD_SWS]", //print complete group for debugging
            var items = gWeather_DWD_SWS.members.filter[i |]
            var i = 0
            while ((i=i+1) < items.length) {
                var item = items.get(i)
                var dwdType ="_").get(5)
                try {
                    var itemValue = Float::parseFloat(
                    if(dwdType.contains("TTT")) {
                        // Komma
                        itemValue = Float::parseFloat(,2) + "." +
                        // Vorzeichen
                        var pre = Float::parseFloat("v" + dwdType))
                        if(pre == 1)
                            itemValue = -itemValue
                    //logInfo("DWD", "Update Item " + + " " + itemValue)
                } catch(NullPointerException e) {
                    //logInfo(" ", e.toString)
  1. Prettify with maps and a sitemap

-=kein Wert
0=gesamte Messstelle in Ordnung
1=einige oder alle Luftsensoren defekt
2=einige oder alle Straßensensoren defekt 
9=Messstelle teilweise oder ganz defekt

-=kein Wert
3=SSI/Scan (MicKS) 4 Vaisala

-=kein Wert

-=kein Wert
0=kein Niederschlag
1=bei alten Anlagen: Niederschlag ja bei neuen Anlagen: Regen

Sitemap (excerpt):

Frame label="Memmingen Süd" {
    Default item=Weather_DWD_SWS_FN_P808_TTT
    Default item=Weather_DWD_SWS_FN_P808_TTTd 
    Default item=Weather_DWD_SWS_FN_P808_VVVV 
    //Default item=Weather_DWD_SWS_FN_P808_DD
    //Default item=Weather_DWD_SWS_FN_P808_FF
    Default item=Weather_DWD_SWS_FN_P808_W 
    //Default item=Weather_DWD_SWS_FN_P808_RR
    //Default item=Weather_DWD_SWS_FN_P808_RRK
    Default item=Weather_DWD_SWS_FN_P808_TTTb 
    Default item=Weather_DWD_SWS_FN_P808_TTTu 
    Default item=Weather_DWD_SWS_FN_P808_hh 
    Default item=Weather_DWD_SWS_FN_P808_hhK 
    Default item=Weather_DWD_SWS_FN_P808_m 
    Default item=Weather_DWD_SWS_FN_P808_F 
    Default item=Weather_DWD_SWS_FN_P808_S 

I commented out some MeasureTypes, as not every Kennung/road sensor delivers all data.

Hope, somebody is able to use it. I am currently working on a DWD Forecast Binding. Maybe someone can wrap everything above in another binding :wink:


EDIT: replaced rule with a better one.


Is there a map too, where i can see all positions of stations? Many stations have names without a known location for me and i can´t enter all the coordinates into google maps, to see where they are located…

The sensors are installed and supervised by the road administration of the federal states. Unfortunately, every administration offers its own documentation. For Bavaria, you can take a look at the following map layers:||

1 Like

Thanks, that helped! Now i´ve a station about 10km near my home on the road to my workplace.

Created a quick and dirty widget for visualization.

Color scheme: green = dry surface, blue = wet surface, red = slippery surface (ice, snow)

Just import from this repo and follow the instructions there:
Credits go to Yannick Schaus, who originally created the OpenStreetMap widget.

Important: in settings you are asked to provide an item. Create a Location item for yourself (use the correct naming scheme, see above). Example:

Location  Weather_DWD_SWS_FN_P808_Location     "Location [%2$s°N %3$s°E %1$sm]"

Have fun!