Rain Warning Sensor with Home Assistant

Rain Warning Sensor with Home Assistant
Home Assistant weather station

Disclaimer: This is only useful for people living in Germany. But you might get inspiration from this post to build this yourself. Let's go.

So the other day I stumbled across a competition from the German Make magazine about automation and found a guy who did build a lamp that will go blue when it will rain the next 30 to 120 minutes.

He is using the data from the German meteorological service. Problem is that the dataset is not trivial and therefore he conveniently wrote a service we can use to get a simple JSON: https://morgenwirdes.de/

Thanks to this service we will not create a DDOS to the German meteorological service servers. The downloaded data would be 1GB per person per day. So thank you for providing us this neat service ?

Home Assistant sensor YAML

Here is the YAML which I am using to get the data into home assistant sensors:

sensor:
  - platform: rest
    name: regenradar
    scan_interval: 300
    json_attributes:
      - raintext
      - rainin30min
      - rainin60min
      - rainin120min
    resource: https://morgenwirdes.de/api/v3/rain.php?lat=X.XX&long=Y.YY
    value_template: "{{ value_json.raintext }}"
  - platform: template
    sensors:
      rrraintext:
        friendly_name: "Vorhersage"
        value_template: "{{ state_attr('sensor.regenradar', 'raintext') }}"
      rrrainin30min:
        friendly_name: "Regen in 30min"
        value_template: "{{ state_attr('sensor.regenradar', 'rainin30min') }}"
      rrrainin60min:
        friendly_name: "Regen in 60min"
        value_template: "{{ state_attr('sensor.regenradar', 'rainin60min') }}"
      rrrainin120min:
        friendly_name: "Regen in 120min"
        value_template: "{{ state_attr('sensor.regenradar', 'rainin120min') }}"

You only need to adapt the resource string with your latitude and longitude:

resource: https://morgenwirdes.de/api/v3/rain.php?lat=X.XX&long=Y.YY
Replace X.XX and Y.YY with your longitude and latitude

How to get longitude and latitude in Google Maps

You can check your longitude and latitude on Google Maps with just a right-click on your desired position:

Google maps shows longitute and latitude with a right-click
Google Maps longitude and latitude with a right-click

Add sensors to Home Assistant Dashboard

I have added an entity card to Home Assistant in order to show the values. However, you can pick whatever floats your boat.

Home Assistant entity card with the new rain sensors
Adding the new sensors to an entity card

Add a weather map to Home Assistant

If you want to have the weather radar as well you can integrate that with a picture card and add this URL:

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

You only need to supply your postal code in plz. Additionally, you can play with the other parameters delay, type, zommlvl, bar, map, textcol and bgcol to adjust the look and feel as you like.

Your weather tab could look like this:

Weather forecast and rain radar in home assistant
Home Assistant weather tab

What to do next?

I am just using this as information in a weather tab in the Home Assistant app. I do not have a lamp next to the door I can turn blue it if will rain.

You could use text to speech when the main door is opening to inform about rain or make a push notification to your phone. All sorts of things.

I am currently tinkering with an E-Ink display to display some weather data. Not too hard with ESPHome.

esp8266 with E-Ink display showing some Home Assistant sensors values
esp8266 with E-Ink display showing some Home Assistant sensors values

Need to figure out how to power this thing and build a 3D printed case. The case can be done by friends, that should not be the problem. I do not have a 3D printer yet and can outsource that ?

Cordless power is something I need to look into. Not familiar with that topic yet. Was thinking about some charge/power board with a small battery pack. Does not be that big of a battery I guess because I do not need to update the E-Ink that often. Maybe even something with wireless QI-charging. Still doing some research and learning on that topic.

If you have a good idea or a helpful resource feel free to leave me a mail or contact me on Twitter.


If you find this interesting hit subscribe and do not miss any updates on my shenanigans. Feel free to share this with your nerdy friends as well. Maybe one of them has a good idea to improve this project.

Have a great day!