UniFi Video Compatibility

Has anyone else had luck using Unifi Video? Is there anything in the logs that might explain why this is not working?

Device tracker using Unifi and sensors from mFi work great.

Let me know if more information is needed.

Thanks!

16-09-27 18:15:07 homeassistant.components.camera: Error while setting up platform uvc
Traceback (most recent call last):
  File "/home/derick/.homeassistant/deps/uvcclient/nvr.py", line 85, in _uvc_request
    return self._uvc_request_safe(*args, **kwargs)
  File "/home/derick/.homeassistant/deps/uvcclient/nvr.py", line 107, in _uvc_request_safe
    resp = conn.getresponse()
  File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
    response.begin()
  File "/usr/lib/python3.5/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.5/http/client.py", line 266, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py", line 107, in _setup_platform
    discovery_info)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/camera/uvc.py", line 35, in setup_platform
    nvrconn = nvr.UVCRemote(addr, port, key)
  File "/home/derick/.homeassistant/deps/uvcclient/nvr.py", line 62, in __init__
    self._bootstrap = self._get_bootstrap()
  File "/home/derick/.homeassistant/deps/uvcclient/nvr.py", line 123, in _get_bootstrap
    return self._uvc_request('/api/2.0/bootstrap')['data'][0]
  File "/home/derick/.homeassistant/deps/uvcclient/nvr.py", line 87, in _uvc_request
    raise NvrError('Failed to contact NVR')
uvcclient.nvr.NvrError: Failed to contact NVR

Seems to be the same with 3.5.0-Beta1

Bummer!! I love ubnt and all of their products! HA’s support for Ubiquiti was certainly a driving factor in choosing it. I looked for the last supported Unifi Video on ubnt’s website but couldn’t find it. Needless to say HA and it’s devs are the best and I hope it will be updated soon. Thanks for reminding me to update to the latest UV beta too :slight_smile:

Any updates on this? I’m brand-new to HA and went to pull my UniFi video in cannot get it to work. Running NVR version 3.5.1. Thanks!

@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 !