Custom Component: Unifi Protect

Thanks to @briis and everyone else who contributed to this project! Been using it since it was a custom component, and finally got a G4 doorbell (happened to see it in stock for a few hours earlier this week).

Has anyone figured out how to cast a lovelace view to a Google Cast device with the doorbell feed in the view?

I’m replacing a Nest doorbell, which had a nice feature of displaying the camera feed on my Google Hub along with some buttons for canned responses like “No one is able to come to the door right now”. I found that very useful when I’m in a meeting for work and the neighborhood kids come by ringing the doorbell multiple times looking for my kids :slight_smile: I’d like to do that with the UniFi doorbell and HA.

I can get the camera feed to display on my Google Cast devices just fine with the play_media service - something like this:

service: media_player.play_media
target:
  entity_id: media_player.kitchen_display
data:
  media_content_id: media-source://camera/camera.g4_doorbell_high
  media_content_type: image/jpeg
metadata:
  title: Doorbell High
  thumbnail: /api/camera_proxy/camera.g4_doorbell_high
  media_class: video
  children_media_class: null
  navigateIds:
    - {}
    - media_content_type: app
      media_content_id: media-source://camera

but that’s just the camera feed, nothing else.

I made a lovelace dashboard called doorbell-response that has the camera feed and some buttons/toggles/info that would be useful when the doorbell rings.

The camera card in that view is set up like this:

  - type: picture-entity
    show_state: true
    show_name: true
    camera_view: live
    entity: sensor.g4_doorbell_last_motion_detected
    image: https://demo.home-assistant.io/stub_config/bedroom.png
    camera_image: camera.g4_doorbell_high
    name: Last Motion

and the doorbell ring automation calls the cast.show_lovelace_view service like this:

service: cast.show_lovelace_view
data:
  entity_id: media_player.kitchen_display
  dashboard_path: lovelace-main
  view_path: front-doorbell-response

Locally via a web browser on a PC or the iOS app on my phone, the lovelace view displays just fine. However, when it’s cast to a Google Hub, the camera feed doesn’t work - there’s just a stock placeholder image.

I’m guessing it has something to do with the cast service using the external HA URL due to Google’s HTTPS requirements and that perhaps the camera feed isn’t getting sent correctly? I’m using the Nabu Casa setup for HA cloud features, so my external URL is through that service.

Any ideas on how to get the dashboard with a camera feed to work on a Cast device?

1 Like

Apologize if asked and answered, but there are too many response to filter through.

Is there a way to take a snapshot from a protect camera and display through the HA app on Android or iPhone when not connected to the local network?

How did you add your Unifi cameras through the integration? I don’t know what I should enter when setting up the WebRTC integration?

1 Like

The most beautiful answer of all: It depends!
The username seems to be the same for all: ubnt

If you have a standalone camera its: ubnt/ubnt
If you have adopted the camera into a Video Server the password is located under the Protect app and then Settings and there should be a password setting (sorry dont own a uvds)
Same thing if you own a UDM (Pro)
If you have a UDR then it’s under the Protect app → Settings and look for the Recovery Code

You need to run a seperate ‘server’/docker container to convert the rtsp to webrtc. See https://github.com/deepch/RTSPtoWeb. You need to enter the server ip and port in the setup of the integration.

I tried it, but the provided rtsps streams from the unifi protect integration are not supported.
The provided URL is: rtsps://192.168.1.xx:7441/xxxxxxxxxxxxxxx?enableSrtp
When I manually change the URL to: rtsps://192.168.1.xx:7441/xxxxxxxxxxxxxxx the video is loading. However the WebRTC integration always updates the URL when changing views.

@AngellusMortis Is it possibel to remove the ?enableSrtp from the rtsps URL’s?

1 Like

No. We do not in any way support RTSPtoWeb to for UniFi Protect cameras. We also recommend against the HACS custom component for WebRTC using RTSPtoWeb as it downloads binaries from the Internet without verification.

RTSPtoWeb will never be supported by us directly for UniFi Protect in any capacity as it is a not a viable solution for playing UniFi Protect video feeds (there is never any audio since WebRTC does not support AAC and RTSPtoWeb cannot transcode). The recommended approach is to use LL-HLS or make a PR to pyunifiprotect to add support for the native Protect WebRTC.

