Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for use with NVR Beta software #1

Closed
wants to merge 2 commits into from

Conversation

joshughes
Copy link

The beta NVR software has an API change where _id is used instead of uuid to connect to camera's over the api. This PR introduces the option to pass a id flag and a flag that that allows a user to specify to use the connection id vs the uuid.

After this is merged I will update the Homeassistant component configuration to allow for this flag. This will allow users like myself that use the NVR beta software to use homeassistant with our Cameras.

@@ -19,6 +19,8 @@ Hopefully this is enough to get you going::
-v, --verbose
-d, --dump
-u UUID, --uuid=UUID Camera UUID
-i id, --id=id Camera Connection id
-c, --connect_with_id Connect using id instead of UUID (NVR Beta API)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to detect the newer version somehow and always use the id if necessary, right? Do you know if the older versions allow use of the _id value in place of the uuid? If so, it might be easier to just do that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api path is the same... 2.0 I can try to pull more data out of the api but I am just capturing data with chrome since the api is not documented.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but that's just the major version. Although they definitely shouldn't be breaking something like this without a major bump, it would be quite a deal to change the version in the url.

Looks like this path will get you lots of data:

http://192.168.1.10:7080/api/2.0/bootstrap

Which includes data[0]['systemInfo'] which has a version in it. Let's just check to see if that is >= 3.2 and use the ID in that case, okay? We should probably be polling that on first connect anyway and exposing it to the client user anyway. Let me know if you want me to do that bit first and I'll be glad to so you can build on that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a look... There is also changes in the login and getsnapshot for cameras... I have login working but have not figured out the right api call to get snapshot from the camera. The fallback of getting a snapshot through the nvr still works, but the homeassistant module does not have that fallback implemented.

So I will try to find some similar information from the cameras themselves to determine how we should log in and take snapshots.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'm surprised, hadn't really seen a change in the login/snapshot API through multiple major revs of the software. I hope this isn't a sign of more breaking changes to come :/

@kk7ds
Copy link
Collaborator

kk7ds commented Mar 6, 2016

Hi, thanks for working on this. I don't run the beta so I didn't know this was broken. I have no idea why ubiquiti would change this.. I wonder if it's a known bug and will be fixed for the release.. have you seen any documentation indicating that this is intentional?

Also, I'd really like to avoid having to tell the client whether to use the id or the uuid. If they expose some software version then we should check that, or if all else fails, probe somehow by trying a uuid and then an id or something like that.

Thanks!

@joshughes
Copy link
Author

Since its beta and this is an unpublished api... I assume that they are not worried about breaking clients.

Anyway, with the bootstrap information we can make the client intelligent on when to use uuid and when to use id. I have also figured out the api/1.1 for cameras to get snapshots. I will look into updating settings as well. It will probably take me till next weekend to get enough time to do it all, but the good news is that I hacked it all together tonight and Homeassistant is working!

@kk7ds
Copy link
Collaborator

kk7ds commented Mar 7, 2016

Cool, thanks!

@dcrypt3d
Copy link

dcrypt3d commented Jun 3, 2016

Using a UVC Micro I see this:
16-06-02 23:17:52 homeassistant.components.camera: Error while setting up platform uvc File "$PATH/lib/python3.5/site-packages/homeassistant/components/camera/uvc.py", line 50, in setup_platform cameras = [camera for camera in cameras File "$PATH/lib/python3.5/site-packages/homeassistant/components/camera/uvc.py", line 51, in <listcomp> if 'airCam' not in nvrconn.get_camera(camera['uuid'])['model']] File "$PATH/lib/python3.5/site-packages/uvcclient/nvr.py", line 217, in get_camera return self._uvc_request('/api/2.0/camera/%s' % connection_id)['data'][0]

kk7ds added a commit that referenced this pull request Jun 4, 2016
This makes us resolve names to the 'id' instead of 'uuid' for newer
versions of the NVR server software.

Fixes most of #1
@kk7ds kk7ds closed this in e722954 Jun 4, 2016
@kk7ds
Copy link
Collaborator

kk7ds commented Jun 4, 2016

Hi guys, I just pushed a couple changes that should fix things. I just upgraded my camera server to 3.2.x and made the changes necessary for things to keep working. If you find other stuff, please open another issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants