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
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:
- 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)
- 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”)
- 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.
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?
I am running 2.8.35
Maybe a stupid question but how do I edit the message and the title of the notification? Everything works great and it is very cool that a video is shown in the notification on iOS, I just want to edit the text in the notification:)
Edit: 1
Solved this by makeing an automation from the trace of the blueprint, gives me full control of all the details on the automation.
Edit 2:
Does anyone know why some video clips in the notification are several seconds (maybe 5-7) while some are just 0.5 seconds and sometimes there is only a static image?
Forgive me if this has been already asked, but I’m looking to:
-
Use the license plate data as cars come up the driveway (I have a long one) to automatically open the correct garage door based on the vehicle that has the plate.
-
If it isn’t one of my plates, then send a notification but only then.
-
Do facial recognition and link that to persons in home assistant to know if the person is home, and to not notify me if it’s one of my family.
Is any of this possible?
As I (also) prefer not opening remote access for anything unless really needed, I came up with the idea of handling motion & doorbell notifications through Home Assistant. Very happy to see others already solved this and the blueprints are great!
I do however have a an issue which I cannot really explain nor properly consistently reproduce: I sometimes simply do not get an image preview in the motion trigger notification.
This seems to happen more often when not connected to my local network, but I have setup the correct access to /api/unifiprotect/* and /api/webhook/* via Nginx Proxy Manager and can confirm it works, it just sometimes doesn’t.
If I trigger the automation manually after receiving a notification without a thumbnail, using the ID of that event in the Debug Event ID field… it does show the thumbnail!
Could if be the notification is send/received before the image was actually created and therefor not shown? Any other ideas? Would love to have this working consistently.
Thanks for the quick answer. I have done some more (mostly manual) testing and it seems that even the manual events with a static Debug Event ID will eventually trigger a notification where the image doesn’t appear (anymore):
-
Triggering a manual run with Debug Event ID while my Android phone is connected to local WiFi / VPN always results in showing the image (so far),
-
Disconnecting phone from WiFi / VPN and triggering it again (same setup) 5 minutes after also shows the image.
-
Waiting another 15 min (phone still only on 4G) to trigger once more and the image is not shown…
I now think my assumption of “my firewall/routing works” might be wrong, and the remote notifications only display the image since it is somehow still cached on the device. Only after xx minutes it tries to fetch it again and fails (maybe)?
I will look into my routing setup: I am confident I have outside access to the /api/unifiprotect/
endpoints because when accessing an image directly (remote) it returns a 401: Unauthorized
(same when accessing locally) instead of a 403 Forbidden
. I assumed this was correct, since I am accessing the url directly without being signed. This also triggers a Login attempt or request with invalid authentication from unifi.localdomain (192.168.0.1). See the log for details.
while this doesn’t appear for any of the notification requests.
I realise this might be offtopic because it might be a remote access issue. Am I missing something in the Home Assistant configuration? For instance, do I need to add certain trusted_networks
or trusted_proxies
(besides my Nginx iProxy)?
EDIT:
Testing if caching might somehow be involved was of course easy to test:
- Phone on 4G (~10 min after last connected to WiFi) only I triggered motion by standing in front of my G4 Doorbell. Resulted in a fresh notification with corresponding image.
- 40 minutes later I did the same thing (phone still on 4G only): Resulted in a fresh notification without an image.
- Triggering manually with hardcoded Device Event ID: no image (this image worked before when on WiFi)
- Connect Phone to WiFi and triggering manually again with same Device Event ID: image.
It’s either random with a pattern I just think is there, or it really just stops working ~30 minutes after the phone is disconnected from local network. Hard to say.
If it is indeed a timeout issue, is there a way to debug this? Is there a way to set a higher timeout (I assume this is managed by the receiving device, my Android phone).
Figured checking my Nginx Proxy Manager logs might clear things up:
First manual notification the image worked (just after switching from WifI to 4G, also just had Home Assistant App open).
[05/Jan/2024:20:12:37 +0100] - 200 200 - GET https REMOTE_URL"/api/unifiprotect/thumbnail/11696ee...a6f8b9/659551e...e4004c93" [Client REMOTE_IP] [Length 16532] [Gzip -] [Sent-to 192.168.0.20] "Home Assistant/2023.12.4-11898 (Android 14; Pixel 7)" "-"
An hour later, triggered another manual one, and image doesn’t work. I did not try to open the Home Assistant App at all:
[05/Jan/2024:21:13:01 +0100] - - 403 - POST REMOTE_URL "/api/webhook/c4828043d...ce3f2320fb93e" [Client REMOTE_IP] [Length 107] [Gzip 1.36] [Sent-to 192.168.0.20] "Home Assistant/2023.12.4-11898 (Android 14; Pixel 7)" "-"
2024/01/05 21:13:18 [error] 505#505: *16988 access forbidden by rule, client: REMOTE_IP, server: REMOTE_URL, request: "POST /auth/token HTTP/2.0", host: "REMOTE_URL"
[05/Jan/2024:21:13:18 +0100] - - 403 - POST REMOTE_URL "/auth/token" [Client REMOTE_IP] [Length 107] [Gzip 1.36] [Sent-to 192.168.0.20] "Home Assistant/2023.12.4-11898 (Android 14; Pixel 7)" "-"
The /api/unifiprotect/thumbnail/
path is never called (and image doesn’t show up).
So it looks like it needs the /auth/token
endpoint after a certain amount of time to refresh authentication (which is still blocked, since I only opened /api/unifiprotect/
and /api/webhook/
).
If I allow full remote access to /
it immediately starts working again:
[05/Jan/2024:21:32:25 +0100] - - 403 - POST https REMOTE_URL "/api/webhook/c4828043d142a...ce3f2320fb93e" [Client REMOTE_IP] [Length 107] [Gzip 1.36] [Sent-to 192.168.0.20] "Home Assistant/2023.12.4-11898 (Android 14; Pixel 7)" "-"
[05/Jan/2024:21:32:59 +0100] - 200 200 - POST https REMOTE_URL "/auth/token" [Client REMOTE_IP] [Length 233] [Gzip -] [Sent-to 192.168.0.20] "Home Assistant/2023.12.4-11898 (Android 14; Pixel 7)" "-"
[05/Jan/2024:21:33:00 +0100] - 200 200 - GET https REMOTE_URL "/api/unifiprotect/thumbnail/11696eec...a6f8b9/659551e...e4004c93" [Client REMOTE_IP] [Length 16532] [Gzip -] [Sent-to 192.168.0.20] "Home Assistant/2023.12.4-11898 (Android 14; Pixel 7)" "-"
Is this expected?