Setting up NVR-based Reolink cameras

Summary: Is there a way to setup NVR-based Reolink cameras with the IP Camera Binding to handle camera-based motion detection events (i.e., without FFMPEG)?

Desired configuration: The Reolink motion detection is pretty good; however, the builtin push notifications are excessive and don’t provide a thumbnail of the motion frame for easy spot checking. So, I’d like to pipe the Reolink motion detection events into Openhab and use a rule to manage the frequency of push notifications and include a still (of gif) of the motion event. I’d prefer not to use FFMPEG as I’m currently running Openhab on a RaspberryPi 3 and am already pushing the limits on its capabilities.

**Details **
I’ve been digging for a while now and can’t seem to setup the IpCamera binding quite the way I’d like. Here is the hardware that I have.

  • Reolink RLN8-410 NVR
  • Reolink RLC-810A cameras
  • Reolink RLC-820A cameras
    I’ve seen in the primary IP Camera community thread and some of the other threads that people have been able to successfully setup Reolink cameras via the ONVIF option. However, I believe these are cameras directly hooked up to the network, rather than through an NVR. It also isn’t clear to me if camera-based motion detection events is possible.

I’ve found documentation regarding the Reolink API here and here. I’ve been able to hard code the snapshot URL thus far and that seems to work: http:///api.cgi?cmd=Snap&channel=0&rs=ABCDEFG&user=&password=. There is also a GetMdState command that provides the status on motion detection for a particular camera channel on the NVR: http:///api.cgi?cmd=GetMdState&channel=0&rs=ABCDEFG&user=&password=. Is there a way to integrate this into the current IP Camera binding?

Thoughts? Thanks!

As you mention, this works for others when talking directly to the camera and its possible your NVR is blocking this. NVRs usually create a private network for the cameras and usually that is the desired effect, to isolate them from the rest of the network to improve security. Hikvision make a range of NVRs that allow you to directly talk to each camera on separate ports whilst they are behind the NVR, not sure if Reolink have that feature, but its not a common feature in other brands and why people consider using Hikvision over others. Also a reason why some like to roll their own NVR with their own hardware and software.

There are other ways to do this, one of them is if the camera supports FTP uploads when motion occurs is the ‘ftp upload’ binding. It can throw a motion switch when the ftp site gets the upload from the camera.

Great news that it has an API and that you have tested it to work. I took a quick look and it does not look very hard to add this to the binding. Are you able to add it? The documentation is lacking IMHO as it does not fully explain the token creation and renewing process, nor what the channel numbers are…
ie does channel=0 work on a stand alone camera? what does it show when on the NVR? Is channel 1 the first or second channel on the NVR as its common to start counting at 0 and not 1.

Thanks for all of the input.

As you mention, this works for others when talking directly to the camera and its possible your NVR is blocking this. NVRs usually create a private network for the cameras and usually that is the desired effect, to isolate them from the rest of the network to improve security.

I’m reasonably certain that is the case here (and is why I went with the NVR setup). The only way to communicate with the cameras appears to be through the CGI API.

There are other ways to do this, one of them is if the camera supports FTP uploads when motion occurs is the ‘ftp upload’ binding. It can throw a motion switch when the ftp site gets the upload from the camera.

I’ll have to look into this more and there appears to be an FTP uploads option when motion occurs https://support.reolink.com/hc/en-us/articles/360004083873. This is probably the easiest solution for now. I’ll look into this a little more and report back.

Great news that it has an API and that you have tested it to work. I took a quick look and it does not look very hard to add this to the binding. Are you able to add it?

I’ll poke around into the binding and see if I can figure out how to add something. I haven’t done any binding work in openhab, and it has been a while since I coded in Java, so it might take me a little while to piece something together.

The documentation is lacking IMHO as it does not fully explain the token creation and renewing process

Agreed. It does appear that Reolink is trying to improve this, but it is still rather cryptic and lacking at times. The token doesn’t appear to be required. I’ve been able to interact with the cameras by sending a username and password in the URL. This isn’t ideal from a security standpoint, but works for now.

nor what the channel numbers are… ie does channel=0 work on a stand alone camera? what does it show when on the NVR? Is channel 1 the first or second channel on the NVR as its common to start counting at 0 and not 1.

The channel number is just the port that the camera is hooked up to on the NVR. I’ve seen references to NVR channel in the IP documentation, but it doesn’t appear when I try to define the thing through the UI.

