IpCamera: New IP Camera Binding

What ONVIF modes did you try and confirm that work in ODM? continuous, relative and absolute as well as using presets, this adds up to 4 different ways and it is common for cameras to not support all 4 ways. I have posted screen shots on how to change between them on this forum if you do not know how.

In OH3 this widget is the easiest to get going IF you use the UI to auto find and add the thing as equipment.

OH3 Widget: Move and see your PTZ camera feed on a page - Add-ons / UIs - openHAB Community

Thanks for your reply. So I made some more tests with ONVIF Device Manager. In fact, only the Continous move mode seems to be supported on this camera (the others generate: nothing for absolute mode, and a SOAP Server error on the Relative mode). So the Continuous mode is OK for pan and tilt (still have some issue with zoom) and presets with ONVIF Device Manager.
So, with the OpenHab UI:

  • I added a new Thing for this Foscam camera, adding the right parameters (IP, ports, credentials, …)
  • I switched ON the “Use Continuous PTZ” property
  • I attached items for IR LEDs, pan, til,t and zoom.

The IR leds are OK (I can switch them on and off, so no credential issues), but I still have the same issue with the PTZ functionalities.

I also confirm that I have the lastest firmware (V-2.x.1.79_p1) for this camera.

Thanks in advance for any help.

Good, just check that in the UI it is showing as turned on it you are using textual to rule to typo/syntax issues.

Can you send me the TRACE level logs of when the camera is connecting? Just do a find and replace on your password first. I am after the ONVIF xml chatter that occurs when the camera first connects. If the handshake is working then I will move onto looking at wireshark logs of what is different when comparing what ODM sends vs the bindings messages.

If presets work, they will be better to use.

