{"id":13627158,"url":"https://github.com/idodov/RedAlert","last_synced_at":"2025-04-16T19:31:12.414Z","repository":{"id":199688908,"uuid":"703464829","full_name":"idodov/RedAlert","owner":"idodov","description":"Israeli Red Alert Service for Home Assistant","archived":false,"fork":false,"pushed_at":"2024-04-08T16:48:58.000Z","size":404,"stargazers_count":25,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-08T20:36:17.238Z","etag":null,"topics":["appdaemon","appdaemon-apps","automation","hacs","hacs-custom","home-assistant","israeli"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idodov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-11T09:44:46.000Z","updated_at":"2024-04-14T17:25:25.535Z","dependencies_parsed_at":"2023-10-16T03:21:52.067Z","dependency_job_id":"8471f176-c883-4241-9f33-1fb4738c63f6","html_url":"https://github.com/idodov/RedAlert","commit_stats":null,"previous_names":["idodov/redalert"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idodov%2FRedAlert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idodov%2FRedAlert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idodov%2FRedAlert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idodov%2FRedAlert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idodov","download_url":"https://codeload.github.com/idodov/RedAlert/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249268549,"owners_count":21240941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appdaemon","appdaemon-apps","automation","hacs","hacs-custom","home-assistant","israeli"],"created_at":"2024-08-01T22:00:30.876Z","updated_at":"2025-04-16T19:31:07.406Z","avatar_url":"https://github.com/idodov.png","language":"Python","funding_links":[],"categories":["Projects by main language","**[🚨](https://emojipedia.org/police-car-light) Red Alert (Tzeva Adom) Warning Integrations**","Home Automation"],"sub_categories":["python","Home Assistant"],"readme":"# Israeli Red Alert Service for Home Assistant (AppDaemon)\n***Not Official Pikud Ha-Oref***\n\nThis script creates a suite of binary sensors that issue warnings for all hazards signaled by PIKUD HA-OREF. These hazards encompass red alerts for missile and rocket fire, breaches by unauthorized aircraft, seismic activity, tsunami warnings, terrorist incursions, chemical spill emergencies, non-conventional warfare, among other dangers. Upon receiving an alert, the specific type of threat is indicated at the start of the message (for instance, `ירי רקטות וטילים` for rocket and missile fire).\n\nThe script offers additional functionalities, such as archiving all alert details in a historical text and CSV files and facilitating the creation of additional sub-sensors derived from the primary sensor.\n____\n### This script introduces four new entities in Home Assistant:\n\u003e [!NOTE]\n\u003e **You can customize the sensor name to your liking, with `red_alert` set as the default.**\n* `binary_sensor.red_alert`: Holds PIKUD HA-OREF data, triggering on alarms and resetting otherwise. It’s useful for automations or creating additional sensors.\n* `binary_sensor.red_alert_city`: Similar to the above but only triggers if the specified city is targeted by the alarm.\n* `input_text.red_alert`: Logs the most recent alert data, serving as a historical log.\n* `input_boolean.red_alert_test`: Simulates a dummy alert to verify automation setups.\n\nThe script automatically generates two GeoJSON files that store the alert’s geolocation data, which can be displayed on the Home Assistant map.\n# Installation Instructions\n\u003e [!TIP]\n\u003e For saving history data you need to create a folder called `www` inside the Home Assistant directory.\n\u003e To ensure the history of sensors is maintained after a restart in Home Assistant, it’s advisable to establish input text and boolean helpers. It’s best to do this prior to installation. Here’s how you can proceed:\n\u003e 1. Open `configuration.yaml`.\n\u003e 2. Add this lines and restart Home Assistant:\n\u003e ```yaml\n\u003e #/config/configuration.yaml\n\u003e homeassistant:\n\u003e   allowlist_external_urls:\n\u003e     - http://192.168.86.20:8123  # YOUR HOME ASSISTANT IP\n\u003e     - http://homeassistant.local:8123\n\u003e   allowlist_external_dirs:\n\u003e    - \"/config/www\"\n\u003e \n\u003e input_text:\n\u003e   red_alert:\n\u003e     name: Last Alert in Israel\n\u003e     min: 0\n\u003e     max: 255\n\u003e\n\u003e input_boolean:\n\u003e   red_alert_test:\n\u003e     name: Test Alert\n\u003e     icon: mdi:alert-circle\n\u003e ```\n1. Install the **AppDaemon** addon in Home Assistant by going to `Settings` \u003e `Add-ons` \u003e `Ad-on-store` and search for **AppDaemon**.\n2. Once AppDaemon is installed, enable the **Auto-Start** and **Watchdog** options.\n3. Go to the AppDaemon ***configuration*** page and add `requests` ***Python package*** under the Python Packages section.\n\n![Capture1](https://github.com/idodov/RedAlert/assets/19820046/d4e3800a-a59b-4605-b8fe-402942c3525b)\n\n4. **Start** the add-on\n5. In file editor open **`/addon_configs/a0d7b954_appdaemon/appdaemon.yaml`** and make the changes under *appdeamon* section as described:\n\u003e [!TIP]\n\u003e  If you’re using the File Editor add-on, it’s set up by default to only allow file access to the main Home Assistant directory. However, the AppDaemon add-on files are located in the root directory. To access these files, follow these steps:\n\u003e 1. Go to `Settings` \u003e `Add-ons` \u003e `File Editor` \u003e `Configuration`\n\u003e 2. Toggle off the `Enforce Basepath` option.\n\u003e 3. In the File Editor, click on the arrow next to the directory name (which will be ‘homeassistant’). This should give you access to the root directory where the AppDaemon add-on files are located.\n\u003e \n\u003e    ![arrow](https://github.com/idodov/RedAlert/assets/19820046/e57ea52d-d677-45b0-90c4-87723c5ddfea)\n\n\n\u003e [!IMPORTANT]\n\u003e You can locate your own coordinates (latitude \u0026 longitude) here: https://www.latlong.net/\n\u003e *  `latitude: 31.9837528`\n\u003e *  `longitude: 34.7359077`\n\u003e *  `time_zone: Asia/Jerusalem`.\n\u003e *   If you install this script via HACS - **Specify the apps directory in `app_dir: /homeassistant/appdaemon/apps/`.**\n\u003e     * Also **transfer** all files from `/addon_configs/a0d7b954_appdaemon/apps` to `/config/appdaemon/apps`.\n\u003e   ```yaml\n\u003e     #/addon_configs/a0d7b954_appdaemon/appdaemon.yaml\n\u003e     ---\n\u003e     #secrets: /homeassistant/secrets.yaml\n\u003e     appdaemon:\n\u003e         app_dir: /homeassistant/appdaemon/apps/ # If you install this script via HACS\n\u003e         latitude: 31.9837528\n\u003e         longitude: 34.7359077\n\u003e         elevation: 2\n\u003e         time_zone: Asia/Jerusalem\n\u003e         plugins:\n\u003e           HASS:\n\u003e             type: hass\n\u003e     http:\n\u003e         url: http://127.0.0.1:5050\n\u003e     admin:\n\u003e     api:\n\u003e     hadashboard:\nYou have two choices to download the script: manually or via HACS. Installing from HACS ensures that if any new version of the script becomes available, you’ll receive a notification in Home Assistant. Manual download won’t provide you with future automatic updates. Pick the method that suits you best.\n### Manual Download\n1. Download the Python file from [This Link](https://github.com/idodov/RedAlert/blob/main/apps/red_alerts_israel/red_alerts_israel.py).\n2. Place the downloaded file inside the `/addon_configs/a0d7b954_appdaemon/apps` directory and proceed to the **final step**\n### HACS Download\n1. In Home Assistant: Navigate to `HACS` \u003e `Automation`\n   * If this option is not available, go to `Settings` \u003e `Integrations` \u003e `HACS` \u003e `Configure` and enable `AppDaemon apps discovery \u0026 tracking`. After enabling, return to the main HACS screen and select `Automation`\n2. Navigate to the `Custom Repositories` page and add the following repository as `Appdaemon`: `https://github.com/idodov/RedAlert/`\n3. Return to the `HACS Automation` screen, search for `Red Alerts Israel`, click on `Download` and proceed to the **final step**\n### Final Step\nIn the `appdaemon/apps/apps.yaml` file, add the following code. \n\u003e [!IMPORTANT]\n\u003e **Make sure to replace the `city_names` values as PIKUD HA-OREF defines them. For example, don’t write `תל אביב`, instead write: `תל אביב - דרום העיר`.**\n\u003e\n\u003e For a list of city and area names - [Click Here](https://github.com/idodov/RedAlert/blob/main/cities_name.md)\n```yaml\n#/appdaemon/apps/apps.yaml\nred_alerts_israel:\n  module: red_alerts_israel\n  class: Red_Alerts_Israel\n  interval: 2\n  timer: 120\n  sensor_name: \"red_alert\"\n  save_2_file: True\n  city_names:\n    - תל אביב - מרכז העיר\n    - כיסופים\n    - שדרות, איבים, ניר עם\n    - אשדוד - א,ב,ד,ה\n    - נתיב הל''ה\n```\n\n| Parameter | Description | Example |\n|---|---|---|\n| `interval` | The interval in seconds at which the script runs | `2` |\n| `timer` | The duration, in seconds, for which the sensor remains on after an alert | `120` |\n| `sensor_name` | The name of the primary binary sensor in Home Assistant (`binary_sensor.#sensor_name#`) | `red_alert` |\n| `save_2_file` | Store historical data files. Each time an alert is triggered, a dedicated TXT file and CSV file will save the data. This file is accessible from the Home Assistant WWW directory/ The CSV can be opened in any spreadsheet application, such as Excel or Google Sheets | `True` |\n| `city_names` | The names of the cities that activate the second binary sensor that will be named `binary_sensor.#sensor_name#_city`. *You can add as many cities you want* | `תל אביב - מרכז העיר` |\n_______\n## YOU ARE ALL SET!  \nHome Assistant initializes four distinct entities:\n* `binary_sensor.red_alert`: This is the main entity that becomes active during a Red Alert in Israel and reverts to inactive otherwise. It encompasses a range of attributes like category, ID, title, data, description, active alert count, and emojis.\n* `binary_sensor.red_alert_city`: This entity retains PIKUD-HA-OREF data and is activated solely if the alert includes the specified city.\n* `input_text.red_alert`: Intended for logging alert history in the logbook. Given Home Assistant’s 255-character limit for text entities, extensive events may lead to data being cut off or omitted. Therefore, it’s inadvisable to rely on this entity for automation triggers or to generate sub-sensors.\n* `input_boolean.red_alert_test`: Flipping this switch generates fictitious data (for selected cities) that activates the sensor for a set duration as per the `timer` configuration.\n\n**Card Example**\n\n![red-alerts-sensors](https://github.com/idodov/RedAlert/assets/19820046/e0e779fc-ed92-4f4e-8e36-4116324cd089)\n```yaml\ntype: vertical-stack\ncards:\n  - type: tile\n    entity: input_text.red_alert\n    vertical: true\n    state_content: last-changed\n  - type: entities\n    entities:\n      - entity: binary_sensor.red_alert\n      - entity: binary_sensor.red_alert_city\n      - entity: input_boolean.red_alert_test\n    state_color: true\n```\n\n**24 Hours History**\n\n![red-alert-history-data](https://github.com/user-attachments/assets/1b3861c0-4953-47d9-ab28-a281260d8c4f)\n\u003e [!TIP]\n\u003e You can modify the card by choosing to show or not to show the history and more information data.\n\u003e `{% set show_history = False %}` False is to not show the 24 hours alert history\n\u003e `{% set show_info = False %}` - False is to not show the more info data\n```yaml\ntype: markdown\ncontent: \u003e-\n  {% set show_history = True %}\n\n  {% set show_info = True %} \n\n  {% set alerts = state_attr('binary_sensor.red_alert',\n  'last_24h_alerts_group') %}\n\n  {% set oref = states('binary_sensor.red_alert') %}\n\n  \u003ctable width=100%\u003e\u003ctr\u003e\u003ctd align=center\u003e\n\n  {% if oref == 'on' %}\n\n  # \u003cfont color = red\u003e{{ state_attr('binary_sensor.red_alert', 'prev_title')\n  }}\u003c/font\u003e {{ state_attr('binary_sensor.red_alert', 'emoji') }}\n\n  \u003c/td\u003e\u003c/tr\u003e\n\n  \u003ctr\u003e\u003ctd align=center\u003e\u003cbig\u003e\u003cbig\u003e\n\n  \u003cb\u003e{{ state_attr('binary_sensor.red_alert', 'alert_txt') }}\u003c/b\u003e\u003c/big\u003e\u003c/big\u003e\n\n  {% else %}\n\n  ## \u003cfont color=green\u003eאין התרעות\u003c/font\u003e ✅{% endif %}\n\n  \u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n  {% set current_date = now().date() %}\n\n  {% if state_attr('binary_sensor.red_alert', 'prev_last_changed') |\n  regex_match(\"^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\d{2}:\\d{2}.\\d+$\") %}\n\n  {% set last_changed_timestamp = state_attr('binary_sensor.red_alert',\n  'prev_last_changed') | as_timestamp %}\n\n  {% if current_date == (last_changed_timestamp | timestamp_custom('%Y-%m-%d',\n  true) | as_datetime).date() %}\n\n  {% set current_timestamp = now().timestamp() %}\n\n  {% set time_difference = current_timestamp - last_changed_timestamp %}\n\n  \u003ccenter\u003eהתרעה אחרונה נשלחה {% if time_difference \u003c 3600 %} לפני {{\n  (time_difference / 60) | int }} דקות\n\n  {% elif time_difference \u003c 86400 %}היום בשעה {{ last_changed_timestamp |\n  timestamp_custom('%H:%M', true) }}\n\n  {% else %}בתאריך {{ last_changed_timestamp | timestamp_custom('%d/%m/%Y',\n  true) }}, בשעה {{ last_changed_timestamp | timestamp_custom('%H:%M', true) }}\n\n  {% endif %}{% endif %}{% endif %}\n\n  \u003c/ha-alert\u003e\n\n  {% if alerts and show_history %}\n\n  {% if show_info %}\n\n  \u003chr\u003e\n\n  \u003ctable width=100%\u003e\n\n  \u003ctr\u003e\u003ctd align=center\u003e\n\n  {{ state_attr('binary_sensor.red_alert', 'cities_past_24h') | length }}\n  :ערים\u003c/td\u003e\n\n  \u003ctd align=center\u003e \n\n  {{ state_attr('binary_sensor.red_alert', 'last_24h_alerts') | length }}\n  :התרעות\u003c/td\u003e\u003c/tr\u003e\n\n  \u003ctr\u003e\n\n  \u003ctd colspan=2 align=center\u003e\n\n  במהלך 24 שעות אחרונות \n\n  \u003c/td\u003e\n\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\u003ctd colspan=2\u003e\u003chr\u003e\u003c/td\u003e\u003c/tr\u003e\n\n  \u003c/table\u003e\n\n  {% endif %}\n\n  \u003ctable width=100% align=center\u003e\n\n  {% for alert_type, areas in alerts.items() %}\n\n  \u003ctr\u003e\n\n  \u003ctd\u003e\u003c/td\u003e\n\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n\n  \u003ctd colspan=6 align=center\u003e\u003ch2\u003e\u003cfont color=blue\u003e{{ alert_type }}\u003c/font\u003e\u003c/h2\u003e\n\n  \u003chr\u003e\u003c/td\u003e\n\n  \u003c/tr\u003e\n\n  {% for area, cities in areas.items() %}\n\n  \u003ctr\u003e\n\n  \u003ctd\u003e\u003c/td\u003e\n\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n\n  \u003ctd colspan=6 align=center\u003e\u003cbig\u003e\u003cb\u003e{{ area }}\u003c/b\u003e\u003c/big\u003e\u003c/td\u003e\u003c/tr\u003e\n\n  \u003ctr\u003e\n\n  \u003ctd colspan=6\u003e\u003c/td\u003e\n\n  \u003c/tr\u003e\n\n  {% for city_pair in cities|batch(2) %}\n\n  \u003ctr\u003e\u003ctd align=right valign=top\u003e{{ city_pair[0].city }}\u003c/td\u003e\n\n  \u003ctd valign=top\u003e - \u003c/td\u003e\u003ctd valign=top\u003e{{ city_pair[0].time[11:16] }}\u003c/td\u003e{% if\n  city_pair|length \u003e 1 %} \n\n  \u003ctd align=right valign=top\u003e{{ city_pair[1].city }}\u003c/td\u003e\n\n  \u003ctd valign=top\u003e - \u003c/td\u003e\u003ctd valign=top\u003e{{ city_pair[1].time[11:16] }}{% else\n  %}\u003c/td\u003e{% endif %}\u003c/tr\u003e\n\n  {% endfor %}\n\n  \u003ctr\u003e\n\n  \u003ctd colspan=6\u003e\u0026nbsp;\u003c/td\u003e\n\n  \u003c/tr\u003e\n\n  {% endfor %}\n\n  {% endfor %}\n\n  \u003c/table\u003e\n\n  {% else %}\n\n  {% endif %}\n\n```\n\n\n\u003e [!TIP]\n\u003e Use this trigger in automation `{{ (as_timestamp(now()) - as_timestamp(states.binary_sensor.red_alert.last_updated)) \u003e 30 }}` to know when the script fails to run.\n\u003e \n\u003e You can also create a specialHis markdown card to track the sensor:\n\u003e \n\u003e ![runs](https://github.com/idodov/RedAlert/assets/19820046/ba01b903-7cd8-4549-9859-8081d8f11712)\n\u003e ```yaml\n\u003e type: markdown\n\u003e content: \u003e-\n\u003e   {% set status = (as_timestamp(now()) -\n\u003e   as_timestamp(states.binary_sensor.red_alert.last_updated)) \u003c 30 %}\n\u003e   {% if status %}\n\u003e   \u003cha-alert alert-type=\"info\"\u003eRun **{{ state_attr('binary_sensor.red_alert', 'count') }}** times since restart\n\u003e   {% else %}\n\u003e   \u003cha-alert alert-type=\"warning\"\u003e**SCRIPT IS NOT RUNNING!!!**\n\u003e   {% endif %}\n\u003e   \u003c/ha-alert\u003e\n\u003e ```\n\n## binary_sensor.red_alert Attribues\nYou can use any attribue from the sensor. For example, to show the title on lovelace card, use this code syntax: \n```{{ state_attr('binary_sensor.red_alert', 'title') }}```\n| Attribute name | Means | Example |\n| ----- | ----- | ----- |\n| `active_now' | `on` when there is a live alert, `off` when there is no live alerts | `off` |\n| `count` | Counts the number of times the script has run since the last restart of Home Assistant. By monitoring this data, you can determine if and when the script is not running. | `12345` |\n| `cat` | Category number. can be from 1 to 13 | `1` |\n| `title` | Attack type in text | `ירי רקטות וטילים` |\n| `data` | List of cities as string | `תל אביב - מרכז העיר` |\n| `cities` | List of cities that are attacked | `- קריית שמונה` |\n| `alerts_count` | Number of live alerts | `4` |\n| `my_cities` | The defined user cities | `- תל אביב - מרכז העיר` |\n| `areas` | List of areas as string | `גוש דן` |\n| `desc` | Explain what to do |  `היכנסו למרחב המוגן ושהו בו 10 דקות` |\n| `duration` | How many seconds to be in the safe room | `600` |\n| `id` | Id of the alert | `133413399870000000` |\n| `data_count` | Number of cities that are attacked | `1` |\n| `cities_past_24h` | List of cities that had attacked in the past 24 hours | `- שלומי` |\n| `last_24h_alerts` | List of all alerts in the past 24 hours | `title`, `city`, `area`, `time` |\n| `last_24h_alerts_group` | List of all 24 hours alerts grouped by title and area | `titile`, `area`, `city`, `time` |\n| `emoji` | Icon for type of attack | `🚀` |\n| `prev_*` | Last data from each attribue | Stores the most recent information when the sensor was active |\n| `alert` | One line full text  | `ירי רקטות וטילים ב־קו העימות - בצת, שלומי` |\n| `alert_alt` | Breaking line full text | ` ירי רקטות וטילים/n* קו העימות: בצת, שלומי` |\n| `alert_txt` | One line text | `קו העימות: בצת, שלומי` |\n| `alert_wa` | Optimize text message to send via whatsapp | ![whatsapp](https://github.com/idodov/RedAlert/assets/19820046/817c72f4-70b1-4499-b831-e5daf55b6220) |\n| `alert_tg` | Optimize text message to send via telegram |  |\n\n**Example:**\n```yaml\ncount: 237\nid: 1234567890000000\ncat: 1\ntitle: ירי רקטות וטילים\ndesc: היכנסו למרחב המוגן ושהו בו 10 דקות\ndata: אבירים, פסוטה\nareas: קו העימות\ndata_count: 2\nduration: 600\nlast_changed: \"2024-03-29T20:18:36.354614\"\nemoji: ⚠️\nicon_alert: mdi:alert\nprev_last_changed: \"2024-03-29T20:18:36.354636\"\nprev_cat: 1\nprev_title: ירי רקטות וטילים\nprev_desc: היכנסו למרחב המוגן ושהו בו 10 דקות\nprev_data: שלומי\nprev_data_count: 1\nprev_duration: 600\nprev_areas: קו העימות\nalert: \"ירי רקטות וטילים ב־קו העימות: שלומי\"\nalert_alt: |-\n  ירי רקטות וטילים\n   * קו העימות: שלומי\nalert_txt: \"קו העימות: שלומי\"\nalert_wa: |-\n  🚀 *ירי רקטות וטילים*\n  \u003e קו העימות\n  שלומי\n\n  _היכנסו למרחב המוגן ושהו בו 10 דקות_\nfriendly_name: All Red Alerts\nicon: mdi:alert\nalert_tg: |-\n  🚀 **ירי רקטות וטילים**\n  **__קו העימות__** — שלומי\n\n  __היכנסו למרחב המוגן ושהו בו 10 דקות__\n```\n# Usage *Red Alert* for Home Assistant\n## Map\n![{FF1A0EEA-8270-4D29-ACBC-3D0EEF065EE3}](https://github.com/user-attachments/assets/6834a827-0186-4b60-921c-f5918dc3bd1b)\n\nThe script also creates two GeoJSON files automatically, which store the alert’s geolocation data and can be displayed on the Home Assistant map. Both files are located in the `\\\\homeassistant\\config\\www` directory. The `red_alert_24h.geojson` file stores data for alerts from the last 24 hours, and the `red_alert_latest.geojson` file stores the most recent alert data.\n\n**To display the data on the Home Assistant map:**\n1. Install the GeoJSON integration directly from the Home Assistant integration page.\n2. Add the GeoJSON URL: `http://homeassistant.local:8123/local/red_alert_24h.geojson`.\n3. Adjust the radius to cover the entire country area.\n   \n![{28E29F42-3F7F-4625-859B-587381F81941}](https://github.com/user-attachments/assets/23f2f200-28a9-49c1-82c7-79a00343f23c)\n\u003e [!NOTE]\n\u003e If the GeoJSON integration can't access the GeoJSON file, open the `configuration.yaml` file and add the necessary approval, like this:\n\u003e ```yaml\n\u003e homeassistant:\n\u003e   allowlist_external_urls:\n\u003e     - http://192.168.86.174:8123      # YOUR HA IP\n\u003e     - http://homeassistant.local:8123\n\u003e   allowlist_external_dirs:\n\u003e     - \"/config/www\"\n\u003e ```\n\n## History File\nThe script stores the sensor data in a text file named `red_alert_history.txt` and `red_alert_history.csv`, both located in the `\\\\homeassistant\\config\\www` directory. Each time an alert (including test alerts) is triggered, the files gets updated. The dedicated CSV file can be opened in any spreadsheet application, such as Excel or Google Sheets.\n You can directly access these files from your browser using the provided URL: [ http://homeassistant.local:8123/local/red_alert_history.txt](http://homeassistant.local:8123/local/red_alert_history.txt).\n\n\n![red-alert-txt](https://github.com/idodov/RedAlert/assets/19820046/70e28cd2-2aee-4519-a0d6-6ac415c703e7)\n## Lovelace Card Example\nDisplays whether there is an alert, the number of active alerts, and their respective locations.\n\n![TILIM](https://github.com/idodov/RedAlert/assets/19820046/f8ad780b-7e64-4c54-ab74-79e7ff56b780)\n```yaml\ntype: markdown\ncontent: \u003e-\n  \u003ccenter\u003e\u003ch3\u003e{% if state_attr('binary_sensor.red_alert', 'data_count') \u003e 0 %}\n  כרגע יש {% if state_attr('binary_sensor.red_alert', 'data_count') \u003e 1 %}{{\n  state_attr('binary_sensor.red_alert', 'data_count') }} התרעות פעילות{% elif\n  state_attr('binary_sensor.red_alert', 'data_count') == 1 %} התרעה פעילה אחת{%\n  endif %}{% else %} אין התרעות פעילות{% endif %}\u003c/h3\u003e\n\n  {% if state_attr('binary_sensor.red_alert', 'data_count') \u003e 0 %}\u003ch2\u003e{{\n  state_attr('binary_sensor.red_alert', 'emoji') }} {{\n  state_attr('binary_sensor.red_alert', 'title') }}\u003c/h2\u003e\n  \u003ch3\u003e{{ state_attr('binary_sensor.red_alert', 'data') }}\u003c/h3\u003e\n  **{{ state_attr('binary_sensor.red_alert', 'desc') }}** {% endif %} \u003c/center\u003e\ntitle: Red Alert\n```\nUsing this script, you have the flexibility to include additional information, such as the **precise time the alert was triggered**.\n\n![TILIMA](https://github.com/idodov/RedAlert/assets/19820046/4ba18dde-ae0c-4415-a55d-80ed0c010cbc)\n![LAST](https://github.com/idodov/RedAlert/assets/19820046/ae52bc94-46ba-4cdb-b92b-36220500ee48)\n```yaml\ntype: markdown\ncontent: \u003e-\n  \u003ccenter\u003e\u003ch3\u003e{% if state_attr('binary_sensor.red_alert', 'data_count') \u003e 0 %}\n  כרגע יש {% if state_attr('binary_sensor.red_alert', 'data_count') \u003e 1 %}{{\n  state_attr('binary_sensor.red_alert', 'data_count') }} התרעות פעילות{% elif\n  state_attr('binary_sensor.red_alert', 'data_count') == 1 %} התרעה פעילה אחת{%\n  endif %}{% else %} אין התרעות פעילות{% endif %}\u003c/h3\u003e\n\n  {% if state_attr('binary_sensor.red_alert', 'data_count') \u003e 0 %}\u003ch2\u003e{{\n  state_attr('binary_sensor.red_alert', 'emoji') }} {{\n  state_attr('binary_sensor.red_alert', 'title') }}\u003c/h2\u003e \u003ch3\u003e{{\n  state_attr('binary_sensor.red_alert', 'data') }}\u003c/h3\u003e **{{\n  state_attr('binary_sensor.red_alert', 'desc') }}** {% endif %}\n\n  {% if state_attr('binary_sensor.red_alert', 'last_changed') |\n  regex_match(\"^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\d{2}:\\d{2}.\\d+$\") %}\n\n  {% set last_changed_timestamp = state_attr('binary_sensor.red_alert',\n  'last_changed') | as_timestamp %}\n\n  {% set current_date = now().date() %}\n\n  {% if current_date == (last_changed_timestamp | timestamp_custom('%Y-%m-%d',\n  true)\n   | as_datetime).date() %}\n   ההתרעה האחרונה נשלחה היום בשעה {{ last_changed_timestamp | timestamp_custom('%H:%M', true) }}\n  {% else %}התרעה אחרונה נשלחה בתאריך {{ last_changed_timestamp |\n  timestamp_custom('%d/%m/%Y', true) }}, בשעה {{ last_changed_timestamp |\n  timestamp_custom('%H:%M', true) }}\n\n  {% endif %}\n  {% endif %}\n  \u003c/center\u003e\n```\n**Another nicer way:**\n\n![3333](https://github.com/idodov/RedAlert/assets/19820046/438c0870-56e8-461b-a1e5-aa24122a71bc)\n![000000](https://github.com/idodov/RedAlert/assets/19820046/2d6da8d4-2f84-46d4-9f52-baffdbd4b54b)\n```yaml\ntype: markdown\ncontent: \u003e-\n  \u003cha-icon icon=\"{{ state_attr('binary_sensor.red_alert', 'icon')\n  }}\"\u003e\u003c/ha-icon\u003e {% if state_attr('binary_sensor.red_alert', 'data_count') \u003e 0\n  %}כרגע יש {% if state_attr('binary_sensor.red_alert', 'data_count') \u003e 1 %}{{\n  state_attr('binary_sensor.red_alert', 'data_count') }} התרעות פעילות{% elif\n  state_attr('binary_sensor.red_alert', 'data_count') == 1 %} התרעה פעילה אחת{%\n  endif %}{% else %}אין התרעות פעילות{% endif %}{% if\n  state_attr('binary_sensor.red_alert', 'data_count') \u003e 0 %}\n\n  \u003cha-alert alert-type=\"error\" title=\"{{ state_attr('binary_sensor.red_alert',\n  'title') }}\"\u003e{{ state_attr('binary_sensor.red_alert', 'data') }}\u003c/ha-alert\u003e\n\n  \u003cha-alert alert-type=\"warning\"\u003e{{ state_attr('binary_sensor.red_alert',\n  'desc') }}\u003c/ha-alert\u003e\n\n  {% endif %}\n\n  {% if state_attr('binary_sensor.red_alert', 'last_changed') |\n  regex_match(\"^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\d{2}:\\d{2}.\\d+$\") %}\n\n  {% set last_changed_timestamp = state_attr('binary_sensor.red_alert',\n  'last_changed') | as_timestamp %}\n\n  {% set current_date = now().date() %}{% if current_date ==\n  (last_changed_timestamp | timestamp_custom('%Y-%m-%d', true)\n   | as_datetime).date() %}\u003cha-alert alert-type=\"info\"\u003eההתרעה האחרונה נשלחה היום בשעה {{ last_changed_timestamp | timestamp_custom('%H:%M', true) }}\n  {% else %}התרעה אחרונה נשלחה בתאריך {{ last_changed_timestamp |\n  timestamp_custom('%d/%m/%Y', true) }}, בשעה {{ last_changed_timestamp |\n  timestamp_custom('%H:%M', true) }}{% endif %}{% endif %}\u003c/ha-alert\u003e\n```\n## Automation Examples\nYou have the flexibility to generate various automated actions triggered by the binary sensor or its subsidiary sensors. As an example, one potential application is to dispatch alert messages to a LED matrix screen (in  pic: forwarding all alerts to the Ulanzi Smart Clock, which is based on ESPHome32 and features a screen).\n\n![20231013_210149](https://github.com/idodov/RedAlert/assets/19820046/0f88c82c-c87a-4933-aec7-8db425f6515f)\n\n### Send a notification to the phone (Home Assistant app) when there is an alert in Israel (all cities)\n*(Change ```#your phone#``` to your entity name)*\n```yaml\nalias: Notify attack\ndescription: \"Real-time Attack Notification\"\ntrigger:\n  - platform: state\n    entity_id:\n      - binary_sensor.red_alert\n    from: \"off\"\n    to: \"on\"\ncondition: []\naction:\n  - service: notify.mobile_app_#your phone#\n    data:\n      message: \"{{ state_attr('binary_sensor.red_alert', 'data') }}\"\n      title: \"{{ state_attr('binary_sensor.red_alert', 'title') }} {{ state_attr('binary_sensor.red_alert', 'areas') }}\"\nmode: single\n```\n### Change the light color when there is an active alert in your city\nAs another illustration, you can configure your RGB lights to change colors repeatedly while the alert is active.\n\n![20231013_221552](https://github.com/idodov/RedAlert/assets/19820046/6e60d5ca-12a9-4fd2-9b10-bcb19bf38a6d)\n\n*(Change ```light.#light-1#``` to your entity name)*\n```yaml\nalias: Alert in city\ndescription: \"When an alert occurs in your define city, the lights will cyclically change to red and blue for a duration of 30 seconds, after which they will revert to their previous states\"\ntrigger:\n- platform: state\n  entity_id:\n    - binary_sensor.red_alert_city\n  from: \"off\"\n  to: \"on\"\ncondition: []\naction:\n  - service: scene.create\n    data:\n      scene_id: before_red_alert\n      snapshot_entities:\n        - light.#light-1#\n        - light.#light-2#\n        - light.#light-3#\n  - repeat:\n      count: 30\n      sequence:\n        - service: light.turn_on\n          data:\n            color_name: blue\n          target:\n            entity_id: \n            - light.#light-1#\n            - light.#light-2#\n            - light.#light-3#\n        - delay:\n            hours: 0\n            minutes: 0\n            seconds: 0\n            milliseconds: 500\n        - service: light.turn_on\n          data:\n            color_name: red\n          target:\n            entity_id: \n            - light.#light-1#\n            - light.#light-2#\n            - light.#light-3#\n        - delay:\n            hours: 0\n            minutes: 0\n            seconds: 0\n            milliseconds: 500\n  - service: scene.turn_on\n    data: {}\n    target:\n      entity_id: scene.before_red_alert\nmode: single\n```\n### Get notification When it's safe\nThe \"desc\" attribute provides information on the duration in minutes for staying inside the safe room. This automation will generate a timer based on the data from this attribute.\nBefore implementing this automation, it's essential to create a TIMER helper.\n1. Create a new **TIMER helper**. You can generate a new timer entity within the user interface under **'Settings' \u003e 'Devices and Services' \u003e 'Helpers' \u003e 'Create Helper' \u003e 'Timer'**\n2. Name it \"**Red Alert**\".\n3. Create automation with your desire trigger, \n**for example:** *(change ```#your phone#``` to your entity name)*\n```yaml\nAlias: Safe to go out\ndescription: \"Notify on phone that it's safe to go outside\"\nmode: single\ntrigger:\n  - platform: template\n    value_template: \u003e-\n      {{ \"תל אביב - מרכז העיר\" in state_attr('binary_sensor.red_alert',\n      'data').split(', ') }}\ncondition: []\naction:\n  - service: timer.start\n    data:\n      duration: \u003e-\n        {{ state_attr('binary_sensor.red_alert_city', 'duration') }}\n    target:\n      entity_id: timer.red_alert\n  - service: notify.mobile_app_#your phone#\n    data:\n      title: ההתרעה הוסרה\n      message: אפשר לחזור לשגרה\n```\n## Creating Sub Sensors\nWhile you need to specify the cities in which the secondary binary sensor will be activated, you also have the flexibility to define additional sub-sensors based on the main sensor. Here are a few examples of how you can do this.\n\u003e [!NOTE]\n\u003e To create a sensor that activates only when an attack occurs in a specific city that has similar character patterns in other city names, you should use the following approach. For example, if you want to create a sensor that activates when **only** \"יבנה\" and **not** \"גן יבנה\" is attacked, you can use the following code syntax.\n\u003e If you want to trigger a specific area, use the SPLIT function and make sure to type the city name and area **exactly** as they appear in https://www.oref.org.il/12481-he/Pakar.aspx\n\u003e ```\n\u003e {{ \"תל אביב - מרכז העיר\" in state_attr('binary_sensor.red_alert', 'data').split(', ') }}\n\u003e ```\n#### Yavne city and not Gan-Yavne city\n```\n{{ \"יבנה\" in state_attr('binary_sensor.red_alert', 'data').split(', ') }}\n```\n#### Multiple cities or city areas\n```\n{{ \"אירוס\" in state_attr('binary_sensor.red_alert', 'data').split(', ')\n or \"בית חנן\" in state_attr('binary_sensor.red_alert', 'data').split(', ')\n or \"גן שורק\" in state_attr('binary_sensor.red_alert', 'data').split(', ') }}\n```\n### Cities With Multiple Zones:\nIn cities with multiple zones, relying solely on the SPLIT function won't be effective if you've only defined the city name. If you need a sensor that triggers for all zones within the 11 cities divided into multiple alert zones, it's advisable to utilize the SEARCH_REGEX function instead of splitting the data.\n```\n{{ state_attr('binary_sensor.red_alert', 'data') | regex_search(\"תל אביב\") }} \n```\n### Metropolitan Areas\nIsrael is segmented into 30 metropolitan areas, allowing you to determine the general status of nearby towns without the need to specify each one individually. To achieve this, you can utilize the \"areas\" attribute. Here's the list of the 30 metropolitan areas in Israel, presented in alphabetical order:\n\nאילת, בקעה, בקעת בית שאן, גוש דן, גליל עליון, גליל תחתון, דרום הגולן, דרום הנגב, הכרמל, המפרץ, העמקים, השפלה, ואדי ערה, יהודה, ים המלח, ירושלים, ירקון, לכיש,  מנשה, מערב הנגב, מערב לכיש, מרכז הגליל, מרכז הנגב, עוטף עזה, \nערבה, צפון הגולן, קו העימות, שומרון, שפלת יהודה ושרון\n```\n{{ \"גוש דן\" in state_attr('binary_sensor.red_alert', 'areas').split(', ') }}\n```\n### Red Alert Trigger for Particular Type of Alert:\nThe **'cat'** attribute defines the alert type, with a range from 1 to 13. You have the option to set up a binary sensor for a particular type of alert with or without any city or area of your choice.\n| Cat (number) | Type of Alert |\n| ---- | --- |\n| 1 | Missle Attack |\n| 6 | Unauthorized Aircraft Penetration |\n| 13 | Infiltration of Terrorists |\n\n**Trigger for Automation**\n```\n{{ state_attr('binary_sensor.red_alert', 'cat') == '6' }}\n```\n***Sample trigger alert for unauthorized aircraft penetration in Nahal-Oz***\n```yaml\n{{ state_attr('binary_sensor.red_alert', 'cat') == '6'\nand \"נחל עוז\" in state_attr('binary_sensor.red_alert', 'data').split(', ') }}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidodov%2FRedAlert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidodov%2FRedAlert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidodov%2FRedAlert/lists"}