unifi-protect: Use connectionHost to support cameras distributed between stacked nvrs #1128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When utilizing stacked NVRs with the
unifi-protect
plugin, we encountered an issue where the plugin failed to generate correct RTSP stream URLs for cameras connected to the secondary NVR. This limitation stemmed from the fact that only the primary IP was available and configurable in the UI. As a result, we could only access camera streams from the primary NVR, rendering those on the secondary NVR inaccessible.Action
To address this issue, we revised the approach to generating RTSP stream URLs. Instead of statically utilizing the primary NVR's IP, we integrated the use of the connectionHost property, which is returned from the API for each camera. The
connectionHost
property contains the specific IP address of the host NVR that a camera is connected to, ensuring that the correct IP address is used for generating the RTSP stream URL, whether the camera is on the primary or secondary NVR.Result
This modification results in a successful and consistent generation of RTSP stream URLs for all cameras across both primary and secondary NVRs.
Other Solutions Considered
We evaluated an alternative solution that involved manually adding the secondary IP during the setup process. However, we decided against this approach as it compromises the abstraction of NVR stacking. It would also introduce additional configuration steps, increasing the potential for user errors and complicating the setup process.
cc: @shyawnkarim