10:56:20.464 [DEBUG] [mera.internal.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.28:888
10:56:20.476 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetSystemDateAndTime
10:56:20.526 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.28:88/cgi-bin/CGIProxy.fcgi?usr=...&pwd=...&cmd=snapPicture2
10:56:20.527 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'ipcamera:foscam:7058551098' changed from OFFLINE (COMMUNICATION_ERROR): Connection Timeout: Check your IP and PORT are correct and the camera can be reached. to ONLINE
10:56:20.571 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Body><tds:GetSystemDateAndTimeResponse><tds:SystemDateAndTime xsi:type="tt:SystemDateTime"><tt:DateTimeType>NTP</tt:DateTimeType><tt:DaylightSavings>false</tt:DaylightSavings><tt:TimeZone xsi:type="tt:TimeZone"><tt:TZ>CST-1:00:00</tt:TZ></tt:TimeZone><tt:UTCDateTime xsi:type="tt:DateTime"><tt:Time xsi:type="tt:Time"><tt:Hour>10</tt:Hour><tt:Minute>16</tt:Minute><tt:Second>49</tt:Second></tt:Time><tt:Date xsi:type="tt:Date"><tt:Year>2021</tt:Year><tt:Month>1</tt:Month><tt:Day>10</tt:Day></tt:Date></tt:UTCDateTime><tt:LocalDateTime xsi:type="tt:DateTime"><tt:Time xsi:type="tt:Time"><tt:Hour>11</tt:Hour><tt:Minute>16</tt:Minute><tt:Second>49</tt:Second></tt:Time><tt:Date xsi:type="tt:Date"><tt:Year>2021</tt:Year><tt:Month>1</tt:Month><tt:Day>10</tt:Day></tt:Date></tt:LocalDateTime></tds:SystemDateAndTime></tds:GetSystemDateAndTimeResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:56:20.583 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetCapabilities
10:56:20.610 [DEBUG] [camera.internal.onvif.OnvifConnection] - Cameras  UTC dateTime is:2021-1-10T10:16:49
10: 56:20.614 [DEBUG] [camera.internal.onvif.OnvifConnection] - Openhabs UTC dateTime is:2021-01-10T10:56:20.614Z
10:56:20.647 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://www.w3.org/2003/05/soap-encoding"><SOAP-ENV:Code><SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value></SOAP-ENV:Code><SOAP-ENV:Reason><SOAP-ENV:Text xml:lang="en">HTTP Error: 401 Unauthorized</SOAP-ENV:Text></SOAP-ENV:Reason></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:56:21.545 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.28:88/cgi-bin/CGIProxy.fcgi?usr=...&pwd=...&cmd=snapPicture2
10:56:21.552 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.28:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=...&pwd=...
10:56:21.745 [TRACE] [mera.internal.handler.IpCameraHandler] - HTTP Result back from camera is  :<CGI_Result>
    <result>0</result>
    <IOAlarm>0</IOAlarm>
    <motionDetectAlarm>1</motionDetectAlarm>
    <soundAlarm>0</soundAlarm>
    <record>0</record>
    <sdState>0</sdState>
    <sdFreeSpace>0k</sdFreeSpace>
    <sdTotalSpace>0k</sdTotalSpace>
    <ntpState>2</ntpState>
    <ddnsState>0</ddnsState>
    <url></url>
    <upnpState>0</upnpState>
    <isWifiConnected>0</isWifiConnected>
    <wifiConnectedAP></wifiConnectedAP>
    <infraLedState>0</infraLedState>
    <humanDetectAlarmState>1</humanDetectAlarmState>
    </CGI_Result>
:
10:56:21.772 [DEBUG] [mera.internal.handler.IpCameraHandler] - End of FOSCAM handler reached, so closing the channel to the camera now
10:56:29.584 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.28:88/cgi-bin/CGIProxy.fcgi?usr=...&pwd=...&cmd=snapPicture2
10:56:29.586 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.28:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=...&pwd=...
10:56:29.772 [TRACE] [mera.internal.handler.IpCameraHandler] - HTTP Result back from camera is  :<CGI_Result>
    <result>0</result>
    <IOAlarm>0</IOAlarm>
    <motionDetectAlarm>1</motionDetectAlarm>
    <soundAlarm>0</soundAlarm>
    <record>0</record>
    <sdState>0</sdState>
    <sdFreeSpace>0k</sdFreeSpace>
    <sdTotalSpace>0k</sdTotalSpace>
    <ntpState>2</ntpState>
    <ddnsState>0</ddnsState>
    <url></url>
    <upnpState>0</upnpState>
    <isWifiConnected>0</isWifiConnected>
    <wifiConnectedAP></wifiConnectedAP>
    <infraLedState>0</infraLedState>
    <humanDetectAlarmState>1</humanDetectAlarmState>
</CGI_Result>
:
10:56:29.786 [DEBUG] [mera.internal.handler.IpCameraHandler] - End of FOSCAM handler reached, so closing the channel to the camera now

And moreover, I tried the preset and when I try to at a channel (with link an Item), I’ve got the following error message in the openhab console:

11:07:44.562 [WARN ] [se.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: FoscamCamerawithAPI_GoToPreset
11:07:55.344 [ERROR] [core.common.registry.AbstractRegistry] - Cannot inform the listener "org.openhab.core.thing.internal.ChannelLinkNotifier@6d512" about the "ADDED" event: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.LinkedList.checkElementIndex(LinkedList.java:559) ~[?:?]
    at java.util.LinkedList.get(LinkedList.java:480) ~[?:?]
    at org.openhab.binding.ipcamera.internal.onvif.OnvifConnection.getXml(OnvifConnection.java:288) ~[?:?]
    at org.openhab.binding.ipcamera.internal.onvif.OnvifConnection.requestBuilder(OnvifConnection.java:366) ~[?:?]
    at org.openhab.binding.ipcamera.internal.onvif.OnvifConnection.sendPTZRequest(OnvifConnection.java:809) ~[?:?]
    at org.openhab.binding.ipcamera.internal.handler.IpCameraHandler.handleCommand(IpCameraHandler.java:1178) ~[?:?]
    at org.openhab.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:177) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.lambda$3(ChannelLinkNotifier.java:72) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.call(ChannelLinkNotifier.java:96) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.added(ChannelLinkNotifier.java:72) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.added(ChannelLinkNotifier.java:1) ~[?:?]
    ...

Do you know how to use wireshark? It is failing to work for this request so if you can provide what odm is sending as a request for the above?

Yes I know. I just captured all the traffic and save it into a wireshark log file.
As I can’t modify the log to remove some potential credential information, I would like to send this log to you directly (and not on this forum). Could you tell me how to proceed.

I’ll PM you my email if that is what you prefer.
Some other things are:

  1. Change your password before taking the log and then change it back afterwards.
  2. I only need the REQUEST and not the RESPONSE, with only half of the traffic the digest method can not be reversed from what I understand. I have seen some cameras do a really stupid things so it is best to do 1. if it concerns you.

I’m on OH3 now so who to kill to get my UDP camera to work?

I’m currently trying to record a 30 seconds GIF from my Foscam via the recordGIF action.

While in the logs it first tell me that the recording should be 30 seconds, the passed parameter -t is only 5:

10:54:40.079 [DEBUG] [ing.ipcamera.internal.IpCameraActions] - Recording ipcamera.gif for 30 seconds.
10:54:40.085 [DEBUG] [nhab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-y -t 5 -hide_banner -loglevel warning -rtsp_transport tcp -i rtsp://user:pass@192.168.1.62:88/videoMain -r 2 -filter_complex scale=-2:360:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse c:\openhab\conf\html\carport\ipcamera.gif

Does anyone have an idea how this can be solved or is GIF recording somehow limited to max 5 seconds?

That is a bug in the 2.5.x merged binding which was fixed in V3.0 and newer. I built a fixed version and uploaded it here for 2.5.x
http://www.pcmus.com/openhab/IpCameraBinding/ipcamera-2020-11-15.zip

Thanks, do I need to recreate the thing or something like that? Because removing the bundle and installing that addon plus restarting OH didn’t change the behavior.

Matt
I have fresh installed OH3, installed IP Camera Binding and tried to add ONVIF UDP camera.
When I play the stream:

rtsp://user:pass@192.168.1.16/onvif1

in VLC all works!
When I add ONVIF camera as a thing with parameters:

IP - 192.168.1.15
ONVIF PORT: 5000
PORT: 2015
MJPEG: rtsp://user:pass@192.168.1.16:554/onvif1
Options before -i: -rtsp_transport udp

OH Log Viewer gives error:

2021-01-12 15:40:12.204 [WARN ] [hab.binding.ipcamera.internal.Ffmpeg] - An error occured trying to process the messages from FFmpeg.

any thoughts?

UPDATE: I have managed kinda make it working, but that is DEAD slow!!! DEAD and unstable!!! and on fresh install did not work at all for some reason…And that is the same with TCP stream by the way - very slow (RPI3B+)

So does this mean you are supplying a H264 stream to the config that is meant for a mjpeg format stream? if so that would explain your issues. If your camera does not do mjpeg, then leave that feild blank. It would be more helpful if you posted the CODE that shows how the thing is configured. Also no need to do user:pass@ in the urls the binding will handle the password correctly for you.

Same problem as Tobias…

Steps:

  1. Uninstalled the binding in PaperUI
  2. Stopped OH
  3. Placed org.openhab.binding.ipcamera-2.5.10-SNAPSHOT.jar in the addon-folder
  4. Restarted OH

Result:
Binding was loaded / Camera-Thing works ok but still only 5 seconds recorded

Hi,
i have an issue with the events for the motion detection.
my openhab system:

Release = Raspbian GNU/Linux 10 (buster)
Kernel = Linux 5.4.83-v7l+
Platform = Raspberry Pi 4 Model B Rev 1.2 4GB / SSD
Updates = 0 apt updates available.
openHAB 2.5.11-1 (Release Build)

the IP-Camera is an UPCAM Tornado HD S (www.upcam.com)
After the installation of the IPCamera binding via PaperUI i was running discovery for this ONVIF-supported camera and the thing for the camera was created.

I have used the DEBUG level for logging of the ipcamera binding to fix some issues with the binding. I was able to fix most of them. I am still struggling with the motion detection.
There are a lot of entries every 5-20 second in the logging:

2021-01-16 12:23:36.182 [DEBUG] [amera.internal.onvif.OnvifConnection] - Onvif Event Topic:RuleEngine/CellMotionDetector/Motion, Data:IsMotion, Value:false

2021-01-16 12:23:48.350 [DEBUG] [amera.internal.onvif.OnvifConnection] - Onvif Event Topic:RuleEngine/CellMotionDetector/Motion, Data:IsMotion, Value:false

2021-01-16 12:23:54.592 [DEBUG] [amera.internal.onvif.OnvifConnection] - Onvif Event Topic:RuleEngine/CellMotionDetector/Motion, Data:IsMotion, Value:false

Most of these log entries show Data:IsMotion, Value:false.
Why i get all these entries even if there is no motion? My assumption is that these events are only raised when there is a motion detected by the camera. But is some cases i don’t get the event when there is an motion deteced (i compared the entries in the camera and the log file in openhab)
Any idea why this happens as described and how i only get the correct events in case a motion is deteced by the camera.
I have also a logging with TRACE which i can provide if needed to fix this issue.

They are normal and come from ONVIF, do you have the cell motion channel linked or the normal motion channel?

So far i have seen theses events only in the logging. For test purpose i have linked both, but only the cell motion channel get updates

2021-01-17 14:36:15.477 [thome.event.ItemStateEvent] - Upcam1CellMotionAlarm updated to OFF

2021-01-17 14:36:27.643 [thome.event.ItemStateEvent] - Upcam1CellMotionAlarm updated to OFF

2021-01-17 14:36:33.732 [thome.event.ItemStateEvent] - Upcam1CellMotionAlarm updated to OFF

2021-01-17 14:36:43.918 [thome.event.ItemStateEvent] - Upcam1CellMotionAlarm updated to ON

2021-01-17 14:36:49.013 [thome.event.ItemStateEvent] - Upcam1CellMotionAlarm updated to ON

2021-01-17 14:37:01.232 [thome.event.ItemStateEvent] - Upcam1CellMotionAlarm updated to OFF

2021-01-17 14:37:07.313 [thome.event.ItemStateEvent] - Upcam1CellMotionAlarm updated to OFF

2021-01-17 14:37:13.422 [thome.event.ItemStateEvent] - Upcam1CellMotionAlarm updated to OFF

Is there any possibility to get rid of these unneccessary events (motion=false) or at least to reduce the frequency.
I always try to optimize a system and get rid of unneccessary actions.

You can filter the logs to remove them by adding lines to a cfg file. Search the forum for how. I’ll have a look at the code when I have spare time to see if it can be filtered at the binding level, but this will take some cpu and ram to do this, but I do understand it is annoying if the event log gets flooded with noise. Best to raise this as a git hub issue.

Gives the binding for openhab3?