Brent Saltzman


Interested in all things technology with a passion for analog, design, audio, and anything that sparks creativity and imagination.


Proactive Future Rain Notifications in Home Assistant with Dark Sky

I hate leaving the house and getting caught in the rain without a rain jacket. I don't check as much as I should before I leave in the morning and even if I watch my local morning news, I'll still probably forget. This is why I made this automation and it's one of my favorites.

I have a door open/close sensor on the garage entry door inside my house. Each time the door opens, Home Assistant checks to see if there's a storm under 5 miles away from me and if so, it alerts me that it might rain soon and includes a current radar loop from our local National Weather Service office.

Rain Notification

I personally prefer the Weather Underground PWS Component for all of my home automation weather needs, but the Dark Sky Component offers a few nice extra sensors that can be useful such as cloud_cover and nearest_storm_distance. The Nearest Storm Distance sensor is what I found to be most helpful in this case since it implies a storm is moving near me.

Here's what the Automation in Home Assistant looks like:

automation:  
  alias: Proactive Future Rain Notification
  trigger:
    platform: state
    entity_id: binary_sensor.ecolink_doorwindow_sensor
    to: 'on'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: cover.MyGarageDoor
        state: 'closed'
        for:
          seconds: 15
      - condition: numeric_state
        entity_id: sensor.dark_sky_nearest_storm_distance
        below: 6
  action:
    service: notify.ios_myiPhone
    data:
      message: "It might rain soon! There's a storm less than 5 miles away"
      data:
        attachment:
          url: https://radblast.wunderground.com/long/URL/To/NWS_Radar.gif
          content-type: gif
          hide-thumbnail: false

We're looking at the Nearest Storm Distance sensor as a condition so on a clear nice day the nearest storm is usually 100+ miles away so this automation won't perform the action. It only alerts me when I leave the house if there's a storm within 5 miles of my location.

Here's the expanded iOS Notification with the Radar image attachment. Since it's an animated GIF, it will loop in the notification. (Some markers on the map are blurred for privacy)

Since I want to make sure I only get alerted when I'm leaving the house instead of alerting me when I open the door to come inside. I'm going to toy around with using the door sensor I have on the actual garage door to add a secondary condition (using some AND logic) to see if I can make it so it will only alert if a storm is under 5 miles away and the garage door was closed when the entry door was opened.

Update: I've updated the Home Assistant automation to include the condition to ensure I only get this alert when I'm actually leaving the house. It's been working great!

Previous Post | Next Post