SkillAgentSearch skills...

RedAlert

Israeli Red Alert Service for Home Assistant

Install / Use

/learn @idodov/RedAlert
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Red Alerts Israel

Not Official Pikud Ha-Oref

Simple rocket-alert monitoring for Home Assistant via AppDaemon

Red Alerts Israel is an AppDaemon application for Home Assistant that connects to the official Israeli Home Front Command (Pikud HaOref) API. It fetches real-time "Tzeva Adom" rocket alerts and other hazards, making this information available via easy-to-use Home Assistant sensors.

This script monitors various hazards signaled by PIKUD HA-OREF, including missile/rocket fire, unauthorized aircraft, seismic activity, tsunami, terrorist incursions, chemical emergencies, and more. Upon receiving an alert, the specific threat type is indicated, for example, ירי רקטות וטילים for rocket and missile fire.

The application is designed for reliability and persistence, offering features like archiving alert details, state persistence via JSON backup, triggering Home Assistant native events, publishing messages via MQTT, and providing detailed sensor attributes for creating derived sensors and advanced automations.


Key Features

  • Polls the official Israeli Home Front Command API every few seconds for live alerts.
  • Creates dedicated Home Assistant entities: main binary sensors, a text helper, a test boolean, and three detailed history sensors.
  • Offers flexible alert notification publishing via MQTT and native Home Assistant events triggered by new alert payloads.
  • Saves alert history (TXT, CSV) and the last active state (JSON) for persistence across restarts (optional).
  • Generates GeoJSON files for visualizing active and historical alert locations on the Home Assistant map (optional).
  • Provides specific binary sensors to indicate if an alert affects your configured cities or if it's a special "Pre-Alert" type.
  • Tracks the history of distinct alert events within a configurable time window.
  • Generates pre-formatted messages suitable for platforms like WhatsApp and Telegram based on cumulative window data.

Entities Created

The script creates several Home Assistant entities, using your configured sensor_name as the base name (default: red_alert):

  • binary_sensor.YOUR_SENSOR_NAME: Indicates if any alert is currently active nationwide. This sensor stays on for the duration of the configured timer after the last detected alert activity in a sequence.
  • binary_sensor.YOUR_SENSOR_NAME_city: Indicates if binary_sensor.YOUR_SENSOR_NAME is on and the alert window includes one of the specific cities/areas you configured in city_names.
  • binary_sensor.YOUR_SENSOR_NAME_pre_alert: Indicates if a pre alert is currently active nationwide. This sensor turns on.
  • binary_sensor.YOUR_SENSOR_NAME_city_pre_alert: Indicates if a pre alert alert is currently active and affects one of your configured city_names. This sensor turns on only when an pre alert is received and processed AND the alert window includes one of your configured city_names.
  • binary_sensor.YOUR_SENSOR_NAME_active_alert: Indicates if an alert with a category other than pre alert is currently active nationwide. This sensor turns on.
  • binary_sensor.YOUR_SENSOR_NAME_city_active_alert: Indicates if an alert with a category other pre alert is currently active and affects one of your configured city_names. This sensor turns on when a pre alert is received and processed AND the alert window includes one of your configured city_names.
  • input_text.YOUR_SENSOR_NAME: Displays a summary of the latest alert payload received during an active alert window.
  • input_boolean.YOUR_SENSOR_NAME_test: Allows manual triggering of a fictitious test alert sequence.

Three additional history sensors track distinct alert events that occurred within the configured hours_to_show timeframe (after applying timer-based deduplication):

  • sensor.YOUR_SENSOR_NAME_history_cities: State is the count, attributes list unique cities alerted in the history window.
  • sensor.YOUR_SENSOR_NAME_history_list: State is the count, attributes list each distinct alert event entry in the history window.
  • sensor.YOUR_SENSOR_NAME_history_group: State is the count, attributes group distinct alert events by title, area, and city in the history window.
<details> <summary>Detailed Binary Sensor Logic and Attributes</summary>

Binary Sensor States (binary_sensor.YOUR_SENSOR_NAME, _city, _pre_alert, _city_pre_alert, _active_alert, _city_active_alert)

All six binary sensors are controlled by the script's polling and reset logic.

  • When a new alert payload is received from the API:

    • binary_sensor.YOUR_SENSOR_NAME turns on (if not already) and its internal timer is reset.
    • binary_sensor.YOUR_SENSOR_NAME_city turns on if any of the accumulated cities in the current alert window match your configured city_names, otherwise it stays off.
    • If the cat value in the latest incoming alert payload is 13:
      • binary_sensor.YOUR_SENSOR_NAME_pre_alert turns on.
      • binary_sensor.YOUR_SENSOR_NAME_city_pre_alert turns on if the binary_sensor.YOUR_SENSOR_NAME_city sensor is on (i.e., if configured cities are affected), otherwise it turns off.
      • binary_sensor.YOUR_SENSOR_NAME_active_alert turns off.
      • binary_sensor.YOUR_SENSOR_NAME_city_active_alert turns off.
    • If the cat value in the latest incoming alert payload is not 13 (e.g., cat=1 for rockets, which is the case for test alerts):
      • binary_sensor.YOUR_SENSOR_NAME_pre_alert turns off.
      • binary_sensor.YOUR_SENSOR_NAME_city_pre_alert turns off.
      • binary_sensor.YOUR_SENSOR_NAME_active_alert turns on.
      • binary_sensor.YOUR_SENSOR_NAME_city_active_alert turns on if the binary_sensor.YOUR_SENSOR_NAME_city sensor is on, otherwise it turns off.
  • When the alert timer expires and confirms no active alerts are pending:

    • All six binary sensors (_main, _city, _pre_alert, _city_pre_alert, _active_alert, _city_active_alert) are explicitly set to off.
  • On Script Initialization/Restart:

    • All six binary sensors are initialized to off.

Shared Binary Sensor Attributes

When any of the six binary sensors are updated, they receive the same set of attributes. These attributes reflect the state and accumulated information for the current alert window since binary_sensor.YOUR_SENSOR_NAME last turned on. When binary_sensor.YOUR_SENSOR_NAME is off, they show default/empty values or the prev_* values from the window that just ended, providing context about the last alert incident.

| Attribute name | Description | Example | | :------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------- | | active_now | true when binary_sensor.YOUR_SENSOR_NAME is on, false when off. Mirrors the main sensor state. | false | | script_status | The operational status of the AppDaemon script (initializing, running, error, terminated). Useful for monitoring the script itself. | running | | id | Unique ID of the latest alert payload received during the current window. | 1721993400123456 | | cat | Category number (0-14) of the latest alert payload. Corresponds to alert type (e.g., 1 for rockets, 13 for special update). | 1 | | title | Title/Type of the latest alert payload (e.g., "ירי רקטות וטילים"). | ירי רקטות וטילים | | desc | Recommended action description from the latest alert payload (e.g., "היכנסו למרחב המוגן ושהו בו 10 דקות"). | היכנסו למרחב המוגן ושהו בו 10 דקות | | special_update | true if the cat of the latest alert payload is 13, false otherwise. This attribute mirrors the state logic of the *_pre_alert sensors. | false | | areas | Comma-separated string of all areas affected by any payload within the current active window. | גוש דן, קו העימות | | cities | A sorted list of all unique original city names affected by any payload within the current active window. | ['אור יהודה', 'תל אביב - מרכז העיר'] | | data | Comma-separated string of all unique original city names affected during the current active window. May be truncated if very long. |

View on GitHub
GitHub Stars58
CategoryDevelopment
Updated1d ago
Forks6

Languages

Python

Security Score

100/100

Audited on Mar 29, 2026

No findings