Martin's corner on the web

Storm cell and hail alerts in Home Assistant from RainViewer radar

A hail storm went over Sofia recently and did its usual damage – dented cars left in the open, but also flooded ground floors, smashed roof tiles and greenhouses, garden furniture, and shading damage, PV systems lightning damage. Almost all of it is preventable given twenty minutes of warning: move the car under cover, close the shutters, get the cushions in. What I wanted to know is whether hail or lightning is heading for our house or our cars, and when.

The answer is a Python script that Home Assistant runs every five minutes. RainViewer’s free API only serves radar PNG tiles, so the script fetches the tiles around a coordinate and decodes the pixels back into reflectivity – turns out the palette index minus 32 is the dBZ value. It clusters everything above 35 dBZ into storm cells, matches them across the last three frames to get a velocity vector, and extrapolates: a 45+ dBZ cell whose closest pass is within 12 km and under two hours away fires a push notification with direction and ETA; a 55+ dBZ core inside 25 km – the classic hail signature – gets its own warning. Blitzortung lightning inside 10 km stops the EV charging at the wallbox and kills any running irrigation cycle, disconnect PV DC switch.

It was built to watch moving targets as well as static ones. The car is often parked in the city, 25 km from home, where the weather can be completely different, so the same script runs on the car’s TeslaMate coordinates every ten minutes while it is away and the notification comes with a Google Maps link to the spot. The script, the palette table and both HA packages are in this gist – swap in your coordinates and notify targets. I have not had a real hail cell test it yet, so treat the thresholds as a starting point.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.