Unifi Protect Camera Stream

@kymnyth You can look on my GitHub, for an example. I have just updated my raw config of my lovelace to Github. Iā€™ll push the rest of the config to github in the next few hours when i return from work.

You can use this example to assist you with installing custom components for Lovelace. There will also be many posts on the forum for installing custom JavaScript.

I restarted everything tried to connect to the stream and look the logs again. there are no errors and it says itā€™s starting the stream but Iā€™m not getting any picture. Iā€™m running this on a raspberry pi, is it possible itā€™s just too underpowered to act as a proxy for the stream?

I am also running a similar setup to you. I am running all my infrastructure on another VLAN to Hasiso however I am using PFSense and Hassio is a container on an Intel NUC Gen7.

What is the controller for you Unifi camera?

Iā€™ve updated my Github with all the settings I am using.

Iā€™m running on a pi 3b.

I am using the CKG2+ with Unifi Protect. The reason I was questioning the ability of the Raspberry Pi 3 to keep up was due to the fact a direct stream works but not using the hassio as a proxy for the stream to a browser.

the only difference is the platform hassio is running on then.

Are you able to access the stream in a browser on the same subnet as the Raspberry Pi?

These are my settings when browsing the to the IP of the camera and logging in. Enable Anonymous Snapshot is required.

image

On the stream in Hassio I have Preload Stream always ticked.
image

@noodlemctwoodle My configuration is identical to yours and I did try and connect to homeassistant on the same subnet and Iā€™m still unable to see the stream. The snapshots have worked from the beginning. I appreciate your help.

I also wanted to note that I tried various resolutions / rtsp streams.

If you put your computer (Desktop/Laptop) in the same subnet as HomeAssistant can you see the camera?

Yes that is what I tried and got the same result.

Just for clarification, what is the result when you try and hit the camera from your PC when its in the same subnet as HomeAssistant?

Can you view the live stream on the Camera IP?

@noodlemctwoodle Here is a description of the testing I have done from a network/firewall perspective.

I have 2 subnets IOT and MAIN.
HASSIO is on IOT my cameras are on MAIN.
My original firewall rules drop all traffic from IOT to MAIN except specific ip address/port combinations that are required (example: access to my plex server from my tvs/shield).

Originally configured firewall rules:
Accept tcp/udp access from my HASSIO (10.8.7.7) to my cameras (10.10.10.X addresses) for snapshot access - this has worked from the beginning.
Accept tcp/udp access from my HASSIO to CKG2+/Unifi Protect (10.10.10.3:7447) - this didnā€™t allow streams

To verify it wasnā€™t a firewall rule issue I changed firewall to:
Accept all IOT tcp/udp to MAIN temporarily. - Streaming still did not work from MAIN subnet
through HASSIO, vlc access works from MAIN subnet

I changed firewall to limit a bit while continuing to test:
Accept IOT to CKG2Ā± no access to stream from MAIN network through HASSIO, vlc access still worked
Accept tcp/udp to Cameras for snapshot access - snapshots still work

I thought this may be a firewall issue so I decided to do testing from the IOT subnet. Streamed directly from camera to a computer and my nvidia shield which is on the IOT subnet works both with the firewall wide open IOT-> MAIN and locked down to only have access to the CKG2+ ports and camera ips.

As for streaming directly from camera IP. My understanding is I would have to put the camera in standalone mode which would prevent the use of unifi protect which I would prefer not to do.

@kymnyth For testing are you able to put the Raspberyy Pi into you MAIN subnet and see if the stream works?

My setup is mariginally diffeernt to your I have an Infrastructure subnet, Clients subnet and a IOT subnet.

All my UNIFI gear, Firewall, Switches, APs and UnRAID are in the Infrastructure subnet, my docker host, Shield TV and Windows PCs and any other trusted device is in the Clients subnet.

Then things I dont trust are in the IOT such as SONOFF and other unbranded Cinese systems.

I have a FIrewall rule that allows all traffic outbound from the Infrastructure subnet to the Clients subnet on any protocol.

IOT is blocked from access to the WAN and access to the Infrastructure subnet. It is only allowed to communicate to the Hassio container on specific TCP/UDP.

Ideally to troubleshoot the problem I would get all the components on the same subnet without any restrictions and see if it works. Once you have confirmed that setup works without issue you can then complicate the setup :smiley:

You should be able to get the live stream working in HomeAssistant without affecting the Unifi Protectā€¦ My protect is working flawlessly and all the cameras are manageable within both the cloud managed and locally manged instances.

Have you tried adjusting the resolution as suggested in this post

I now have the hassio rbp, my client system and the CKG2+ all on the same subnet. I switched to the lowest resolution option in unifi protect for the rtsp feed and I am still not able to get any output. :frowning:

BOO :frowning:

Are you able to ping the camera from the Raspberry PI command line? Do you get any error in the log?

Not sure what the difference is but it doesnā€™t seem to be how I am configuring the camera and stream. Instead of running on a raspberry pi I tried installing Ubuntu on an atom based mini computer and HASSIO into a docker. I only added a camera to the configuration thus far. The camera is working. There are a number of other differences as well. I will have to work my way through transferring the rest of my configuration and see if I can figure out what was causing the problem. Perhaps the pi was just under-powered.

I finally got this working but I am not sure why. I rebuilt everything on another atom based mini computer and proceeded to get it working. I will mention the differences in this configuration vs my previous which are few.

  1. The entire configuration of lovelace was done through the configuration ui vs before I used editing the ui-lovelace.yaml directly.
  2. Running on a bit more powerful piece of hardware
    Other than that, there were really no differences.
    I did notice that when accessing the camera live streams I often had to expand and contract the browser window to get it to be refresh and display. Perhaps it was working before and it just wasnā€™t refreshing properly. I did let it sit for quite a while so I doubt that is it. Hope some help can be gleaned from this by someone else.
1 Like

Fwiw, Iā€™m running hassio (now up to 0.93.2) on the pi. Both hassio and the cloud key gen2+ are on the same vlan.

The only port forwarding I did was to allow 8123 in to hassio so I could get in with my ISP-given DHCP IP and duckdns name.

I can also see the stream via the Nabu Casa / Home Assistant Cloud / Remote Control URL. I did not make any changes for this one to work.

Has anyone tried to stream the cameraā€™s over AirPlay?

My camera streams are working fine in the picture entity card, but if I stream it to the AppleTV, it just spins and spins trying to load on the AppleTV.
Doing the same action from my Foscam cameras works just fine.

There is now a custom component for UniFI Protect thanks to @briis :smiley:

1 Like