IpCamera: New IP Camera Binding

Matt, I created a github issue with the results.

Hi all

Iā€™m very newbie in OH, my camera is a SANNCE I21AC and it support ONVIF, I can see live video with ONVIF Device Manager.
Ipcamera binding detect it and show ONLINE status but show these errors:

2018-05-24 13:36:33.987 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Fetching the number of Media Profile this camera supports.
2018-05-24 13:36:37.777 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Checking the selected Media Profile is a valid number.
2018-05-24 13:36:37.780 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Fetching a Token for the selected Media Profile.
2018-05-24 13:36:37.782 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Auto fetching the snapshot URL for the selected Media Profile.
2018-05-24 13:36:41.387 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to fetch some information about the Media Profiles from the camera
2018-05-24 13:36:41.390 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - ********************* Media Profile 0 details reported by camera at IP:192.168.1.23 *********************
2018-05-24 13:36:41.392 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera will use this Media Profile unless you change it in the binding by pressing on the pencil icon in PaperUI.
2018-05-24 13:36:41.394 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 is named:VideoEncoderConfiguration_000
2018-05-24 13:36:41.396 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video encoder	:H_264
2018-05-24 13:36:41.398 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video quality	:1.0
2018-05-24 13:36:41.400 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video resoltion	:1280 x 720
2018-05-24 13:36:41.401 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video bitrate	:1024
2018-05-24 13:36:41.403 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - ********************* Media Profile 1 details reported by camera at IP:192.168.1.23 *********************
2018-05-24 13:36:41.404 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 is named:VideoEncoderConfiguration_001
2018-05-24 13:36:41.405 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video encoder	:H_264
2018-05-24 13:36:41.406 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video quality	:1.0
2018-05-24 13:36:41.408 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video resoltion	:640 x 360
2018-05-24 13:36:41.409 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video bitrate	:512
2018-05-24 13:36:41.410 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to interrogate the camera to see if it supports PTZ.
2018-05-24 13:37:19.205 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Camera is reporting it supports PTZ controls via ONVIF
2018-05-24 13:37:19.209 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - The camera can Pan  from -1.0 to 1.0
2018-05-24 13:37:19.211 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - The camera can Tilt from -1.0 to 1.0
2018-05-24 13:37:19.213 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - The camera can Zoom from -1.0 to 1.0
2018-05-24 13:37:22.619 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera replied with null when asked what its position was, going to fake the position so PTZ still works.
2018-05-24 13:37:22.622 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Finished with PTZ, now fetching the Video URL's the camera supports.
2018-05-24 13:37:31.061 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:192.168.1.23
2018-05-24 13:37:31.739 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/snapshot.cgi:
2018-05-24 13:37:31.866 [DEBUG] [ipcamera.internal.MyNettyAuthHandler] - 401: This reply from the camera is normal if it needs Basic or Digest auth details.
2018-05-24 13:37:31.882 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:192.168.1.23
2018-05-24 13:37:31.902 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/snapshot.cgi:
2018-05-24 13:37:31.934 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: failure(java.lang.IllegalArgumentException: a header name cannot contain the following prohibited characters: =,;: \t\r\n\v\f: ,), version: HTTP/1.1)
HTTP/1.1 200 OK
Server: GoaHead
2018-05-24 13:37:32.085 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 401 Unauthorized
Server: GoAhead-Webs
Date: Mon May  7 15:25:00 2018
WWW-Authenticate: Digest realm="WIFICAM", domain=":17498",qop="auth", nonce="e68757ec4fcc787f47f347a968564fc4", opaque="5ccc069c403ebaf9f0171e9517f40e41",algorithm="MD5", stale="FALSE"
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
2018-05-24 13:37:32.103 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 178, cap: 178/178, unwrapped: PooledUnsafeDirectByteBuf(ridx: 515, widx: 515, cap: 1024)), decoderResult: success)
2018-05-24 13:37:32.109 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with 

I provide user and password in ONVIF Thing Configuration Parameters and not use any of prohibited characters: =,;: \t\r\n\v\f: ,),

How may I include a video or image in a sitemap, something like this?

Image url="http://google.com/leaveLinkAsThis" item=ONVIFGenericIPCameraWithONVIFSupport_ImageURL refresh=5000

Video url="http://google.com/leaveLinkAsThis" item=ONVIFGenericIPCameraWithONVIFSupport_VideoURL encoding="mjpeg"