If you want to insist on using for RTSPtoWeb, see the dedicated thread for it. People have gotten UniFi Protect cameras working in there.

Has there been any thought on this integration being discovered as a speaker? These could be used in various spots of the house to alerts through them.

Also, big thanks to the team for the Protect integration! Leveraging several rules to notify movement with the cameras. Something that UI took away. Now, 5+ rules per camera. Huge thanks again.

Everything that UniFi Protect exposes for the Smart Chime is already in Home Assistant. There is no interface to interact with the speaker directly.

Updated to version 2022.8 of Home Assistant and suddenly the “auto” camera update for my Unifi Protect Cameras wont work. The snapshot image is not displayed any more in the cards. Instead these are grayed out like the picture shown below.

Nothing is changed on the UniFi Protect side and anonymous snapshot is still enabled on each camera.

Yes I have the same problem. Up until now this integration actually worked with cloud accounts even though it said it didn’t. Unfortunatly that has changed. Deleting the integration and trying to readd it resolves in an “unkown error occurred”. This is within a local network with a local user.

Edit: the Unifi OS Update to 2.5.11 solved this issue for me… among a few other issues in Protect.

Please provide logs. Otherwise, there is nothing that can really be done to help either of you.

You may also consider making a Github Issue

Forgive me if I’ve missed this in the long thread.
Is there a way of going from a smart detection trigger and linking to the relevant thumbnail or video clip.
I see that the video clips are accessible from the media library, but can’t see how you would get the ids from an event.

Ideally I want it to work how I had it setup briefly in the early days of this as a custom component.

so…

  1. Smart detection occurs - I send a notification to telegram with a snapshot of the camera.
  2. When the event finishes - I update the noticification with the thumbnail of the event and provide a link to view the video of the event.

Is this possible ?

What’s the easiest way of achieving it ?

Thanks

Short answer is no.

I have tried to add the feature on 3 separate occasions and the core devs keep telling me different things that need to be implemented. So, I have given up on trying to implement it. Until they decide to overhaul notifications, you will not be able to resolve media items for entities.

1 Like

Thanks for letting me know.
At least I can stop trying.

I have a G4 Doorbell, not Pro - within Protect it notifies me when a package is detected, but does not flag this to the smart detect entity in HA.

E.g. yesterday my doorbell advised that a person was detected, then a package notification was sent. But the entity (sensor.front_doorbell_detected_object) only went from none, through person, back to none.
Are there plans for the integration to capture package detection? Note again, NOT a G4 Doorbell Pro, just the G4 Doorbell.

1 Like

Thanks for all the hard work on this everyone. I recently migrated from Frigate to Unifi Protect and can say it’s much more accurate/reliable for my deployment and love how well it integrates into Home Assistant. However, I really miss the custom frigate-hass-card to display my camera feed and events. I’m curious if anyone is aware of another custom card or a custom lovelace view that could provide a similar experience.

Thanks again!

Why not continue to use the frigate card? I use it to show my protect cameras on my dashboard (using the rtsp feed that unifi provides).

I’ve thought about that, but actually have better results with Unifi’s smart detections than I did with Frigate’s. I’m assuming you are using Frigate for it’s smart detections and Unifi’s at the same time then? Do you ever have a situation in which one or the other doesn’t detect when it should have?

1 Like

I am not currently and my frigate docker container has been shut down for some time now. I simply like the frigate card layout and functionality so I use it for my dashboard camera views. Of course I don’t get the snapshot/clip views etc. If that is what you are looking for then I am not aware of any cards that would give that all that functionality in one package.

Just an fyi, the Protect section under Media does allow you to view a lot of “clips” so there is potential of a specialized card being created in the future to tap into that. There would just need to be someone with the desire and frontend skills to put it together. Maybe one day. @AngellusMortis your thoughts?

The clip gallery is what I’m looking for specifically; the Frigate card is very polished and feature-rich. I’m using the webrtc-card by AlexxIT currently for the camera view.

1 Like