Skip to content

Diondk/nlalert_radius

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NL-Alert (Nearby)

A custom Home Assistant integration that monitors NL-Alert messages for the Netherlands and determines whether they are near or affecting your configured zone (e.g. zone.home).

The integration fetches official NL-Alert data, calculates accurate distances to alert areas (using polygon-edge math), and exposes multiple sensors for automation and dashboards.


✨ Features

  • 🇳🇱 Uses the official NL-Alert public API
  • 📍 Configurable zone (default: zone.home)
  • 📏 Configurable radius (km)
  • 🗺️ Accurate distance calculation:
    • Distance to polygon edges
    • 0 km if your zone is inside the alert area
  • 🧠 Fully configurable via the Home Assistant UI (no YAML)
  • 🔄 Automatic updates on a configurable interval
  • 🧾 Exposes alert text, timing, and distance
  • 🕘 Tracks the most recent inactive NL-Alert
  • ⚙️ Option to track last inactive alert:
    • Only within your zone/radius or
    • Anywhere in the Netherlands
  • 🌍 English and Dutch translations included
  • 🧩 HACS compatible

🧩 Sensors Created

sensor.nl_alert_nearby

State

  • Number of active NL-Alerts within your configured radius

Attributes

  • alerts: list of matching alerts
    • id
    • message
    • start_at
    • stop_at
    • distance_km

sensor.nl_alert_nearby_closest_distance

State

  • Distance (km) to the closest active NL-Alert area

Meaning

  • 0.0 km → your zone is inside the alert area
  • > 0 km → alert nearby
  • unknown → no active alerts within radius

sensor.nl_alert_nearby_last_inactive

Tracks the most recent NL-Alert that is no longer active from the current API response.

State

  • Timestamp when the last inactive alert stopped (shown in relative time like "4 days ago")

Attributes

  • id
  • message
  • start_at
  • stop_at
  • distance_km

Note: This sensor shows the latest inactive alert from the API at the time of each update. It does not persist historical data across restarts.


⚙️ Configuration (UI)

All configuration is done via:

Settings → Devices & Services → Add Integration → NL-Alert (Nearby)

Initial setup options

  • Name (default: NL-Alert (Nearby))
  • Zone (default: zone.home)
  • Radius (km) (default: 25.0)
  • Update interval (seconds) (default: 300)
  • Last inactive alert scope
    • Only within your zone/radius (default)
    • Anywhere in the Netherlands

Changing configuration later

  • To change zone: Use the Reconfigure option (three dots menu → Reconfigure)
  • To change radius, interval, or scope: Use the Options menu (three dots menu → Configure)

Note: Each zone can only be configured once. To monitor multiple zones, add multiple instances of the integration.


🛠️ Installation

Option 1: Install via HACS (recommended)

  1. Open HACS
  2. Go to Integrations
  3. Click ⋮ → Custom repositories
  4. Add:
    • Repository: https://github.com/Diondk/nlalert_radius
    • Category: Integration
  5. Search for NL-Alert (Nearby)
  6. Install
  7. Restart Home Assistant
  8. Add the integration via Devices & Services

Option 2: Manual installation

  1. Download or clone this repository
  2. Copy the folder:
    custom_components/nlalert_radius
    
    to your Home Assistant custom_components directory
  3. Restart Home Assistant
  4. Add the integration via Settings → Devices & Services → Add Integration

📝 Example Automations

Send notification when alert becomes active nearby

This automation triggers when any NL-Alert appears within your configured radius and sends a notification with the alert message and distance.

Example: If there's a fire in Roermond and you're 40 km away with a 70 km radius configured, you'll receive a notification like: "Brand in Roermond - Distance: 40 km"

automation:
  - alias: "NL-Alert Nearby Notification"
    trigger:
      - platform: state
        entity_id: sensor.nl_alert_nearby
    condition:
      - condition: numeric_state
        entity_id: sensor.nl_alert_nearby
        above: 0
    action:
      - service: notify.mobile_app
        data:
          title: "🚨 NL-Alert Nearby"
          message: >
            {{ state_attr('sensor.nl_alert_nearby', 'alerts')[0].message }}
            Distance: {{ state_attr('sensor.nl_alert_nearby', 'alerts')[0].distance_km }} km

Alert when zone is inside alert area

This automation triggers when your zone is directly inside an active alert area (distance = 0 km), meaning you are in the affected zone and should take immediate action.

Example: If an NL-Alert is issued for your city and your home location is within the alert polygon, you'll receive: "Your location is affected!" with distance showing 0.0 km.

automation:
  - alias: "NL-Alert Zone Inside Alert Area"
    trigger:
      - platform: numeric_state
        entity_id: sensor.nl_alert_nearby_closest_distance
        below: 0.1
    action:
      - service: notify.mobile_app
        data:
          title: "⚠️ NL-Alert - Your location is affected!"
          message: >
            {{ state_attr('sensor.nl_alert_nearby', 'alerts')[0].message }}

🔧 Troubleshooting

Integration doesn't load

  • Check that you've restarted Home Assistant after installation
  • Check the Home Assistant logs for errors related to nlalert_radius

No alerts showing up

"Zone already configured" error

  • Each zone can only be configured once
  • To change settings for an existing zone, use the Options or Reconfigure menu
  • To monitor a different zone, delete the existing integration first or use a different zone entity

📡 Data Source

This integration uses the Public Warning App API which provides official NL-Alert data for the Netherlands.

API Endpoint: https://api.public-warning.app/api/v1/providers/nl-alert/alerts


📄 License

This project is licensed under the MIT License.


🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


⭐ Support

If you find this integration useful, please consider giving it a star on GitHub!

About

Home Assistant custom integration for NL-Alert notifications within a specific radius

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages