Custom Component: Unifi Protect

I was going to add one, but there is no way to reboot the console from within Protect. It is something only UniFi OS can do, which the integration does not interact with in any way at the moment.

There is no concept of an “event thumbnail” inside of the HA integration at the moment. Are you pulling the snapshot from the camera entity? That does not really guarantee the person is in the frame, especially is they are walking perpendicularly to the camera.

Yes I think I am :slight_smile:

service: camera.snapshot
data:
  entity_id: camera.g4_altanen
  filename: /media/cameras/G4-Altanen/{{ time_stamp }}.png
entity_id: camera.g4_altanen

Is there a better way of doing this because I’m a bit fed up wth getting notifications that is missing the person that triggered the snapshot :slight_smile:

1 Like

Hi all

im having a tough time figuring this out. according to the HA documentation:

Media Player - If your camera has a speaker, you will get a media player entity that allows you to play audio to your camera’s speaker. Any audio file URI that is playable by FFmpeg will be able to be played to your speaker, including via the TTS Say Service.

I can play with not problem using tts services but when I try to play any audio file (mp3, wav etc…checked they play with ffmpeg btw) I get a call service error:

Failed to call service media_player play_media. Unknown error

anyone else encounter this?

here is the call service yaml im trying to launch

service: media_player.play_media
data:
  media_content_type: music
  media_content_id: /local/warning_multi_lang.mp3
target:
  entity_id: media_player.2_front_door_speaker

best

Z

The most likely issue is you do not have your firewall setup correctly. HA needs to be able to connect to the cameras directly for talkback.

You can also enable debug logging to get the full ffmpeg command that is run to test it and figure out why it is not working.

Kind of, but not very well. There is a select that controls the recording mode, so you can have it set to Never and change it to Always with an automation, but that does not let you get the footage before the motion detection like Protect does.

Generally, it is better just to set Motion Zones within Protect to exclude the road, so the cars do not trigger it. That way Protect can still add the configured amount of padding before and after the motion.

The problem is they do not document their APIs. It is all HTTP, so I am sure there is a way to post to the camera to tell it motion has triggered. I have just had zero interest or need in reverse engineering the camera APIs. Only the Protect APIs.

Stupid question but where do I change the login credentials for the Unifi account that is being used for this custom component?

You know this is no longer a Custom Component? It is now part of HA Core.
With the Core version, if your credentials no longer are accepted the Integration will prompt you to reconfigure it, and here you can enter Username/Password.

1 Like

Hi folks. I’m being asked to reauth my account a few times a week.

When I get up in the morning, I see all my UNifi Protect entities are unknown, and when I head into Integrations, I’m prompted to re-enter the credentials I use for HA on my UDMP.

It’s a local access administrator account, with all cameras selected. Once I’ve re-entered my credential the integration is fine. I’ve tried a reboot of HA and the UDMP, but sadly no change. I’m not on early access, and the protect app is up to date - in fact, it updated last night.

Am I missing a trick, or shall I enable debug logs and raise a bug request?

Thanks … :grinning:

I’m seeing the exact same thing, for the first few says I was re-authenticating but by accident noticed an HA reboot cleated it, for a day or two.

What’s weird is it’s not authentication request I have, sometimes it’s as many as 7 or 8 all showing at the same time.

It is always a good idea to enable the Debug, and see if anything shows up in the log. And if it does, raise an issue on Home Assistant.

With that said, I found that when HA looses contact to UniFi Protect it will prompt for credentials, so maybe check your Protect devices to see if anything shows up in the log there also.

The re-auth issue seems to have started in the 2.1.1 versions. Sometimes Protect just replies with an unauthorized status code even though it is not because you are unauthorized.

We have two work-in-progress fixes to improve it. One to let you reload the integration without re-auth (frontend bug) so you do not need to re-enter your credentials or restart HA to fix it. And another to wait until multiple unauthorized errors occur in a row before triggering the re-auth flow.

1 Like

Hmm, today mine popped up but the reauth isn’t working, nor is a reboot of HA. I even just tried to update my protect to 2.1.1 today to see if that would help. The local account works but it’s not working with HA.

ok, here’s an update, my local admin account can access and authenticate, but my old custom one that I only give full access to protect wont authenticate. However I decided to make another account and it works, so I think my shared account for homebridge and homeassistant for some reason started fighting each other.

Not even 24 hours of updating to 2.1.1, Reauth popped up. Looking forward to a partial, workaround fix.

Now, knowing Ubiquiti, I wouldn’t be surprised they are up to their shenanigans and games.

Off topic, just thought most of you would get a chuckle having probably experienced similar things, this is the second time that I’m aware this has happened.
Birdman confirmed:
telegram-cloud-photo-size-1-5103022434935745093-m

1 Like

Hey,

Anyone had luck using the WebRTC with Ubiquiti Cameras (Unifi Protect)?

I still have some delay issues when casting to my Nest devices and the delay on my Dashboard is about 5-7 seconds. No issues with my network, so I thought I would give the integration a shot.

I can also read that it would be possible to do live streaming to my Nvidia Shields through this, which would be very nice.

Currently it seems that there have been some issues after the latest release, but I’m not sure that is my current issue, because when I try to add the address when setting it up, then I don’t know what address I should use. What do I need to enter from my Ubiquiti setup in order to get the cameras added?

image

Sorry if I should have asked in the WebRTC thread.

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