Delete me 10char

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?

(post deleted by author)

Yeah I understand this issue is unrelated to these blueprints or how the Unifi Protect Integration works. Glad I got some steps closer to a solution and will look in other places for more information. Thanks!

Hi Angellus. I’ve been using your integration and blueprints since briiis was the origin author. Appreciate your hard work on maintaining this. I was originally on android and the Smart Detections bp has always worked like a charm with the initial picture and then video clips notification updates. I switched to IOS a couple of months ago and my notifications have never been as reliable. A lot of times the initial message does not include the the image. I would usually get the video clip shortly after but even that would occasionally just show a black box. I never had the time to start troubleshooting till this weekend.

I did a reimport of your bp to ensure I had the latest version and started to test manually with the debug event id (didn’t even know that was an option till I updated the bp). Coincidentally I did my testing using the MacBook instead of my iPhone and noticed there was an “error” in the thumbnail for the image notification (never noticed this on my iPhone). When expanded it gave a “Failed to load attachment” error. While searching the forum I saw that another bp as having similar issues and they seemed to found a fix or workaround. I’m not sure if this is the exact same thing I’m experiencing (as well as others who have mentioned similar issues with this bp).

Please see link to forum post below that hopefully is helpful. A few post down they post a potential fix with an update. I also added a pic of the error as seen in MacOs.

1 Like

I think this is similar to the sporadic issues I’ve seen and reported as well. While the camera feed is nice when it works, it often either takes too long to load or fails to load.

Does anyone know what in the BP would specifically need to change to grab the snapshot instead of the video for iOS? It seems like if I really want to see the video, I’ll click through to launch the actual camera.

What are you using as the trigger for this automation to ensure that the eventID is availble when you need it ? I get NONE as the eventID somtimes ?

So, to make sure I’m not missing something, expected behavior with having multiple cameras setup like this would mean that any one triggering will prevent notifications from the others during the cooldown, yeah?

Also, for anyone else looking, you can having the “open camera” action take you directly to the stream. After struggling a bit with figuring this out, I decided to RTFM and found you can just set the URL to the entity ID.

The More Info panel of an entity using entityId:<entity_ID> where <entity_id> is replaced with the entity ID you wish to view. Ex: entityId:sun.sun.

For example, if you set it to

camera.doorbell_high_resolution_channel

It’ll open the app and redirect you to the stream.

I’m now seeing this “failed to load attachment Response could not be serialized, input data was nil or zero length” error in the image/video in the push notifications from my G5 Pro fairly consistently.

Has anyone figured out what this is and how to resolve it?

Thanks for creating this and I’m brand new to home assistant.

I got the blueprint working to send me a push notification of the license plate data and timestamp to my phone.

Now, I’d like to send that data to a zapier webhook

I found instructions on using the restful integration. If I manually test the restful service, the webhook is triggered. But how do I get HA to pass the message from the blue print to restful everytime the blueprint runs?

Sorry for missing something obvious

Thanks.