Integrating Israeli Rocket Alerts (Red Alerts) Into Home Assistant

Daniel Rosehill
Daniel’s Tech World
8 min readApr 4, 2024

NB: I can’t commit to updating this post regularly or forever. The features mentioned are as described only at the date of publication. home automation -

So as we all know, Israel is currently going through extremely testing times from a security perspective.

Israel’s longstanding policy is not to comment on foreign media reports. But it is almost universally believed to be behind a strike on an Iranian consulate in Damascus that resulted in the killing of several Iranian Revolutionary Guard Corps (IRGC) commanders.

Everyone in Israel is bracing for what an Iranian response might look like — and the very real possibility that Israel’s shadow war with Iran will move into the open.

This seemed like a good moment to finally get around to integrating the Red Alert system into my Home Assistant install.

Firstly, if you’re thinking about following these steps, know that you’re doing so at your own risk!

Israel’s Home Front Command ( Pikud HaOref) operates an official National Emergency Portal (and smartphone apps) where you can receive the alerts.

Additionally, there are a plethora of options provided by amateur third party integrators. You can find solutions for pushing Red Alert notifications to everything from Telegram through to WhatsApp.

As I mentioned in a previous blog, I’m a huge believer in the value of backups. I try to extend this concept to all forms of technology. When it comes to receiving vital notifications about incoming rockets, never allow yourself to have a single point of failure.

At a minimum, I’d recommend operating this system in addition to receiving alerts through the official (Pikud HaOref) smartphone app. Here’s the Google Play link for that.

Home Assistant Red Alert Apps

Perusing the Googlesphere, I found two apparently independent projects both creating Home Assistant integrations for the red alert system (hey, they don’t say “two Jews, three opinions” for no reason).

There’s RedAlert:

And there’s oref_alert:

I tried both but ended up using the latter (I really liked the fact that it created a service call specifically for testing the system so that you can validate that your setup is working before you require it!)

My current Home Assistant OS host (an Aliexpress mini PC). I run all my networking gear (and the mini PC) off a UPS to ensure connectivity in the event of a power outage.

Prerequisites (Hardware, Software):

  • To install third-party integrations we’re going to need to be running Home Assistant OS / a “supervised” install.
  • The hardware to run this.
  • A UPS to ensure that the network stays up and the alerts are sent in the event of a power outage (not essential but highly recommended.)
  • HACS installed (also not required but it makes installing integrations a lot quicker).

Oref Alert Configuration Steps

I’ll provide the instructions for HACS users. Also note: these are “valid” only at the time I’m writing this blog. They may change in the future.

Download the integration. Local link:

http://homeassistant.local:8123/hacs/repository/706651591

Once that has been setup, you add the integration through Home Assistant (settings -> integrations):

To configure the integration, we just need to navigate into it and click on the “configure” button:

The pop-up here allows you to create your default alert. You need to select the area(s) to monitor in Hebrew:

Pay attention to the middle parameters which affect how long the alert will stay active for and what the polling/update frequency should be:

Finally you may wish to configure different icons for when the entity is in alert mode and in “regular” mode to provide visual indicators of a threat:

If you search for the keyword ‘alert’ under your entities (devices -> entities) you can see what the integration has created:

The default (first) alert that you create is:

binary_sensor.oref_alert

In my case, I “dedicated” this alert to Jerusalem (Merkaz) (ירושלים — מרכז) which is my alert area.

In Jerusalem (and other cities in Israel) there are alerting zones that are general (for the whole city) and more localised.

I decided to create another sensor for Jerusalem-the-whole-city. This one will create alerts that are less … dramatic … than the sensor for the sub-district.

Creating My Second Alarming Sensor

To create second (and sequential) sensors you need to call an “add_sensor” service using Developer Tools.

Here’s the sample data provided by the integration:

service: oref_alert.add_sensor target: {} data: name: Petah Tikva areas: פתח תקווה

All you need to do is call the service and you’ll set up your additional sensors:

Remember, again, that the alerting zones are in Hebrew. You can refer to the options in the configuration UI if you can’t remember a spelling or how a certain alerting area is denoted.

If you later decide that you don’t want those sensors, you can remove them by calling a service too.

The service for this is:

oref_alert.remove_sensor

Recommendation: Write Down Your Sensor Entities!

Finally we’re going to want to do something with the sensors that we’ve created.

My sensors are:

binary_sensor.oref_alert

Which is the default/first sensor.

And:

binary_sensor.oref_alert_all_areas

Which is the one that I created for Jerusalem (All Areas).

This is important stuff!

Besides being a big fan of backups, I’m also a huge advocate for documentation. Consider documenting the entity names of the sensors you’ve created and what they do somewhere convenient, like a Google Sheet:

Configuring Automations (Etc)

Now that we have our sensors, we can integrate them into our Home Assistant instance however we please.

I’ve put mine up on my home dashboard:

YAML (you’ll need to change the sensor values for your ones, of course):

type: entities entities: - entity: binary_sensor.oref_alert secondary_info: none name: Jerusalem (merkaz) - entity: binary_sensor.oref_alert_jerusalem_all_areas name: Jerusalem (all areas) title: Red Alerts

If you’re making a simple entity card like I did, you may wish to color the icons based on their state:

Next, I set up an automation for my alerting area (Jerusalem Center).

I need to work on this a bit, but right now it sends notifications and turns on all the lights (the idea is to a — wake anybody up and b — assist with evacuation to a safe space).

If you have RGB lights, you could set them to red to provide a visual indication about an emergency condition:

Play A Siren Through Your Devices

You may also wish to consider triggering a siren sound effect.

/home/assistant/www/soundeffects/foo

I download an mp3 and uploaded it to my instance using File Editor and then uploaded it using File Editor:

/local/soundeffects/foo

If you drop files under the /www directory they can be retrieved using /local.

Ie:

Can be recalled using:

You can use ‘Media Player’ as an action to play this on your target devices.

Don’t Skip: Testing & Validation!

Because receiving these alerts could be really critical, it’s useful to be able to test that they’re working (the same goes for your automations — you should test them also).

Very helpfully, oref_alert features a service intended exactly for this purpose.

It’s called a synthetic alert.

It can be accessed by navigating into Developer Tools -> Services -> begin typing in the ‘Service’ box for “Create Synthetic Alert”.

You can create the synthetic alerts with YAML or the UI and configure their duration.

I decided that it would be extremely useful to have quick access to this testing functionality by creating a button (to save me having to dig through the backend each time).

So I took the YAML created for my area (I chose an alert duration of 30 seconds):

service: oref_alert.synthetic_alert target: {} data: area: ירושלים - מרכז duration: 30

And with that I created a button to run the test:

And an automation that when the button is pressed, we’ll run the test:

Now I added my button card:

Now I have a little button that I can push to validate that all the components of my alerting system are working as intended:

Just remember: if you’re testing a bunch of notifications that might set off alerts for other users and sirens, give your family/neighbors an FYI!

Other Things You Can Do

This isn’t all that you can do in Home Assistant with the Red Alert integration.

Home Front Command currently recommends remaining in shelter for 10 minutes after an alert sounds because shrapnel could fall during this period. You can also create time-based alerts that trigger upon an activation in your area and send “all clear” push notifications (if another alert hasn’t been activated in the intervening period).

You can use your imagination and tailor to your specific rqeuirements.

Hope this helped!

Originally published at https://www.danielontech.com on April 4, 2024.

--

--

Daniel Rosehill
Daniel’s Tech World

Daytime: writing for other people. Nighttime: writing for me. Or the other way round. Enjoys: Linux, tech, beer, random things. https://www.danielrosehill.com