# UniFi Protect vehicle detected notifications on your phone > Get a push notification when a UniFi Protect camera spots a vehicle, with a button to open the event clip. - Company: UniFi Protect (https://www.justpush.io/recipes/unifi) - Event: `vehicle` (Vehicle) - Tags: Smart home, Security - Install: https://studio.justpush.io/recipes/unifi/vehicle-detected - Web page: https://www.justpush.io/recipes/unifi/vehicle-detected ## 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 Vehicle 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 vehicle trigger, so it stays quiet if you point other alarms at the same integration. 12. Give the alarm a descriptive name, like "Driveway Vehicle". 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 → vehicle detected // Fires when a UniFi Protect camera's smart detection spots a vehicle. // // Set this up as an Alarm Manager alarm in UniFi Protect with a "Vehicle" // 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 vehicles. const vehicle = alarm.triggers.find((trigger) => trigger?.key === "vehicle") if (!vehicle) { console.log(`Ignoring "${alarm.name ?? "unknown"}" alarm — no vehicle trigger`) return null } const seenAt = localTime(vehicle.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. "Driveway Vehicle"). 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: "🚗 Vehicle detected", message: (seenAt ? `Spotted at ${seenAt}` : "A vehicle was spotted") + where, topic: "UniFi Protect", priority: 0, // Normal — cars come and go; this is informational // sound: "incoming", // any of Studio's sounds, e.g. incoming, bugle, siren buttons: eventLink ? [{ cta: "View clip", url: eventLink }] : [], } } ``` ## UniFi Protect vehicle webhook payload (sample) ```json { "alarm": { "name": "Driveway Vehicle", "sources": [], "triggers": [ { "key": "vehicle", "device": "FAKE_MAC", "eventId": "testEventId", "timestamp": 1783505319282 } ], "eventPath": "/protect/events/event/testEventId", "conditions": [ { "condition": { "type": "is", "source": "vehicle" } } ], "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.