UniFi Video Compatibility

@danodemano

I just use a generic platform to connect my UVCs to HA.

The main contributer to all of the Ubiquiti components has not been active on the HA repository for a while. It might be worth reaching out to him.


Here is the code if you see anything that might fix it.
https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/camera/uvc.py
They should probably remove the component for now.

Can you go into more details as to how you are doing this?

I’ll page through the code later and see if I can find a fix. Thanks much for the reply!

Log into your NVR and go to “My Account”

Turn the API access on and it will provide a key.

You will need to click on each camera and get this…

To add it to HA do this

  - platform: generic
    still_image_url: http://X.X.X.X:7080/api/2.0/snapshot/camera/51234738972884ae0e88937300f4?force=true&apiKey=Pq15555UU8XXXYYY
    name: Backyard

You will need to change the ip, rtsp, API, and potentially the port.

The RTSP is between camera/…?

The API is after &apiKey=

You can also log into each camera and allow “snaps” Then you can bring in the snap.jpeg files…

Both seem to work well.

This has some good info.

This is for the anonymous snap

2 Likes

Awesome, thanks so much! I’m still going to see if I can get the UniFi component to work but at least this is something for the mean time. Really appreciate it!

1 Like

No problem! Let me know if you find something!

1 Like

@PtP

Well I don’t have an answer but I’m at least a bit closer to something. I think that the NVR isn’t giving the password to the cameras correctly (or perhaps at all). I modified the camera.py file that’s part of the uvcclient and manually defined the password:

After restarting the service my camera’s came up as expected in the dashboard!

SO all that being said I’ve searched and searched and cannot find anything from Ubiquiti (shocking) that says what this change might be. My only real though at this point (even though it’s a crappy one) is add an additional configuration option for the camera.uvc config to have the camera password listed and use rather than trying to get it from the NVR. Any thoughts?

1 Like

Since it wouldn’t let me add a second image here are the cameras on the dashboard after manually setting the password:

1 Like

@danodemano interesting find…

I have just started up with HA and was hoping to get my cameras in the system but ran into the issue of…
“16-11-17 07:13:03 homeassistant.components.camera.uvc: Unable to login to camera”
being spewed all over my logs.

I checked the store.py (/.homeassistant/deps/uvcclient)in my system but there is no such code (running on PI3 Fabrick installer) - was that the right location?

Thanks for tracking this down… hopefully we can get this working!
pjo

@pjo

Yeah that’s the right location, and where I found it on my system:

Interesting, I have the same issue as @pjo. The file is there but the code is different.
No def login function…

Well now that I think about it there is a login for the NVR but the cameras typically have a different PW when you are using SSH to them. You are probably on to something here. I wish I knew python better! :frowning:
NVR/Camera PW syncing has had a few kinks lately…

@PtP I know enough Python to be dangerous but that’s about it. You can set a password for all the cameras though in the NVR. I have mine the same as my admin login but really it could be changed to anything. While I hate storing passwords in plain-text config files I cannot think of a better option. It’s really either that or enable anonymous viewing of the images. For me that’s not a big deal, they have their own VLAN with no Internet access, but I imagine it could be a problem for some.

@frelev Not sure then. It was at the very bottom of the file for me under the UVCCameraClientV320 class.

@danodemano

I do not see that part of the code either.

Can you post your .yaml setup for the NVR?

It is in the camera.py

class UVCCameraClientV320(UVCCameraClient):
    @property
    def snapshot_url(self):
        return '/snap.jpeg'

    def login(self):
        headers = {'Content-Type': 'application/json'}
        data = json.dumps({'username': self._username,
                           'password': self._password})
        resp = self._safe_request('POST', '/api/1.1/login', data,
                                  headers=headers)
        if resp.status != 200:
            raise CameraAuthError('Failed to login: %s' % resp.reason)
        headers = dict(resp.getheaders())
        try:
            self._cookie = headers['Set-Cookie']
        except KeyError:
            self._cookie = headers['set-cookie']
2 Likes

@PtP Sorry, it was getting late when I posted that and my brain was shot from troubleshooting. You are correct, it was the camera.py.

No worries @danodemano !

So now the real question…what’s the permanent fix?

Still trying to get you quick fix to work. Did you define a port in your config?

This is my config

  - platform: uvc
    nvr: 192.169.1.1
    port: 7443
    key: XXXXXXXXX

The quick fix is not working for me either.

It´s hammering the camera so I get:
“Authentication locked because of too many unsuccessful attempts. Please try again in five minutes.”

I´m running 3.5.1 of UVC

I did not:

camera:
platform: uvc
nvr: 192.168.9.44
key: XXXXXXX