# UniFi Protect glass break heard notifications on your phone > Get a Highest-priority push notification when a UniFi Protect camera hears glass breaking, with a button to open the event clip. - Company: UniFi Protect (https://www.justpush.io/recipes/unifi) - Event: `alrmGlassBreak` (Glass Break) - Tags: Smart home, Security - Install: https://studio.justpush.io/recipes/unifi/glass-break - Web page: https://www.justpush.io/recipes/unifi/glass-break ## Setup 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 Glass Break and select the camera(s) it should watch. 4. Under actions, add a Webhook with method POST and paste your webhook URL (shown in Studio after install)?tz=Europe/Amsterdam as the URL, using your own time zone. 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 (shown in Studio after install)?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 glass break trigger, so it stays quiet if you point other alarms at the same integration. 12. Give the alarm a descriptive name, like "Living Room Glass". 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. ## Code Studio calls `handleRequest(request)` with the incoming webhook (`{ method, headers, body, query, raw }`) and sends the message object it returns. Returning `null` sends nothing. ```js // UniFi Protect → glass break heard // Fires when a UniFi Protect camera's audio detection hears glass breaking. // // Set this up as an Alarm Manager alarm in UniFi Protect with the "Glass Break" // audio trigger and a Webhook action pointing at your JustPush Studio integration URL. // UniFi only sends a UTC timestamp, not your console's time zone, so the time zone comes // from the webhook URL: ?tz=Europe/Amsterdam. Without one (or with an unknown name) the // time is left out rather than shown in the server's time zone. function localTime(timestamp, request) { const timeZone = typeof request.query?.tz === "string" ? request.query.tz.trim() : "" if (!timestamp || !timeZone) return null try { return new Date(timestamp).toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit", timeZone }) } catch { return null // not a time zone name this runtime knows } } function handleRequest(request) { const alarm = (request.body || {}).alarm // Guard: ignore anything that isn't a UniFi Protect alarm payload. if (!alarm || !Array.isArray(alarm.triggers)) { console.log("Not a UniFi Protect alarm payload — skipping") return null } // Alarm Manager sends every alarm to the same webhook, so only handle glass breaks. const glass = alarm.triggers.find((trigger) => trigger?.key === "alrmGlassBreak") if (!glass) { console.log(`Ignoring "${alarm.name ?? "unknown"}" alarm — no glass break trigger`) return null } const heardAt = localTime(glass.timestamp, request) // The payload only carries the camera's MAC, so the alarm name is the most // readable hint of where this happened (e.g. "Living Room Glass"). const where = alarm.name ? ` — ${alarm.name}` : "" // The local link only resolves on your LAN, and only when the event was recorded. const eventLink = alarm.eventLocalLink return { title: "💥 Glass break detected", message: (heardAt ? `Breaking glass heard at ${heardAt}` : "A camera heard breaking glass") + where, topic: "UniFi Protect", priority: 2, // Highest — possible break-in happening right now // sound: "siren", // any of Studio's sounds, e.g. incoming, bugle, siren buttons: eventLink ? [{ cta: "View clip", url: eventLink }] : [], } } ``` ## UniFi Protect alrmGlassBreak webhook payload (sample) ```json { "alarm": { "name": "Living Room Glass", "sources": [], "triggers": [ { "key": "alrmGlassBreak", "device": "FAKE_MAC", "eventId": "testEventId", "timestamp": 1783505319282 } ], "eventPath": "/protect/events/event/testEventId", "conditions": [ { "condition": { "type": "is", "source": "alrmGlassBreak" } } ], "eventLocalLink": "https://192.168.1.1/protect/events/event/testEventId" }, "timestamp": 1783505319286 } ``` ## FAQ ### 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.