DWD HTTP API (rain radar for Germany)

I wanted to show you an easy HTTP api for the “Deutsche Wetterdienst” I use with my Home Assistant. This api allows you to get a precise rain warning sensor for the next two hours (sadly, only if you live in Germany). This api does not get the Data directly from the DWD, because this would generate a really high server load for them(1GB per user per day). It gets the data form my websites server (morgenwirdes.de) that scrapes the data from the DWD and makes it available for everyone.
Here is the config to get the data with the rest sensor.

sensor:
  - platform: rest
    name: regenradar
    scan_interval: 300
    json_attributes:
      - raintext
      - rainin30min
      - rainin60min
      - rainin120min
    resource: https://morgenwirdes.de/api/v3/rain.php?lat=48.669&long=11.904
    value_template: "{{ value_json.raintext }}"
  - platform: template
    sensors:
      rrraintext:
        friendly_name: "Regentext"
        value_template: "{{ state_attr('sensor.regenradar', 'raintext') }}"
      rrrainin30min:
        friendly_name: "Regenin30min"
        value_template: "{{ state_attr('sensor.regenradar', 'rainin30min') }}"
      rrrainin60min:
        friendly_name: "Regenin60min"
        value_template: "{{ state_attr('sensor.regenradar', 'rainin60min') }}"
      rrrainin120min:
        friendly_name: "Regenin120min"
        value_template: "{{ state_attr('sensor.regenradar', 'rainin120min') }}"

This gives you 4 new sensors:

rrraintext has user readable rain information
rrrainin30min, rrrainin60min and rrrainin120min change form 0 to 1 if the will be rain in the next 30 minutes, 60 minutes and 120 minutes.

If you have ideas for more sensors, just reply to this post and i might add them.

I also have a map with the rain radar as a pre rendered GIF you can add to the Dashboard with the picture entity:

https://morgenwirdes.de/api/v3/gif4.php?plz=84051&delay=70&type=1&zoomlvl=3&bar=1&map=0&textcol=ffffff&bgcol=8393c9

you might also find more usefull DWD stuff at:

Wetter für Deine Homepage - Morgenwirdes.de API (German)

12 Likes

This is simply amazing!
Thanks very much for this. :+1:

1 Like

Really cool!
I changed the template sensor so that they match the new way of implementing:

  - trigger:
      - platform: state
        entity_id: sensor.regenradar
    sensor:
      - name: 'Regen Text'
        unique_id: '163d08cc-f861-4d3a-b109-7605702f8bcc'
        icon: 'mdi:weather-pouring'
        unit_of_measurement: ''
        state: "{{ state_attr('sensor.regenradar', 'raintext') }}"
    binary_sensor:
      - name: 'Regen in 30 min'
        unique_id: '1b7db402-d687-44ad-8b5b-aefd753e4ac7'
        icon: >
          {% if is_state_attr('sensor.regenradar', 'rainin30min', 1) %}mdi:weather-pouring
          {% else %}mdi:weather-partly-cloudy
          {% endif %}
        unit_of_measurement: ''
        state: "{{ is_state_attr('sensor.regenradar', 'rainin30min', 1) }}"
      - name: 'Regen in 60 min'
        unique_id: '0cc1087b-0ec2-41dd-b672-1625231d7c1e'
        icon: >
          {% if is_state_attr('sensor.regenradar', 'rainin60min', 1) %}mdi:weather-pouring
          {% else %}mdi:weather-partly-cloudy
          {% endif %}
        unit_of_measurement: ''
        state: "{{ is_state_attr('sensor.regenradar', 'rainin60min', 1)  }}"
      - name: 'Regen in 120 min'
        unique_id: '522013c4-bf25-48f6-ae83-e352818dc7e5'
        icon: >
          {% if is_state_attr('sensor.regenradar', 'rainin120min', 1) %}mdi:weather-pouring
          {% else %}mdi:weather-partly-cloudy
          {% endif %}
        unit_of_measurement: ''
        state: "{{ is_state_attr('sensor.regenradar', 'rainin120min', 1)  }}"
3 Likes

Can you give more insights on how you calculate the rainfall? Are you analizing the DWD radar data? If yes, how?

Yes, i use the DWD WN (Index of /weather/radar/composit/wn/) data and extract the relevant “pixel” for the given coordinates.

So I should use your version instead of @jonasn ?

Hi, the way I understand the documentation the example of @jonasn follows the legacy implementation of the template sensors. I’m currently in the process to migrate my template sensors to the new implementation, but both implementation can exist simultaniously.
With my proposed template sensor you’ll get adapting icons aswell. :wink:

1 Like

Hi and thank you! I would love a sensor for the predicted rain possibilities the next three days as separted values. Ideal would be the chance of rain as %, when it will ocure and how much rain is predicted. Any chance thats a sensor you could implement?

Or is there a better way to get a rain forcast for Germany in generall? Usecase is to get a morning notification as TTS with the weather forcast and a visual representaiton on the dashboard.

I am not sure if Jonas is actively developing his api. It is a nice solution but very buggy, I found too many inconsistencies, like message that there will be no rain in the next 2 hours but at the same time rain in next 30, 60 and 120 minutes was set to 1.

Anyways, here are my examples of what could be returned in addition:
Regen möglich ab 14 Uhr
Heute soll es trocken bleiben
Am Wochenende kann es regnen
Kein regen am Wochenende
Woche sollte trocknen bleiben

or simply date and time when the next rain is predicted:
24.12.2022 18:30

And here is the topic with very interesting morning forcast notification solution, it is not using DWD as a source but it is very accurate: Morning Weather Notification | With daily high temperature 🥺