UniFi Protect Blueprints

Filed issue #7 and submitted PR #8 for review.

@AngellusMortis would love your feedback on this one - thanks again for such a great blueprint!

Hallo all, is there a way to have notification action to point to event video?

There is no way to link to a media item: Introduction | Home Assistant Companion Docs

I guess this answers my question here? :frowning: Getting a Unifi protect video link in a notification

The Motion / Smart Detection Notifications have been nearly perfect for me since updating to the latest, however I’ve got one camera I regularly get an error in the notification sent to iOS that reads, “Failed to load attachment Response could not be serialized, input data was nil or zero length.”

Notifications from this camera work most of the time, but it happens probably once a day at least that I see this error from this camera (G4 Bullet). However, I don’t believe there’s anything wrong with my camera.

Does anyone have any ideas about what could be causing this sporadically when pushing notifications to iOS? This doesn’t happen on any of the other cameras.

In iOS I’m getting a notification with a very small thumbnail. Is it possible to change this, or, when clicked, to open HA to a Lovelace page with the event picture? Do you have an example?

I’m working on a solution to this.
To get the last event image I’m saving the url in input_text, and then I’m using this input_text as the url for a static_image in a “generic camera”, following this example for a dyamic url Template inside a Picture Entity Card - #2 by Noto
Then I’m using a picture-card connected to this generic camera in a lovelace view.
What do you think about it?

I have a question wrt to the “Motion / Smart Detection Notifications” blueprint
I DO receive notification messages but there is no snapshot/thumbnail attached. Kindly advise if this is a known issue or that I might have misunderstood the instructions :slight_smile:

Hi,

I am able to have the smart detection notification working using that blueprint provided. However, when I setup the doorbell with tts notification and response, doesn’t appear to work. What Am I doing wrong?

What Service are you using for tts.speak? I was trying to use the Nabu Casa Cloud and had to change that field to “tts.cloud_say”

[UPDATE] changed the Pull Request to support generic HA Alarm.

I’ve created additional functionality for this blueprint, to support Alarmo integration.

This pull request allows you to integrate your home alarm system through Alarmo integration. It allows to specify Alarmo entity panel and arm states that act as filters as to when to send notifications. The code respects the presence filter and works together. You can specify the presence filter and/or Alarmo entity.

This helped me to unblock several additional use cases:

  1. When I & my family are away and someone is looking after the home, it does not send us a notification every time the person is in camera fields, only if the home is armed. (previously, I had to disable automation)
  2. If the home is armed for a night, I receive notification if someone is on the territory (duplicate of the automation with presence filter off, but respecting “night arm”)
  3. When both the presence filter and Alarmo are enabled, it doesn’t send any notifications to you while you are leaving or entering the house even if an alarm is set.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Pull request link

1 Like

For me, I get the small thumbnail in the notification and if I long press this notification on iOS it’s supposed to show the video clip that triggered the alert. However, it sometimes just shows a black image instead of the video…I really wish it would just show me a larger version of the thumbnail instead.

A history of the images would be great, or at the very least, the ability to show the larger version of the thumbnail on longpress. Does anyone have any pointers on how to adjust the blueprint to do either of these?

The video clips are cool when they work, but it fails enough for me that I’d rather just have the image.

If you want to watch the live stream from the notification, I suggest using a low-res stream, which you can get using the ffmpeg (go2rtc integration) via the RTMP streams. In fact, if you wait on that black screen, eventually, it will start streaming.

Regarding the history of the images, it’s stored on your Protect app, which I would use in case you need to check on something that happened instead of relying on HA.

Great suggestion regarding the stream quality…how do you configure these push alerts from the automation to pull from the low-res stream only? Yes, the black eventually loads, but I’d like quicker alerts that are more reliable, so getting that to be low-res should be fine if I can figure it out.

All of my UniFi Protect cameras in HA are set up with High by default through the Protect integration and then a WebRTC camera pulling from the Medium RTSP stream. So which camera feed is this blueprint pulling from?

Do I have to disable the High and make it so all of my cameras only have the low stream available via the integration? I’d like the ability to still have the WebRTC camera feeds to access via my dashboards in higher resolution.

For example, you set this stream

go2rtc:
  streams:
    g4_pro_med:
      - rtspx://192.168.200.200:7441/q8fWgdupi2tXdckv 

and the camera

  g4_pro_med:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/g4_pro_med?video=copy&audio=aac

Then your automation should look something like this:

  - service: notify.mobile_app_user_iphone
    data:
      title: Notification
      message: Person detected
      data:
        image: >-
          /api/unifiprotect/thumbnail/{{ config_entry_id(trigger.entity_id)
          }}/{{ state_attr(trigger.entity_id, 'event_id') }}
        channel: Motion
        icon: mdi:cctv
        entity_id: camera.g4_pro_med
        actions:
          - action: URI
            title: Open Camera
            uri: /lovelace/cameras
          - action: DISABLE_ALARM
            title: Disable Alarm
            icon: mdi:shield-home
          - action: URI
            title: HA Security
            uri: /lovelace-security/home

I hope it helps

I noticed some lag with the med resolution as well, I didn’t try the low yet.

Thank you. How do you use this with the UniFi Protect Motion / Smart Detection Notifications blueprint from this thread? I only have the options in the automation to set the smart detection and it automatically figures out which camera to show as I understand it. Are you not using this blue print and just set it up directly as you shared here?

To clarify my original message above, I’m using the Blueprint from this thread, so I’m trying to find a way to either modify it to image only or switch it to the low res stream to avoid the black screen when long pressing on the iOS notification.

I am not using that Blueprint. I think I tried it at some point, but it is very limited for what I needed. So I have done my automation on my own. If you want to use the blueprint you just need to pick the low/med res camera instead of the regular one and stick with all the other options in the blueprint.

Just ignore my last piece of the automation config.

@AngellusMortis do you know if it’d be possible to force a lower resolution feed for the push notification videos that come from the Motion / Smart Detection Notifications blueprint?

As I shared above, this automation is awesome and used across several of my cameras. However, for some reason I regularly get a black screen when long pressing on iOS to see the feed, so I’d like to see if forcing a lower resolution stream to my device improves that performance.

I’ve already gone through the UniFi Protect integration and disabled the HIGH streams and enabled the LOW streams instead. I’m also using RTSPtoWebRTC for the feeds that are in my dashboard, but I’m assuming this automation is not using that feed source.

Am I supposed to get multiple notifications or just the last one?

Should this blueprint work with UniFi Protect 2.9.16?