Using iOS actionable notifications to launch alternate app

Hi. I’m trying to use Home Assistant to replace the terrible user experience that comes with Unifi’s Protect camera app. They’ve made a pretty good doorbell camera, but the related iOS notifications are useless. What good is a doorbell if you’ll never know someone is there?

Anyhow, I’ve finally gotten around to setting up an actionable notification that provides a useful notification sound, a live feed from the doorbell camera and an action that can open my driveway gate. This is great because it eliminates fumbling through multiple apps to accomplish the same thing. All I really need beyond that is a second action that can open the native Unifi Protect app. How does one open an app (that isn’t the HA companion app) via an Action?

Second question, getting to these actions requires a long press on the notification banner. A short press launches the companion app. For this use case, I don’t need to interact with the companion app directly. If it’s at all possible to call another another app from an action, is it also possible to replace the that same short press on the banner to call the same app? I’ve scoured the Internet and I can’t seem to find enough info to help me connect the dots on this.

Thanks!

You would need to see if you could find the iOS app url… there is no definitive list of all apps but it would be something like unifiprotectblahblah://

I have been trying to find the one for Amcrest View Pro with no luck… even some scripts exist to pull it from the app but most are outdated.

Then you would link that like you would any link and iOS should open the app… getting specific cameras in said app is a whole-nother can of worms unless you are familiar with dissecting the code of iOS apps

1 Like

A mystery! Wonderful.

Thanks for the nudge in the right direction.

Also it’s easier to test with an iOS shortcut for open url and you will know if it works for the app without modifying and resending your HA notification each time

Also after your reminder of looking for the Url I did some more googling and apparently not all apps have one… please keep me updated if you have any luck finding it…

1 Like

Found it. Luckily, Unifi has a link. I’m posting my configs here to help anyone searching for this solution down the road. Just FYI, I’m using a doorbell camera as gate sentry device, vs. some legacy keypad, telephony, or camera system.

This is what does:
Upon a Unifi Protect G4 Doorbell press, an automation is triggered to send an iOS actionable notification. The doorbell press gets you a new notification in your iOS notification center. And a long press on that notification gets you:

  • A live feed from your camera. The Unfi Protect integration is required (available via HACS). Also, you could capture an image snap if you don’t want the live feed.
  • Two actionable buttons under the camera image. One triggers another automation. In my setup, it’s opening a MyQ cover that controls a gate. The other button will launch your iOS Unifi Protect app. This is kinda important as you’ll often need to use the microphone to communicate with the probably unwanted doorbell presser.

It’s nice having these features in one view as it saves a bunch of unnecessary manual app motions. And here are the related yaml files.

configuration.yaml (this is needed to make the actions available to the HA mobile app)

ios:
  actions:
    - name: GATEBELL
      label:
        text: "Open Gate"

automations.yaml (needed for the actionable notifications, plus automations that trigger events from the notifications button press).

- id: '1625806066488'
  alias: Notification - Gate Doorbell Press
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.doorbell_gate
    to: 'on'
  condition:
  action:
  - service: notify.mobile_app_yet_another_iphone
    data:
      message: Intruder Alert!
      data:
        url: unifi-protect://
        sound: US-EN-Morgan-Freeman-Someone-Is-Arriving.wav
        entity_id: camera.gate
        actions:
        - action: GATEBELL
          title: Open Gate
        - action: PROTECT
          title: Launch Protect App
          url: unifi-protect://
  mode: single

- id: '1635694156078'
  alias: Notification - Gate Open Action
  description: Open the Gate from actionable notification
  trigger:
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: GATEBELL
  condition: []
  action:
  - device_id: 47e45379341830b6eee84fed8a31cdb9
    domain: cover
    entity_id: cover.gate
    type: open
  - service: notify.mobile_app_yet_another_iphone
    data:
      message: Gate is Opening
  mode: single

There may be other methods to do something similar, but the above is working for me.

2 Likes

Awesome glad you found it. How did you end up finding it?

On the Protect support forum, hosted by the vendor. It looks like this info has only been known for a few months. Thanks a bunch for getting me there!

I am struggling with having a camera stream in my actionable notifications since days.

it does work with a still image from my unifi camera but it doesn’t work with providing a stream.
What’s the purpose of the first line with url: unifi-protect:// ?
Or is it a placeholder for your camera stream?

Hi. The first URL statement lets a press on the actual iOS notification launch Unifi Protect instead of the default HA companion app. Under the “data” section of the automation YAML, you’ll need to point to the actual camera entity in HA to get an active feed from the camera. In my setup, I think it’s only getting 1 or 2 frames per second from the camera in this mode, so I guess it’s not exactly live. But it’s good enough to see what’s going on.

I know this is probably stating the obvious, but the Protect integration via the HACS store is needed to get this working. I wish our friends at HA would do a native integration. I only mention the integration as I suppose there are a variety of automations where you’d want to grab an image snap via a URL without the need of leveraging the the integrated entity.

Hope that helps.

I just realized that you’re using an iphone while I am trying to get this working on a Pixel Android phone. :see_no_evil:

using a still image does work:

service: notify.mobile_app_pixel_4
data:
  title: Unifi Protect Alarm
  message: motion detected by {{ trigger.id }}
  data:
    image: http://192.168.50.26/snap.jpeg
    ttl: 0
    priority: high
    importance: high
    actions:
      - action: URI
        title: HA Cams
        uri: /lovelace-security/cams
      - action: URI
        title: HA Security
        uri: /lovelace-security/home
      - action: URI
        title: Unifi Protect
        uri: app://com.ubnt.unifi.protect

trying to use the entity of this protect camera as a stream unfortunately doesn’t:

service: notify.mobile_app_pixel_4
data:
  title: Unifi Protect Alarm
  message: motion detected by {{ trigger.id }}
  data:
    entity_id: camera.livingroom
    ttl: 0
    priority: high
    importance: high
    actions:
      - action: URI
        title: HA Cams
        uri: /lovelace-security/cams
      - action: URI
        title: HA Security
        uri: /lovelace-security/home
      - action: URI
        title: Unifi Protect
        uri: app://com.ubnt.unifi.protect

maybe it’s an android limitation somehow.

P.S.: i am using the protect hacs addon

Ah. I guess that makes sense. Not really sure about HA’s notification features on Android. Related to all this, I think I saw a Protect release note somewhere that indicated Ubiquiti is monkeying with notifications in their upcoming 1.20ish release. I’m not brave enough to try a beta version, but perhaps they’ve taken a shot at implementing configurable alerts.

got a confirmation on another thread that android can’t handle streams.

do you mean the native unifi protect app?

It’s both the Protect app and the Protect system. What I’m referring to is a vague part of the release notes for the latest Protect app. We’ll probably end up with no meaningful modifications, but ohmygod do they need to make notifications better. Especially for the G4 doorbell. Otherwise, it’s a good product. Here’s the note:

https://community.ui.com/releases/UniFi-Protect-iOS-1-5-6/5693180a-00e9-441f-a7cd-1a3273febb0b

I see. Unfortunately the protect app is unusable for me. as long as they don’t add direct connect via ip address to the unifi controller. I don’t want to use their cloud service nor do I have all my devices on the same subnet.

Therefore I use my protect cams via HA directly, which does work very well.