Thanks a lot.
Luis

same question for me.

@matt1 The line crossing detector canā€™t be turned on separately from the motion detector now.
And if you turn on the motion detector is not particularly clear it turns out which one of them works

I found one interesting document - I think he will help you

https://drive.google.com/open?id=18pJMRMizd1_CPjCDxLAb-PW3lWbXuDvr

@ArsalanAlli Yes it is clearly possible if a script is doing it. If my understanding is correct I can see two ways to make improvements, but there are many areas that could be improved that benefit more brands of cameras and it is a matter of how much I do when I donā€™t get paid and I donā€™t even own one of those cameras.

@japhias

Thanks Iā€™ll take a look when I get some time and reply on the github thread.

@Luis_Gonzalez1
Try updating the firmware for your camera. The netty library is reporting the camera uses illegal characters in the header of replies, it is not something that you are doing wrong. Report it to your camera support.

See the readme file which is found with the jar files, and at github. A full example is there. You need to get a picture showing in PaperUI first before it will work in the sitemap.

@toroid
There was no point putting a switch in when it would not work until the feature I already mentioned to you prevents the control from working. Changing any setting in a HIK camera needs extra features added to the binding before it can be added as a feature.

@matt I want to add not a switch but a text field that displays the last log event.
In the future, you can use the openhab rules already for those who need to add switches to those who need them. In the text box, display the type ā€œmotiondetect activeā€ or other event camera records.

@matt1 Time to time my camera is displaying this message.

Camera at 172.29.8.70:80 is not closing the connection quick enough.

Any idea !!

New build 26-05-2018:

  • New changes for INSTAR only, other cameras should see no change.

Not sure how this would work if the camera sends two events at the same time, you would only see the second alarm and miss the first. I do like the idea, for people who wish to have a String that lists the last event and the time that it occured, the picture then shows what the camera saw when the last event went off.
https://github.com/Skinah/IpCamera/issues/6

That is nothing to be worried about and I see it every now and then with my camera. When I upgrade the binding to go fully async a lot of things like this will change.

Hi Matt,

Maybe this problem has been noticed before, but i cant seem to get a good connection to my IPcam.
I added the binding and my camera as a thing. (status is ā€œonlineā€)
When i go to paper ui, I get the folowing:


Can you help me out? My goal is to get the feed in HabPanel.

Thanks,
Tom

Can you send me the debug log output please so I can take a look?

To change the log level:
1.Start Karaf
2.Enter in
log:set DEBUG org.openhab.binding.ipcamera

Then the file is openhab.log that contains what I need to fault find this. I will only need the section where the camera connects and then send the first few requests for the snapshot.

thanks.

I have an Axis camera and I can help testing. However it seems like Vapix is going to be decommissioned from Axis and replaced by WSDL - see link
I found some stuff about Axis WSDL here.

Hi

i am trying to add this camera Y203S

	Could not resolve module: org.openhab.binding.zwave [242]

  Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="2.3.0.201804291002"; osgi.identity="org.openhab.binding.zwave"; singleton:="true"

2018-05-28 22:59:48.592 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.1.40:8001

2018-05-28 22:59:49.592 [ERROR] [l.internal.messaging.saaj.client.p2p] - SAAJ0008: Bad Response; Not Found

