UniFi Protect smoke or CO alarm heard notifications on your phone.

Get a Highest-priority push notification when a UniFi Protect camera hears a smoke or carbon monoxide alarm going off, with a button to open the event clip.

How it works

Three steps to your first push

STEP 01

Install the recipe

One click in Studio gives you a personal webhook URL.

STEP 02

Paste your URL into UniFi Protect

Add it as a webhook for Smoke Alarm.

STEP 03

Get a push on your phone

With the text, sound and buttons from the recipe.

Setup

How to set up the UniFi Protect smoke alarm webhook

  1. Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL.
  2. In UniFi Protect, go to Settings > Alarm Manager and click Add Alarm.
  3. Set the trigger to Smoke Alarm and select the camera(s) it should watch.
  4. Under actions, add a Webhook with method POST and paste your webhook URL?tz=Europe/Amsterdam as the URL, using your own time zone.https://••••••••/•••••••• your personal URL, shown after install
  5. Save the alarm, then press Test to send a sample event.
  6. Add your time zone to the webhook URL so the notification shows the local time:
  7. ```
  8. your webhook URL?tz=Europe/Amsterdam
  9. ```
  10. Use your own [time zone name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). UniFi only sends a UTC timestamp; without `tz`, the time is left out of the message.
  11. Alarm Manager sends every alarm to the same webhook shape. This recipe only reacts when the alarm contains a smoke or CO alarm trigger, so it stays quiet if you point other alarms at the same integration.
  12. Give the alarm a descriptive name, like "Kitchen Smoke". The payload only identifies the camera by its MAC address, so the alarm name is what tells you where it happened.
  13. The **View clip** button uses `eventLocalLink`, which only resolves on your home network (and shows a certificate warning). Away from home it won't load.
The code

What runs when the webhook arrives

Studio calls handleRequest(request) with the incoming webhook and sends the message it returns. It's yours after install; change anything.

transform.js
1// UniFi Protect → smoke / CO alarm heard
2// Fires when a UniFi Protect camera's audio detection hears a smoke alarm or a
3// carbon monoxide alarm sounding.
4//
5// Set this up as an Alarm Manager alarm in UniFi Protect with the "Smoke Alarm"
6// (and optionally "CO Alarm") audio trigger and a Webhook action pointing at your
7// JustPush Studio integration URL.
8
9// Audio detection trigger keys, and what to call them in the notification.
10const ALARM_SOUNDS = {
11 alrmSmoke: "Smoke alarm",
12 alrmCmonx: "CO alarm",
13}
14
15// UniFi only sends a UTC timestamp, not your console's time zone, so the time zone comes
16// from the webhook URL: ?tz=Europe/Amsterdam. Without one (or with an unknown name) the
17// time is left out rather than shown in the server's time zone.
18function localTime(timestamp, request) {
19 const timeZone = typeof request.query?.tz === "string" ? request.query.tz.trim() : ""
20
21 if (!timestamp || !timeZone) return null
22
23 try {
24 return new Date(timestamp).toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit", timeZone })
25 } catch {
26 return null // not a time zone name this runtime knows
27 }
28}
29
30function handleRequest(request) {
31 const alarm = (request.body || {}).alarm
32
33 // Guard: ignore anything that isn't a UniFi Protect alarm payload.
34 if (!alarm || !Array.isArray(alarm.triggers)) {
35 console.log("Not a UniFi Protect alarm payload — skipping")
36 return null
37 }
38
39 // Alarm Manager sends every alarm to the same webhook, so only handle smoke / CO.
40 const heard = alarm.triggers.find((trigger) =>
41 Object.prototype.hasOwnProperty.call(ALARM_SOUNDS, trigger?.key)
42 )
43
44 if (!heard) {
45 console.log(`Ignoring "${alarm.name ?? "unknown"}" alarm — no smoke or CO trigger`)
46 return null
47 }
48
49 const sound = ALARM_SOUNDS[heard.key]
50
51 const heardAt = localTime(heard.timestamp, request)
52
53 // The payload only carries the camera's MAC, so the alarm name is the most
54 // readable hint of where this happened (e.g. "Kitchen Smoke").
55 const where = alarm.name ? ` — ${alarm.name}` : ""
56
57 // The local link only resolves on your LAN, and only when the event was recorded.
58 const eventLink = alarm.eventLocalLink
59
60 return {
61 title: `🚨 ${sound} sounding`,
62 message: (heardAt ? `Heard at ${heardAt}` : `A camera heard a ${sound.toLowerCase()}`) + where,
63 topic: "UniFi Protect",
64 priority: 2, // Highest — a life-safety alarm is going off at home
65 // sound: "siren", // any of Studio's sounds, e.g. incoming, bugle, siren
66 buttons: eventLink ? [{ cta: "View clip", url: eventLink }] : [],
67 }
68}
Payload

The UniFi Protect alrmSmoke webhook

This is what UniFi Protect sends to your URL for smoke alarm. It is a sample, trimmed to the fields recipes use.

alrmSmoke · sample.json
1{
2 "alarm": {
3 "name": "Kitchen Smoke",
4 "sources": [],
5 "triggers": [
6 {
7 "key": "alrmSmoke",
8 "device": "FAKE_MAC",
9 "eventId": "testEventId",
10 "timestamp": 1783505319282
11 }
12 ],
13 "eventPath": "/protect/events/event/testEventId",
14 "conditions": [
15 {
16 "condition": {
17 "type": "is",
18 "source": "alrmSmoke"
19 }
20 }
21 ],
22 "eventLocalLink": "https://192.168.1.1/protect/events/event/testEventId"
23 },
24 "timestamp": 1783505319286
25}
FAQ

UniFi Protect smoke or CO alarm heard notifications: questions

Does this work on iPhone and Android?

Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification.

Do I need to write code?

No. Install the recipe in Studio, paste your webhook URL into UniFi Protect and you are done. The code is there if you want to change the text, the sound or the buttons.

Can I change what the notification says?

Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save.

What does it cost?

JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.

Ready when you are

UniFi Protect on your phone in two minutes.

Install the recipe, paste one URL, done. Free for 30 days, no credit card required.