UniFi Protect Blueprints

image

2 Likes

An oldie, for sure.

1 Like

Hi,

I tried implementing the Blueprint to my current setup and everything seems to be running smoothly. I get the Notification when the motion detection has fired off, but unfortunately the notification does not update with a video on my Android OnePlus device.

Does this only work for iOS or what could I be missing?

Yes, unfortunately. But I do get similar to a gif animation of the event/motion on my Pixel.

Oh okay. I just see a static photo which matches the thumbnail :frowning:

For me I sometimes got the animation, sometimes a zoomed in photo of the motion (just liek in the Unifi app) and sometimes just the ā€œnormalā€ photo, so it was a bit inconcistent for me.

Fair enough. I will let it run for a bit and see.
Thanks for the response :slight_smile:

Hi,

First Post - So be kindā€¦ lol

Iā€™ve had a flick though the forums etc and canā€™t find an answer.

Iā€™ve managed to make an automation so that when a camera picks up a motion - it then streams the live feed to 2 of my nest hubs for 30 secends. There is a delay, so usually the ā€˜liveā€™ feed that is displayed is around 30 seconds behind. Itā€™s 50/50 if I get to see what has triggered the activation.

Iā€™ve noticed that Unifi saves each type of activation as a clip (you can see these if you look at the ā€˜play mediaā€™ option.

My question is, is there a way to make home assistant play the relevant activation clip for that motion activation?

Cheers in Advance

Lee

1 Like

I would suggest checking into WebRTC Camera integration through HACS. I use this with my Unifi cameras and it is up and running the stream in 1 - 3 seconds. I also use this with Google Assitant by casting my Lovelace dashboard using the WebRTC camera card. This works very well for me but occasionally, if I stream it for a while, the feed will drop.

1 Like

Is there a guide for setting this up with unifi?

I use MSE Streams for my UniFi Cameras Webrtc often stuck in fully kiosk browser in Screensaver Mode, i didnt know why, CPU Wakelock and try other things. MSE works good, but there is a delay over 2 Seconds more between MSE and Webrtc. But good enough for me

1 Like

You could check out their GIthub page: GitHub - AlexxIT/WebRTC: Home Assistant custom component for viewing almost any camera stream in real time using WebRTC and other technologies.
Or, and Iā€™m certain there are others, you could check out @mostlychrisā€™s video: Real Time Camera Viewing using RTSPtoWeb and Glance Cards in Home Assistant. - YouTube

1 Like

First, thank you for this amazing automation! I was able to get mobile device notifications set up for smart detections and have HA notify my devices with static images and GIFs. Excellent work!

Since doing so, Iā€™ve found that each Person Detected notification sends three alerts per detection to my Android devices, all within seconds of each other. It was great confirmation that the automation works and helped me understand the behaviour under the hood, but now the constant sounds and buzzing are annoying.

It appears that each notification is replaced by a more informative notification as it is updated with a static image, and then a GIF once the recording is complete and loaded. Or it could be three separate notifications that clear the previous one out - that would explain three alerts too.

Either way, I want the automation to only alert/buzz one time per smart detection and am stuck on how to achieve it with this blueprint.

Currently my thoughts are:

  • Explore the Alert Once functionality native to HA notifications. If the behaviour works as I think it might, then adding Alert Once functionality could be the most elegant solution. It does however assume that notifications are being updated and not replaced - and to me, the alert behaviour suggests each notification is being replaced by the next. Also since it appears that every new smart detection notification erases the last one, this might mean that I only get notified by the next notification after clearing the previous one, which could cause more problems than it solves. Regardless, the blueprint would need changes to achieve this.
  • Break out each sequential notification for the same instance - initial detection, then image update, and then GIF/video - into their own notification channels somehow. Then, set individual alert preferences either as sensible defaults in the blueprint/automation itself or on each device directly. This feels more like a quick and dirty solution but Iā€™m not sure how to achieve this yet.

Iā€™m confident enough to have a crack at forking the blueprint and trying some stuff out, but this will take me many hours because Iā€™m relatively new to HA and not comfortable with the syntax and behaviours yet.

Before I dig too far, has anyone else experienced the same issue? Is there a simpler solution than what Iā€™m considering?

Thanks all for reading!

Update: I went down the rabbit hole and added the following logic to the two relevant action data locations in the automation:

# Android alert once (requires tag to be set)
alert_once: |
  {% if tag != "" %}
	true
  {% else %}
	false
  {% endif %}

In testing today, I can confirm that my phone now only buzzes once per detection, but still retains the desired behaviour of immediately alerting (notify/vibrate) first, followed by silently updating the original notification with an image and GIF afterwards. When a new detection fires, the notify/vibrate alert triggers again and replaces the old notification, so I donā€™t have to dismiss anything to be notified and alerted by the most recent detection.

Edit: itā€™s almost perfect. My phone alerts only buzz once, but my watch still buzzes twice. Better than thrice though :smiley: progress is progress!

iOS isnā€™t affected by this change at all since Alert Once is Android-only.

This is exactly what I want, and I suspect other Android users might also want this so Iā€™m going to make a PR next.


2023-06-27 update:

This morning I learned more about the behaviour of HA Android notifications (with the Alert Once changes proposed in PR #8 implemented) between my Galaxy phone and my Galaxy Watch.

As of this morning, post-Alert Once change, my phone only buzzes once instead of thrice per notification, as desired, but my watch was still buzzing twice when I expected it would only buzz once.

As it turns out, this might be related to the interaction between the Home Assistant phone app and the Home Assistant wearOS app, where each app instance may not be fully aware of the notification state of the other app. It seems the wearOS app was still receiving the notification pushed via the HA wearOS app and reflecting the notification sent to my phone.

I was able to work around this bug by creating a new notify group specifically for these notifications and removing my watch from that group.

Now, when a detection triggers a notification, both my phone and watch alert once! Perfect!

My watch still alerts because it is reflecting the notification sent to my phone like any other app would, without a wearOS companion app installed.

I would rather control this more granularly with native Android app permissions. I believe itā€™s possible to do so, because other Android/wearOS companion app combos sync their notifications and provide options to manage watch-specific notifications independently - but Home Assistant does not appear to do this yet. I hope this will be addressed in future app updates.

For me, this is problem solved. Hope this deep dive helps others using this blueprint with Android devices!

2 Likes

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?