IpCamera: New IP Camera Binding

New build 21-05-2018 has following new features:

  • New INSTAR thing type and a lot of code that needs testing and feedback. Need debug log output with all the controls moved, once I have this I can finish off the features. If something does not work try it in a browser to help me out. @japhias this build should get you a lot closer to having some features working.
  • New changes for HIKVISION. Need the test button moved and check if the motion alarm state changes when you have movement and none. I may have gotten this working but before making it automatic I need the test button moved to see if it works. @ArsalanAlli and @toroid this build will interest you.
  • Changes for all cameras that use onvif. Added the ability to handle bad replies from the camera that may have stopped cameras coming online. Removed a lot of onvif queries to speed up detection and reduce chances of a conflict occurring.

It is grayed out because it is a read only switch, you can not move it manually, only the alarm will move it. Currently you need to move the test switch to tell the binding to check if the alarm is going off. I do this with untested code in case of any issues so you can still use the latest binding by simply not moving the button.

Motion alarm state changes not work in this build.

I noticed the following change in the behavior of binding.
He began to read and correctly display the inclusion of the motion detector in the camera settings.

When you change the setting switch, the camera setting does not change and returns to the same position.

I copied the newest snapshot to my addons folder.
And did the stup in the PaperUI:

And I get this log entries, but no connection:

2018-05-21 22:30:00.173 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.178.110:80
2018-05-21 22:30:00.190 [ERROR] [l.internal.messaging.saaj.client.p2p] - SAAJ0008: Bad Response; Not Found
2018-05-21 22:30:00.191 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - The camera connection had a SOAP error, this may indicate your camera does not fully ONVIF or is an older version. Not to worry, we will still try and connect. Camera at IP:192.168.178.110, fault was com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (404Not Found
2018-05-21 22:30:00.192 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Camera failed to report a valid Snaphot URL, try over-riding the Snapshot URL auto detection by entering a known URL.

I overrided the auto-detection url and after that I got a successful connection:

http://IP-Address:Port/tmpfs/snap.jpg?usr=admin&pwd=instar

Now I’m able to show a jpg in the control menu, what other features can I test?

I would say you need to enable onvif (appears to be disabled by default) and set the onvif port to ‘8080’ in the binding as that is the default port for INSTAR which I’ll change that for the next build.

First enable the DEBUG log output as described in the first post of this thread using Karaf console. Then start moving the controls and watch what appears in the openhab.log file.
The threshold control should send values as does enabling and disabling the motion control.

Can you send me some debug log output please when the camera has movement and also when it has no movement? This should hopefully be an easy fix once I have some logs.

Great thanks for confirming this new change works as intended. This needed to work before I can write the 2 new features I mention next…

That is normal as I have not done the coding to get that working yet. It needs 2 new features added to the binding first before I can get it working. I just need time.

hey matt,
i just tested your new release for motion detection of Hikvision camera and i am getting unauthorized access errors. below is the debug log output of binding.
and my PaperUI is not updating motion Enable/Disable button based on “Motion detection Feature” in camera as it is updating for @toroid

10:59:02.845 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 401 Unauthorized
Date: Tue, 22 May 2018 10:59:57 GMT
Server: App-webs/
Content-Length: 264
Content-Type: text/html
Connection: close
WWW-Authenticate: Digest qop=“auth”, realm=“DS-2CD1121-I”, nonce=“4d546c464d444933517a4d364f4463344d5463304d44413d”, stale=“FALSE”
WWW-Authenticate: Basic realm=“DS-2CD1121-I”
10:59:03.219 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 264, cap: 264/264, unwrapped: PooledUnsafeDirectByteBuf(ridx: 592, widx: 592, cap: 1024)), decoderResult: success)
10:59:03.436 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is :

Document Error: Unauthorized

Access Error: 401 -- Unauthorized

Authentication Error: Your client does not have permission to get URL /MotionDetection/1 from this server.

:

Here is a little more of the log file.

11:04:31.339 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:172.29.8.70
11:04:31.428 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/MotionDetection/1:
11:04:31.508 [DEBUG] [.ipcamera.internal.MyNettyAuthHandler] - 401: This reply from the camera is normal if it needs Basic or Digest auth details.
11:04:31.630 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:172.29.8.70
11:04:31.746 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/MotionDetection/1:
11:04:31.869 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 200 OK
Date: Tue, 22 May 2018 11:05:27 GMT
Server: App-webs/
Connection: close
Content-Length: 406
Content-Type: application/xml
11:04:32.097 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 406, cap: 406/406, unwrapped: PooledUnsafeDirectByteBuf(ridx: 552, widx: 552, cap: 1024)), decoderResult: success)
11:04:32.291 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is :<?xml version="1.0" encoding="UTF-8"?>

1
true
grid

18
22


4


:
11:04:32.727 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 401 Unauthorized
Date: Tue, 22 May 2018 11:05:27 GMT
Server: App-webs/
Content-Length: 264
Content-Type: text/html
Connection: close
WWW-Authenticate: Digest qop=“auth”, realm=“DS-2CD1121-I”, nonce=“4e304d774e54457a525545364f4463344e6a646a5a44553d”, stale=“FALSE”
WWW-Authenticate: Basic realm=“DS-2CD1121-I”
11:04:33.092 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 264, cap: 264/264, unwrapped: PooledUnsafeDirectByteBuf(ridx: 592, widx: 592, cap: 1024)), decoderResult: success)
11:04:33.287 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is :

Document Error: Unauthorized

Access Error: 401 -- Unauthorized

Authentication Error: Your client does not have permission to get URL /MotionDetection/1 from this server.

@ArsalanAlli After a binding refresh you restarted openhab?

In camera settings, what type of authentication do you have?

Hey @matt1, thanks for the reply. I’ll have a deeper look in your code and if I find some time the next days/weeks, I’ll give it a try to implement it. The website you linked looks good and will help me with this, I think.

You’re completely right, the absolute movement is better, but it is not working for my cam, and maybe some others will have this problem, too.

thanx for reply @toroid
my camera doesn’t have digest authentication type. it only has basic one.


image

@ArsalanAlli This is the type of the RSTP, not the web. But something tells me that for the web you also basic. Maybe your camera doesn’t know how to digest authentication.
Is this the latest firmware for your camera?
I have here is such a version of:

yes you are right, my camera doesnt have web authentication field. and firmware of my camera is 5.4
image

But i did not face this authentication error in previous release, its only coming in this release.

Log files I sent to your e-mail with comments.
Forgot only to specify that at the time of testing the switch “Test Code” I had in the on position.
If you need logs with “Test code” - off can also do.

Apparently matt is rigidly prescribed for digest authentication.
My camera supports both types.

So it means i can not use this biding to detect motion as it is using digest authentication.!!
@matt1 !

New build 22-05-2018 is about to be uploaded, following changes:

  1. Instar handler was missing and it probably would not have sent things to the log. This build sends output to the logs.
  2. Instar onvif port defaults to 8080
  3. HIKVISION now has a second url that some cameras use for motion detection. Last nights build only had the one url so this newer build may allow it to start working.

Will edit this with any other changes once I have a look through Sergeys log files…

@ArsalanAlli No that is not correct and thanks for asking for clarification. It will work fine as I am using digest with my camera. With Digest Auth it is 100% normal and ok to see every second request to the camera to be a 401 unauthorized error, if you read the logs you will see the binding detects this and sends the request a second time with the special encyption NONCE key and then you see a 200 OK reply. It is confusing when you are not used to how digest works behind the scenes, but this is normal and it does not stop the binding from working.

Basic auth can be cracked in around 2 seconds by any hacker and your password can then be used to remove your user account locking you out of your own camera! If you use the same password for multiple things, then you have a serious issue.

I do not see something new build on the server :frowning:

@matt1 but in my case my camera doesn’t have digest auth (Screenshot is attached in previous reply)…so you are saying that it is still using digest auth even though i dont have this option in my camera.!! ad when is new release gonna be available ?

already available

LOL I clearly wrote “is about to be uploaded” , I was looking though some logs Sergey sent, more on this below.

@ArsalanAlli Yes your camera is clearly using digest I can tell by the log you posted and you camera does support both see this as you can see the nonce I mention, plus numerous other parts in your logs show it is working fine.

WWW-Authenticate: Digest qop=“auth”, realm=“DS-2CD1121-I”, nonce=“4d546c464d444933517a4d364f4463344d5463304d44413d”, stale=“FALSE”
WWW-Authenticate: Basic realm=“DS-2CD1121-I”

Your picture in my opinion is clearly stating that your camera does not support digest for RTSP. My guess is your camera is locked to always do both, where Sergys camera you can lock the camera to only do digest and refuse to do basic. This is my interuptation on how I read the user interface and how it is displayed…

Something else I noticed in your log output is the camera did reply and it appeared that your camera gave corrupted output.

Try using this link in a browser like chrome to see what it shows. It should be clean XML output.

http://172.29.8.70/MotionDetection/1

@toroid
I looked into both your logs and did a search, it appears not to show any output from when you pressed the test button.

The two URL’s that should be sent are:

http://192.168.1.108/ISAPI/Event/notification/alertStream
http://192.168.1.108/Event/notification/alertStream

Please make sure you do a search for “alertStream” in any logs you send as it was missing from both logs so they may have been old files or over written.

Maybe I don’t understand how You remove the log.

I first activated the test button and then turned on the motion detector on the camera.
When the detector was activated on the camera, motion alarm did not work.
And if the activated motion alarm on the camera to activate the test (off to on) the motion alarm also switches to on. but he switched to the build from 21.05.
The latter does not switch when you activate test