If your keen to take it on, I can do 80% of the work needed in a few hours saving you from needing to learn how the binding works. What I can not do easily is test since I do not have any Reolink here. What you should do is take a look at how FOSCAM has been implemented, as they use a polling method where the binding has to keep asking the camera over and over if any events have occurred. Foscam also uses the user/pass in plain text in the GET requests.

See this file here to see if your java comes easily when reading this:

openhab-addons/FoscamHandler.java at main · openhab/openhab-addons (github.com)

Only some of the brands have that show up, Its easy to create a new thing type called reolink and have the ability to specify a nvr channel in the setup for the thing. That’s the sort of thing I can do in a few minutes to save you learning. I created the binding in a way that allows most of what is done for a brand to be in a single file to make it easy for people to read and fix bugs without knowing the full binding and it makes it easier for me to maintain.

If your keen to take it on, I can do 80% of the work needed in a few hours saving you from needing to learn how the binding works.

I’m willing to take it on. The FOSCAM code seems pretty straight forward (although those are often famous last words). Seems like we can keep most of the structure and just update the CGI syntax and result parsing. I’ll start working through the developers guide. While I’m working on that, do you want to take an initial stab the new Reolink handler class? I can then use that as a base line to troubleshoot/debug.

hi, i’m using Reolink too. Camera, not NVR.
per onvif I get only the motion detection signal.
Somewhere in the internet i found a list for the api commands and i use the http binding for polling a person alarm state.

IPofCam/api.cgi?cmd=GetAiState&channel=0&user=aaaa&password=aaa
JSONPATH:$.[0].value.people.alarm_state

Reolink E1 Outdoor cam api output:

[
   {
      "cmd" : "GetAiState",
      "code" : 0,
      "value" : {
         "channel" : 0,
         "face" : {
            "alarm_state" : 0,
            "support" : 0
         },
         "people" : {
            "alarm_state" : 0,
            "support" : 1
         },
         "vehicle" : {
            "alarm_state" : 0,
            "support" : 1
         }
      }
   }
]

Maybe this is helping you…
Greets

Thanks for the info. I hadn’t thought to look into using the HTTP binding. I think I’m going to continue to pursue the IP Camera Binding option right now as I’m interested in some of its built in features, but might use this as a fall back.

At what rate do you have to poll to make sure you don’t miss an event?

Every 3 seconds.
It’s enough for me…
I use both… Ptz preset is working fine with ipcamera binding… And the snapshot and video stream…
I use the http binding just for person detection.

For anyone that comes across this thread, I can confirm that you can use the HTTP Binding to poll the AI state with an NVR system. To access different cameras on the NVR, you simply need to change the channel reference accordingly: IPofCam/api.cgi?cmd=GetAiState&channel=0&user=aaaa&password=aaa. I should note that, you need to have the firmware v3.0.0.148_21101146 or above installed on your NVR. Prior to that, the AI option doesn’t work through the API.

One of the downsides of this approach, is that you username and password are stored in raw format within the Thing definition. There is likely a way around this, but I haven’t delved too deep into it.

@DieterK has added that functionality to the IP Camera binding and we are just waiting for a PR to be done, you can read his post here on it…

Onvif camera error message - Add-ons / Bindings - openHAB Community

It is far better to use the ONVIF methods as they are event based and the events get pushed to the binding, where how your doing it with the http binding is polling and not as good as event based methods. If you place the binding into DEBUG level logging it will tell you if the camera is reporting events that the binding does not have implemented and if you post this info, it can be added very easily.

@azureshammer Let me know when your able to compile the code and create a jar. I think the best way forward would be to use ONVIF if the dvr channel is 0, and for numbers above this, it could switch to polling so people get the best of both worlds. But this requires someone to test that actually has a camera. I would not be surprised if the API polling has added benefits and extra features. For example with Dahua and Hikvision if you get a Line Crossed alarm, the API can tell you which direction the line was crossed so you know if someone if walking towards or away from your home.

Hi Skinah,

good news!

Reolink managed to fix the issue and i was able to positivly verify the behaviour (i.e. camera is stable now).

Up to now there’s no offical build yet, i received the new FW via email.

I raised a question on when they plan to release new FW, will share any update as soon as available.

Not so good, i’m bit behind on what i stated earlier, i.e. sharing the changes at the weekend …

Will do my very best to come up with those next weekend.

Best regards,

Dieter

1 Like

I don’t know anything about reolink but I have noticed that there is a working solution for home assistant, might give you some ideas on how to integrate it.