2018-05-28 22:59:49.595 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - The camera connection had a SOAP error, this may indicate your camera does not fully support ONVIF, check for an updated firmware for your camera. Not to worry, we will still try and connect. Camera at IP:192.168.1.40, fault was com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (404Not Found

2018-05-28 22:59:49.599 [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.

==> /var/log/openhab2/events.log <==

i can connect to it through VLC

image

image

the camera do not get connected .

which port should be used?

is this camera supported by this binding?

Thanks

@EjvindHald
Iā€™ll send a PM through tonight with what to do to get things moving for Axis.

@nakh_Home

Yes it appears that this is the issue. The rtsp port is usually different from the onvif port number and the best way to find this is to use the opensource ā€œOnvif device managerā€ software.

You will need to get ONVIF working to be able to use PTZ, otherwise you could setup the camera as HTTPONLY thing type and supply a snapshot url. BTW rtsp is a video stream and not supported yet, you need a snapshot url to provide a jpeg picture.

New build 30-05-2018 has following changes:

  • New netty 4.1.25 version library.
  • Fixed a bug in digest auth that was stopping some older Dahua cameras from connecting. Thanks for help from @psyciknz for this.
  • New thing type for DAHUA added.
  • New abilities added for INSTAR that need testing.
  • Fixed a bug where PTZ sliders would not show the cameras location when openhab connects.
  • Whole heap of changes to get closer to full Async comms and to be able to leave multiple connections open to a camera. Possible this may cause issues in some cameras, so use the previous build if any issues, I have had my camera running overnight with the code changes and no issues. Amcrest supports 10 connections by default, not sure what other cameras can do.
  • New counter to show how many connections are open in the debug logs.

@matt1 Does the PTZ on HIK cameras work?

I have in the field videourl shows now this error
2018-05-30_13-51-04

I have no idea as I donā€™t own one. The ptz feature is done by onvif so it should work in any brand camera that has it implemented. The message is telling u onvif did not complete all the way through on your camera. Perhaps u have the wrong port selected or onvif is turned off by default in HIKVISION cameras.

@matt onvif works.

Got a picture.
Tried to change thing for ā€œOnvif genericā€ On it as there is a camera.

When trying to control PTZ in logs the following.

When thing ā€œHikvisionā€ in the logs is the same error.

Hi matt1!

Thanks for your contributions, it is excellent work.

I am having issues getting my camera to work in sitemaps. It is a sannce (generic) IP cam supporting onvif (but I also tried to set it up as http only with the same result). The cam gives status as online, but it also logs an HTTP error in the log, after it connects.

Error from the log (there seems to be a semicolon at the end of the GET):

2018-05-30 20:34:34.245 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:192.168.0.32
2018-05-30 20:34:34.319 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/snapshot.cgi?user=admin&pwd=pass:
2018-05-30 20:34:34.376 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: failure(java.lang.IllegalArgumentException: a header name cannot contain the following prohibited characters: =,;: \t\r\n\v\f: ,), version: HTTP/1.1)

Do you know what could be the problem?

Hi Matt,

Sorry it took me so long.

Thatā€™s the snapshot. Is this what you meant?

Thx.

more info from the log:

with onvif thing:

2018-05-30 23:59:03.715 [DEBUG] [org.openhab.binding.ipcamera        ] - BundleEvent [unknown:512] - org.openhab.binding.ipcamera
2018-05-30 23:59:03.810 [DEBUG] [org.openhab.binding.ipcamera        ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={component.name=org.openha$
2018-05-30 23:59:03.818 [DEBUG] [org.openhab.binding.ipcamera        ] - BundleEvent STARTING - org.openhab.binding.ipcamera
2018-05-30 23:59:03.822 [DEBUG] [org.openhab.binding.ipcamera        ] - BundleEvent STARTED - org.openhab.binding.ipcamera
2018-05-30 23:59:40.279 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Getting configuration to initialize a new IP Camera at IP 192.168.0.32
2018-05-30 23:59:40.292 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.32:10554
2018-05-30 23:59:41.574 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - The camera connection had a SOAP error, this may indicate your camera does not fully support ONVIF, check for an up$
2018-05-30 23:59:41.702 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:192.168.0.32
2018-05-30 23:59:43.533 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/snapshot.cgi?user=admin&pwd=pwd:
2018-05-30 23:59:44.215 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: failure(java.lang.IllegalArgumentException: a header name cannot contain the foll$
HTTP/1.1 200 OK
Server: GoaHead
2018-05-30 23:59:44.277 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:192.168.0.32
2018-05-30 23:59:44.383 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/snapshot.cgi?user=admin&pwd=pwd:
2018-05-30 23:59:44.514 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: failure(java.lang.IllegalArgumentException: a header name cannot contain the foll$
HTTP/1.1 200 OK
Server: GoaHead

with http thing:

2018-05-31 00:03:41.444 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Getting configuration to initialize a new IP Camera at IP 192.168.0.32
2018-05-31 00:03:41.471 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera at 192.168.0.32 has a snapshot address of:http://192.168.0.32:13439/snapshot.cgi?user=admin&pwd=pwd:
2018-05-31 00:03:41.475 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:192.168.0.32
2018-05-31 00:03:41.506 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/snapshot.cgi?user=admin&pwd=pwd:
2018-05-31 00:03:41.539 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: failure(java.lang.IllegalArgumentException: a header name cannot contain the foll$
HTTP/1.1 200 OK
Server: GoaHead

Thanks in advance