Unifi Protect Camera Stream

I think the “Enable Anonymous Snapshot” settng in the camera’s config webpage is what got me going. Did you check that box?

Thanks for the response. Yes I did, which is why I think the snapshot images are visible.

To provide some additional information, I have a Ubiquiti USG firewall. My cameras are on a seperate vlan from the hassio install. I opened what I thought were the necessary ports but to verify this wasn’t the problem I temporarily allowed all traffic between the vlans while I tested it. Is there any port forwarding or weird stuff I would need to do from the outside to get this stream to show up in hassio?

In addition, this is the output in my log file after enabling debug:

2019-05-21 14:46:50 INFO (MainThread) [homeassistant.components.stream] Started stream: rtsp://10.10.10.3:7447/L7i0GDYu4aGkY14S
2019-05-21 14:46:50 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.548391964968] Sending {'id': 18, 'type': 'result', 'success': True, 'result': {'url': '/api/hls/9fe413c4bb684af9605d9fa19605cf340c405a96a27e5f45c5fa4890fde26303/playlist.m3u8'}}
2019-05-21 14:46:51 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/hls/9fe413c4bb684af9605d9fa19605cf340c405a96a27e5f45c5fa4890fde26303/playlist.m3u8 to 10.10.10.104 (auth: False)
2019-05-21 14:46:52 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.548391964968] Received {'type': 'camera/stream', 'entity_id': 'camera.frontporch', 'id': 19}
2019-05-21 14:46:52 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.548391964968] Sending {'id': 19, 'type': 'result', 'success': True, 'result': {'url': '/api/hls/9fe413c4bb684af9605d9fa19605cf340c405a96a27e5f45c5fa4890fde26303/playlist.m3u8'}}
2019-05-21 14:46:52 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/hls/9fe413c4bb684af9605d9fa19605cf340c405a96a27e5f45c5fa4890fde26303/playlist.m3u8 to 10.10.10.104 (auth: False)
2019-05-21 14:46:54 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.548391964968] Received {'type': 'config/entity_registry/get', 'entity_id': 'camera.frontporch', 'id': 20}
2019-05-21 14:46:54 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.548391964968] Sending {'id': 20, 'type': 'result', 'success': False, 'error': {'code': 'not_found', 'message': 'Entity not found'}}
2019-05-21 14:46:54 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.548391964968] Received {'type': 'camera/stream', 'entity_id': 'camera.frontporch', 'id': 21}
2019-05-21 14:46:54 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.548391964968] Sending {'id': 21, 'type': 'result', 'success': True, 'result': {'url': '/api/hls/9fe413c4bb684af9605d9fa19605cf340c405a96a27e5f45c5fa4890fde26303/playlist.m3u8'}}
2019-05-21 14:46:54 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/hls/9fe413c4bb684af9605d9fa19605cf340c405a96a27e5f45c5fa4890fde26303/playlist.m3u8 to 10.10.10.104 (auth: False)

Anybody have an idea on what thte entity not found error could be when trying to send the stream? To be clear I have tested the rtsp stream in vlc and it works fine.

The log shows an incorrect entity id. I’m not sure where it’s getting that from.

camera.frontporch

It should have an underscore in it like in the card config. You could look in the dev tools and see what it shows there.

Responded in the original thread

@gohassgo I changed the name of the camera from
Front Porch
to
Front Porch
trying to see if the space makes a difference. I also changed the entity name to camera.front_porch or camera.frontporch accordingly and this did not change anything. I also verified I can stream from a Nvidia shield on the same vlan as my hassio raspberry pi from the camera on the other vlan. This verified it is not a firewall issue.

@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