IpCamera: New IP Camera Binding

@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

@toroid
I’ll take a look to see if I can work around that when a camera replies with null instead of a valid location. I can probably get it going but you will need to move all 3 controls to then get an accurate location from the camera so a rule on openhab startup to specify a XYZ location would be a good idea.

@frutak
The illegal characters are in the header of the reply back from the camera. You could confirm this with the Linux tool ‘tcpdump’. The : in the request is not there, it is my way of showing where the url starts and stops in the logs so I can see if carriage returns and the like are entered in by users in the snapshot override field. The best way forward would be to use tcpdump to confirm if it is the camera or not so if it is a bug in the netty library we can report it. I think it will be the camera so check for a newer firmware.

@TomBeerten
Your camera is not giving a content length on how large the picture is and this is causing the issue. I may be able to work around this camera issue by guessing how much ram is needed but I would need to err on the larger side and it would place more ram requirements on your server. Maybe 500kb per picture I could guess at. At the least I will detect and put something in the logs that this is happening so thanks for the log.

@frutak
Does your password contain one of the illegal characters? Your camera uses the password in the url string and this goes into the headers so that may be the cause. A space may not be allowed, so try a password that is less complex with no spaces and see if it solves the issue.

thanks for your answer

PTZ works well in onvif device manager.

i can add the cam and it;s online but it do not work


2018-05-31 03:15:38.291 [ome.event.ItemCommandEvent] - Item 'ONVIFGenericIPCameraWithONVIFSupport_Pan' received command 48

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

2018-05-31 03:15:38.300 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@10f8329': null
java.lang.NullPointerException: null
	at org.openhab.binding.ipcamera.handler.IpCameraHandler.setAbsolutePan(IpCameraHandler.java:927) [80:org.openhab.binding.ipcamera:2.3.0.201805252336]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.handleCommand(IpCameraHandler.java:878) [80:org.openhab.binding.ipcamera:2.3.0.201805252336]

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [106:org.eclipse.smarthome.core:0.10.0.oh230]

	at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [106:org.eclipse.smarthome.core:0.10.0.oh230]

	at com.sun.proxy.$Proxy180.handleCommand(Unknown Source) [80:org.openhab.binding.ipcamera:2.3.0.201805252336]

	at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:75) [113:org.eclipse.smarthome.core.thing:0.10.0.oh230]

	at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [113:org.eclipse.smarthome.core.thing:0.10.0.oh230]

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [106:org.eclipse.smarthome.core:0.10.0.oh230]

	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [106:org.eclipse.smarthome.core:0.10.0.oh230]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]


	at java.lang.Thread.run(Thread.java:748) [?:?]


could you kindly advise?

Matt,

Do you need anything from me for this? camera type e.g.?
Is there anything i have to do to solve the problem, camera setting e.g.?

Many Thanks.

New build 31-05-2018 has these changes:

  • Now supports images from cameras that dont specify a content-length header. @TomBeerten and @Yura_Qenf can you test this build please as both of you are the only ones to report this issue. Note: cameras that do this need to keep their snapshots below 512kbytes in size or an error will get thrown.

  • PTZ fix for cameras that reply with null when asked what their current position is. @nakh_Home and @toroid can you test as you both reported this.

  • Instar major bug fix.

  • Dahua possibly now has motion alarm features. Big THANKS to @psyciknz for the help with this.

Tried with both HIK and Onvif Generic
I got the error again: