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

[ipcamera] Add Reolink API support #14728

Merged
merged 35 commits into from
May 13, 2023
Merged

[ipcamera] Add Reolink API support #14728

merged 35 commits into from
May 13, 2023

Conversation

Skinah
Copy link
Contributor

@Skinah Skinah commented Apr 1, 2023

These changes add Reolink support which a lot of users have requested and been testing and giving feedback already in the forum here:

https://community.openhab.org/t/adding-reolink-api-to-the-ipcamera-binding-beta-testers-needed/142202

This pull request will automatically be built and available under the following links if anyone wants to test:
https://openhab.jfrog.io/ui/native/libs-pullrequest-local/org/openhab/addons/bundles/

https://openhab.jfrog.io/ui/native/libs-pullrequest-local/org/openhab/addons/bundles/org.openhab.binding.ipcamera/4.0.0-SNAPSHOT/org.openhab.binding.ipcamera-4.0.0-SNAPSHOT.jar

Signed-off-by: Matthew Skinner matt@pcmus.com

Skinah added 23 commits March 22, 2023 19:44
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
@Skinah Skinah added the enhancement An enhancement or new feature for an existing add-on label Apr 1, 2023
Skinah added 2 commits April 1, 2023 12:42
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/adding-reolink-api-to-the-ipcamera-binding-beta-testers-needed/142202/66

Skinah added 2 commits April 2, 2023 15:55
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/adding-reolink-api-to-the-ipcamera-binding-beta-testers-needed/142202/1

Skinah added 2 commits April 17, 2023 21:50
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

Thanks for the enhancements. Only a few minor comments from my side.

The hardcoded JSON/URL approach seems quite error-prone, but I understand this is the current approach in this binding. However, it would be worth to consider refactoring this when doing more work on this binding.

Skinah and others added 4 commits May 8, 2023 21:39
Co-authored-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
…/binding/ipcamera/internal/handler/IpCameraHandler.java

Co-authored-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
@Skinah
Copy link
Contributor Author

Skinah commented May 8, 2023

@jlaur Thank you for your suggestions which should be all addressed now.... I do not understand your hard coding comment above, perhaps because I am self taught and still learning basic coding concepts. The URL's are defined in an API and the binding is implementing the API as documented. If you could elaborate on what the potential issue is or the better way? Do you mean using constants to define the urls in the one place/file, in case the API changes in the future to reduce the workload changing many lines of code?

@jlaur
Copy link
Contributor

jlaur commented May 8, 2023

I do not understand your hard coding comment above, perhaps because I am self taught and still learning basic coding concepts

What I'm referring to is code like this:

ipCameraHandler.sendHttpPOST("/api.cgi?cmd=AudioAlarmPlay" + ipCameraHandler.reolinkAuth,
    "[{\"cmd\": \"AudioAlarmPlay\", \"param\": {\"alarm_mode\": \"manul\", \"manual_switch\": 1, \"channel\": "
    + ipCameraHandler.cameraConfig.getNvrChannel() + " }}]");

While it will probably work perfectly well, it's hard to read, and for the same reason trivial bugs (like syntax errors) could easily be introduced unnoticed. If this JSON would be serialized from a DTO, it would be easier to read and the risk of syntax errors would be eliminated.

Skinah added 2 commits May 11, 2023 19:31
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matthew Skinner <matt@pcmus.com>
@Skinah
Copy link
Contributor Author

Skinah commented May 13, 2023

Thank you for the suggestions and I believe I have completed all requested changes.

Regarding your non requested suggestion of DTO, I did a quick look and do not wish to go that route, but someone in future can do it. Considering that I do not own one of these brands to do any testing with, I do not have the time when this basic method is going to suit 99% of people just fine and most of it is already tested by end users.

There are at least 2 users of Reolink cameras that can code in Java that are waiting for this to be merged so they can take over and move it forward so it is possible someone will make that change that is able to do tests on real hardware.

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

LGTM

@jlaur jlaur merged commit 01add04 into openhab:main May 13, 2023
@jlaur jlaur added this to the 4.0 milestone May 13, 2023
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/ipcamera-binding-cant-connect-to-d-link-dcs-8627lh/145438/9

tb4jc pushed a commit to tb4jc/openhab-addons that referenced this pull request Jun 19, 2023
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Thomas Burri <thomas.burri@alstomgroup.com>
matchews pushed a commit to matchews/openhab-addons that referenced this pull request Aug 9, 2023
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Matt Myers <mmyers75@icloud.com>
@Skinah Skinah deleted the camera branch November 21, 2023 10:54
austvik pushed a commit to austvik/openhab-addons that referenced this pull request Mar 27, 2024
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants