Skip to content

reolink: add HTTPS option for the NVR/Hub api.cgi connection#1

Open
SnoElement wants to merge 1 commit into
mainfrom
reolink-https-api-option
Open

reolink: add HTTPS option for the NVR/Hub api.cgi connection#1
SnoElement wants to merge 1 commit into
mainfrom
reolink-https-api-option

Conversation

@SnoElement

Copy link
Copy Markdown
Owner

Problem

The NVR/Hub API client (nvr/api.ts) hardcodes http:// for every api.cgi request. The Reolink Home Hub and Home Hub Pro only serve their API over HTTPS, so the plugin cannot talk to them at all — login, GetEvents polling, snapshots, PTZ, etc. all fail against http://host:443.

Change

  • Add a per-device "Use HTTPS" toggle (Advanced), surfaced on both the NVR add-device form (main.ts) and the NVR device settings (nvr/nvr.ts).
  • Thread it through ReolinkNvrClient as a constructor flag that selects the URL scheme (this.protocol); all api.cgi URLs use it.
  • Make the port scheme-aware: the port field (renamed "API Port") now has no hard default; when unset it falls back to 443 for HTTPS, 80 for HTTP. An explicit override always wins.

Defaults to HTTP, so existing cameras and NVRs are unaffected (backward compatible).

Validation

Tested on a real Reolink Home Hub Pro (firmware v3.3.0.466): with "Use HTTPS" on, the hub connects, GetHubInfo/GetDevicesInfo succeed, and there are zero EPROTO/wrong-version SSL errors (which is what http://host:443 produced before this change).

Note

The standalone-camera path (reolink-api.ts, probe.ts) hardcodes http:// the same way; this PR only covers the NVR/Hub path. The standalone path could get the same treatment as a follow-up.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an opt-in HTTPS control-path for the Reolink NVR/Home Hub api.cgi client so HTTPS-only hubs (Home Hub / Home Hub Pro) can be managed successfully while preserving HTTP defaults for existing devices.

Changes:

  • Adds an Advanced per-device “Use HTTPS” toggle and threads it into ReolinkNvrClient to select the URL scheme for api.cgi requests.
  • Makes the API port scheme-aware when unset (80 for HTTP, 443 for HTTPS), while honoring explicit overrides.
  • Updates NVR add-device flow to persist the new HTTPS setting and to default the port based on the chosen scheme.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
plugins/reolink/src/nvr/nvr.ts Adds “Use HTTPS” device setting and makes API port default depend on scheme when unset.
plugins/reolink/src/nvr/api.ts Introduces protocol selection and switches api.cgi URL construction to use it.
plugins/reolink/src/main.ts Adds HTTPS toggle to the add-device flow and applies scheme-aware default port for NVR creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/reolink/src/main.ts Outdated
Comment thread plugins/reolink/src/main.ts
Comment thread plugins/reolink/src/nvr/api.ts
Comment thread plugins/reolink/src/nvr/api.ts Outdated
Comment thread plugins/reolink/src/nvr/nvr.ts
@SnoElement SnoElement force-pushed the reolink-https-api-option branch from f6f6363 to 00b7436 Compare June 21, 2026 11:33
The NVR/Hub client hardcodes http:// for every api.cgi request. The Reolink
Home Hub and Home Hub Pro only serve their API over HTTPS, so the plugin
cannot connect to them (login, GetEvents polling, snapshots, PTZ, etc. all
fail against http://host:443).

Add a per-device "Use HTTPS" toggle (Advanced), surfaced both on the NVR
add-device form and on the NVR device settings, and thread it through
ReolinkNvrClient as a constructor flag that selects the URL scheme. Defaults
to HTTP, so existing cameras and NVRs are unaffected; the add-device port
default switches to 443 when HTTPS is selected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@SnoElement SnoElement force-pushed the reolink-https-api-option branch from 00b7436 to 7d19232 Compare June 21, 2026 18:49
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.

2 participants