IpCamera: New IP Camera Binding

Hi @fruggy83,

I can also confirm that it works with the Reolink cam RLC-420.

I encountered the same issue as you and would be interested in the solution.

The price for the Reolink RLC-410 looks very reasonable. I am going to get one and give it a try.

Having not owned an IP Cam before, I would like to ask a rather naive question. Using @matt1ā€™s add-on, and the ONVIF API, would the camera continue to function if I disable outgoing communication on its IP at the router? I.e. if the cloud portion goes down, or if I would like to totally disable the cloud, does it still function well with the add-on?

Thanks,

@fruggy83 great to hear you have worked this out and also the binding is building for other people. A couple of notes to discuss before doing a PR which is more than welcomeā€¦

I have a number of changes still to be uploaded after some testing so best to wait until this is updated on githubā€¦

How best to only apply this to Reolink cameras and not all ONVIF cameras as this appears to be a unique ā€˜work aroundā€™ this brand needs.

  1. Do we create a new thing type for REOLINK which kind of seems overkill if it does not have an API and the only thing that works is a picture updating and no alarms or other features.

  2. Do we make it auto detect the snapshot URL and if it matches the Reolink url it then turns on the workaround feature? I seem to like this one the best.

  3. Does over riding the URL solve the issue? See How to Capture Live JPEG Image of Reolink Cameras via Web Browsers
    It may only need this workaround for ONVIF and not the usual URL for snapshots.

  4. Another option?

I had a quick look at the price of Reolink, Amcrest are a similar price for similar specs and have an API available as they are made by Dahua. Hikvision and Dahua cameras are also not much more so be sure to look around at what brands are already supported by the binding.

Anyone know if this binding will work with H.VIEW cameras?

I believe this is a ONVIF cam. But I cant really figure, if it will work, specially the motion detection, if it will be a trigger switch in Openhab?

Skinah Matt,1, thank you for posting this,
I have followed your instructions and had my camera working, I have camera module that I took off my old DELL laptop and it works fine, I would like to see my cam feed outside my local network, I tried Myopenhab.org and nothing is showing!
Please guide me to what should I do to make it work, using RPI3 with the latest OH2
Iā€™m new to all of this bty and appreciate any help

Thanks @matt1. Based on @fruggy83ā€™s feedback, I thought motion alarm is working for the Reolink as well. Looks like this might not be the case; it would be a deal breaker for me then. I will return the Reolink and look at the Amcrest. You are correct that the price difference isnā€™t that much.

@matt1

great to hear you have worked this out and also the binding is building for other people

Had some minor troubles with building your binding against the current OH2.4 version but could solve them. Most of them had to do with the source code checks like copyright comments.

How best to only apply this to Reolink cameras and not all ONVIF cameras as this appears to be a unique ā€˜work aroundā€™ this brand needs.

I have introduced a new config parameter through which I can define if the binding has to query the SnapshotUri before getting the current image. So this solution should not have a great impact on other cams

Does over riding the URL solve the issue?

Thanks a lot for this hint. I will try this on weekend and come back with my results. Maybe the workaround is not needed anymore.

Best regards
Daniel

@yfaway sorry for this misunderstanding. My workaround just solves the problem that the Snapshot image is not updated anymore after the initialization of the binding.

However I am currently implementing a dummy ftp server into the binding. As most cams are able to store the video on a ftp server after they detected a motion, I know that whenever the ftp server gets pinged a motion was detected. This works quite well for motion detection. However I am still fiddling around with storing the video.
@matt1 what are you thinking about this approach? Maybe this could be more generalized. For example another cam I own is able to do a simple http get after detecting a motion.

Best regards
Daniel

@fruggy83
That method is already implemented in a binding which I believe is called ā€œFTP Uploadā€.
FTP Upload - Bindings | openHAB

Whilst it is great to have options I personally prefer a method that works even when your internet fails and goes offline. Also a camera should be easy to setup for any level of user, should be as easy as tell openhab what brand and it should work or even better auto detect your cameras which is possible as onvif has this outlined in the spec.

I installed the binding, it says the thing is online, but i donā€™t get picture or image.
Iā€™m new to openhab, if somecould point me in the right directionā€¦

Thank you

New Build 26-10-2018 now available with these changes:

  • HIKVISION New feature added for fielddetection alarm @JSamijn requested this.
  • Dahua now has new URL for checking alarm via a stream, needs testing and a trace level log output if it does not workā€¦ @Kristo requested this.

Thanks @matt1!, I will test during Weekend

After testign:

  1. Status of Enable/Disable the Motion Alarm Switch not updated
    request is NOK :
    2018-10-26 20:12:14.570 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.2.11, URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion

Should be:

/cgi-bin/configManager.cgi?action=getConfig&name=MotionDetect

Answer is very long but we are interested in first line:

table.MotionDetect[0].Enable=true
table.MotionDetect[0].EventHandler.AlarmOut=1
table.MotionDetect[0].EventHandler.AlarmOutChannels[0]=0
table.MotionDetect[0].EventHandler.AlarmOutEnable=false
table.MotionDetect[0].EventHandler.AlarmOutLatch=10
table.MotionDetect[0].EventHandler.BeepEnable=false

or in case of turned off:

table.MotionDetect[0].Enable=false

  1. Enable/Disable the Motion Alarm working OK
  2. Motion Alarm status not working.

Log:

URL:/cgi-bin/eventManager.cgi?action=attach&codes=[All]

2018-10-26 20:09:29.873 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/eventManager.cgi?action=attach&codes=[All]
2018-10-26 20:09:29.875 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Packet back from camera is not matching anything new in here

2018-10-26 20:09:45.022 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - !!!! Channel was found idle for more than 15 seconds so closing it down
2018-10-26 20:09:45.025 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent
2018-10-26 20:09:45.026 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:6 	URL:/cgi-bin/eventManager.cgi?action=attach&codes=[All]
2018-10-26 20:09:45.027 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/eventManager.cgi?action=attach&codes=[All]

In Edge browser i was able to record flowing data :slight_smile:
with code:

/cgi-bin/eventManager.cgi?action=attach&codes=[All][&keepalive=20]

HTTP/1.1 200 OK
    Cache-Control: no-cache
    Pragma: no-cache
    Expires: Thu, 01 Dec 2099 16:00:00 GMT
    Connection: Keep-Alive
    Content-Type: multipart/x-mixed-replace; boundary=myboundary

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:37
Code=VideoMotion;action=Start;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

--myboundary
Content-Type: text/plain
Content-Length:33
Code=NewFile;action=Pulse;index=0

tested alams :slight_smile:
Motion:

Code=VideoMotion;action=Start;index=0
Code=VideoMotion;action=Stop;index=0

Alarm input 0

Code=AlarmLocal;action=Start;index=0
Code=AlarmLocal;action=Stop;index=0

Alarm input 1

Code=AlarmLocal;action=Start;index=1
Code=AlarmLocal;action=Stop;index=1

Other not tested but nice to have them working:

CrossLineDetection: tripwire event
CrossRegionDetection: intrusion event
ParkingDetection: parking detection event
FaceDetection: face detect event
AudioMutation: intensity change

@matt1 iā€™m counting on you :slight_smile:

@Kristo
Do you have a github account? I prefer these talks to go into a ticket for future reference instead of getting lost in a thread like this oneā€¦

Your find that it works in edge browser was great as I was only seeing a black screen in chrome, now that I can see the data stream I found this URL works best on my Amcrest due to your stopping the stream after 20 seconds.

http://192.168.1.50/cgi-bin/eventManager.cgi?action=attach&codes=[All][&keepalive]

Talk about a non consistant API format as to where to place square brackets, makes for a long trial and error process even when this is outlined in the AMCREST API which is available to the public with no NDA needed. Luckily this is working on my Amcrest (made by Dahua) as it will make the next stage possible as I now need to make framework changes to see the data in the binding as whatever stops it from being seen in browsers like chrome is stopping my binding from seeing it the same way HIKVISION streams are showing up.

I will make the changes for the other features and do another build so you can test the other stuff whilst I play with getting the stream data working. You confirmed your camera is doing the same as mine as I was not seeing a white square I thought yours may be different. Edge browser was a good find.

New Build 27-10-2018 has following changes:

  • Dahua alarm now seems to working via the stream method. @Kristo Needs testing as it may need manual setup to work ie checking the days of the week the alarm is enabled on in cameras own control panel.
  • Dahua now has better support behind NVRs.
  • Dahua now does not poll if the alarms are enable or disabled, you need to use the REFRESH command to trigger this as it only happens on an openhab restart or first connect to the camera.

@matt1
After quick testing.

  1. Status of Enable/Disable the Motion Alarm Switch - Working after restart of openhab status changed

  2. Motion Alarm status not working.

I found only this in log

2018-10-27 11:32:28.371 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - !!!! Channel was found idle for more than 15 seconds so closing it down
2018-10-27 11:32:28.374 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent
2018-10-27 11:32:28.376 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-10-27 11:32:28.378 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent last part of the message.Bytes=0
2018-10-27 11:32:28.379 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:2 	URL:/cgi-bin/eventManager.cgi?action=attach&codes=[All][&keepalive]
2018-10-27 11:32:28.381 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/eventManager.cgi?action=attach&codes=[All][&keepalive]
2018-10-27 11:32:28.496 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 566, cap: 566/566, unwrapped: PooledUnsafeDirectByteBuf(ridx: 566, widx: 566, cap: 1024)), decoderResult: success)
2018-10-27 11:32:28.498 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0
2018-10-27 11:32:28.501 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 483

Hi @matt1,

I dont have github, but i can create shortly,
Let me know where to put tickets

Raise an issue ticket here
https://github.com/Skinah/IpCamera/issues

Also /cgi-bin/eventManager.cgi?action=attach&codes=[All]
that URL does stay alive so going with that one next build.

OK just added ticked for Dahua Output control
I will add leter also one for Zoom in non PTZ cameras
should i put separate for Event menager functions?