IpCamera: New IP Camera Binding

Tags: #<Tag:0x00007f617e182e50> #<Tag:0x00007f617e182b08> #<Tag:0x00007f617e182a18>

One quick note: this is with the LaView FW. Let me try loading Hikvision and see what happens. But not tonight.

I got some more time to do testing of ONVIF events with 3 different brands.

INSTAR= does not work in ODM but works in binding.
HIK = works in ODM but does not in binding.
AMCREST= works in ODM but does not in binding after a firmware update.

There are at least 2 ways to get the events and I have only implemented 1 of them so far (Hikvision use the method I have not yet fully implemented) and some cameras are very very fusy on the messages sent.

I know this is very frustrating. Non-standard “standards” only serve the PR departments of the manufacturers while still locking customers into one vendors’ products.

I will create an issue on GitHub and start collecting wireshark traces and other information for you. Just let me know what you need, and I will get the info for you.

I completed the coding for both methods and will need to create a newer Alpha build (not done yet), then all I need is the TRACE level log output of when the camera is connecting for the first time to a camera. It probably wont work on many cameras but the trace log will allow me to improve the coding so don’t stress if it does not work. Please don’t send an entire 30mb log file. Because it only contain one half of the digest strings it is safe to publish, but if you use wireshark and include the request and response messages you can decode and get your password from it, so use a silly password and change it afterwards if doing wireshark and putting on the web.

I narrowed down why Hikvision is not working and that is because the end point is different for the events and the onvif lib I am using does not allow me to access this. Possibly one of the other firmwares you have will be different. Wireshark is needed to determine this.

Hi @matt1. I just finished uploading a whole set of scenarios on your GitHub page as Issue number 56. I included wireshark captures of the onvif2mqtt as it attached to the camera, and I also captured what happens during a PIR event.

I also uploaded data including the openhab.log and events.log along with wireshark captures. I simply started wireshark, and then renamed ipcamera.things~ to ipcamera.things. So the capture is just of the initial registration. Once the registration was done, I then started a fresh capture and generated a PIR event.

The interesting thing is that it sure looks as if the camera sends the binding all of the information normally associated with a PIR event. So maybe I am doing something stupid with my .items file? Or maybe I am looking at the wrong thing in my .sitemaps file? But in any case, there is no record of a motion event in the events.log.

I am not worried about posting public info from the wireshark or OH logs. Everything on my network is non-public, and I will change all passwords in any case once I tear down my lab and actually move out of a dev environment. (Or am I being stupid there too? In which case, please let me know and once you have the files I will delete them from GH.

Let me know when you have the newer Alpha and I will give it a try.

Uploaded it and it is not marked as Alpha as the newer code only runs if the thing type is ONVIF.

Changes are:

  • New channel ‘pirAlarm’ for onvif thing type. Keeps the triggers for normal motion and PIR separate.
  • Both forms of onvif alarms are hopefully implemented enough that it will work for ‘some’ cameras. If not it should log some info I need.
  • Changes to the way it detects a missing snapshot url for onvif.

@matt1 Loaded 5-26 alpha. Not quite working but seems camera is responding with PIR events. Wireshark capture uploaded to your GitHub.

New build 2020-05-30 has had these changes and extensive testing done:

  • More reliable snapshot url detection for ONVIF cams.
  • Logging to help guide new users to what is wrong.
  • ONVIF event changes. Not used for api cameras.
  • Better online/offline detection and re-connecting after network issues for ONVIF cams.

Tested with esp32 cameras.
Tested with 3 different brands of onvif cameras.
Tested with API based cameras.

Last area needing testing is with a RTSP only camera to look for any setup gotchas or if they work after a network issue occurs.

@matt1 - Sorry for the long post.

You can add this Dahua camera to your list of working devices:

Device Type     IPC-HDW4631C-A
System Version  2.460.GP01.16.R, Build Date: 2017-09-04
WEB Version
ONVIF Version   16.12(V2.4.0.485616)

Some notes:
This Dahua is a bit strange. It has 3 streams, main0, sub1 and sub2. Notice, Sub1 is highly limited in setup options, but Sub2 has more options (among MJPEG format). All streams support different types of audio, incl aac.
Ipcamera sometimes has an issue discovering the correct stream. I dont know exactly why. It may be due to not restarting the binding when doing changes on the camera. If anything goes wrong in discovering the stream, Ipcamera will fall back to default stream0, which is main stream. This issue has fooled me quite a few times. A user advice: Keep an eye on the openhab logfile when making changes to the camera. It may not happen at the very second you change a setting on the camera, but sometimes after you reboot camera/openhab or ipcamera binding, Ipcamera can fail in discovering the stream, and then Ipcamera falls back to main stream (stream0).

You can add Reolink RLC-410 as well, (latest firmware), for HTTP ONLY camera. Onvif do not work.
Some Notes:
Reolink RLC-410 is not recommended in my opinion, as its very limited in its output formats and possibilities, making it a bit of a hell demuxing the output to stream HLS through ffmpeg. It can work, but it puts alot of pressure on the system. The camera will do snapshots and animated gif just fine though, as well as direct RTSP streaming.

Notes about pressure the system.
My latest discoveries running my main openhab system with Google Assistant integration (main system is guite busy) on an Rpi3B+ and untill recently with the Reolink only.
Having this Rpi3B+ which is busy enough doing other openhab stuff, there will be consequences adding too many cameras to Ipcamera/ffmpeg, if they dont support a very good compressd format, consequences like openhab acting up strangely, running slower etc. I had to give up Ipcamera on my main system and is now using one of my test systems (Rpi4 4GB) to handle Ipcamera binding and ffmpeg demuxing with one Reolink RCL-410 and one Dahua IPC-HDW4631C-A, (Next step is to add another Dahua IPC-HDW4631C-A camera). This moving of the ipcamera binding as the cameras feed to another system, leads to my next problem.
I have focus on Google Assistant integration mainly. And since only one system can handle the GA integration, I had to setup a proxy switch item on my main openhab system with a static url pointing the HLS startStream on the test setup. I used Karaf to set the static url for this switch item on my main system, cause for some very strange reason openhab do not allow a static url to an item without a channel binding. (Very unlogic to me, but thats what I´ve been told in another thread).

To be specific, this setting do NOT work, openhab will not set the item to the url:

String Dahua1ForHub   "hovedindgang"   { url="", ga="Camera" [ protocols="hls" ] }

But this will work if the user use Karaf to set the static url for the item Dahua1ForHub:

String Dahua1ForHub   "hovedindgang"   { ga="Camera" [ protocols="hls" ] }

I wonder if an easy solution for this could be an option to set the streamStart to a static url (local IP), through ipcamera binding insted? I dont feel its a good solution to set the static url though Karaf or Rest API, as the user cant see it anywhere. Do you think this would be a good idea?
I personally think the only obvious solution would be for openhab to support direct url for an item as default. But thats probably too much work to be done by the developers.

Thats it for now… As mentioned, my next step is to add my second Dahua camera (It’s already here on my table). But I doubt I´ll be having issues when using my Rpi4 for this.
Then I´ll probably return back with a updated “report”.

When was the last time you tested that? I made many changes to the binding and some may mean the rtsp is not needed as a source for the snapshots… As a last resort you can always keep it as ONVIF and set the snapshot over ride to be ‘ffmpeg’ and it will then not auto find the url and use the rtsp source instead. With ONVIF alarms now partly added, some cameras will now have this ability.

No. I recommend using what is in the readme file which uses the bindings channel as the source. This way if the ip is changed everything follows automatically. You are not understanding the openhab framework and that is best discussed in the other thread you opened.

It should follow what u have set as the onvif media profile number, if it does not, then please explain how to reproduce and I will look at it. If you are wanting to use multiple streams for different sources then using the override is the way to do it, otherwise the same source gets used for snapshot, rtsp and ffmpeg.

I would not use a pi3 or older device, the Pi4 was the first one to be decent as all the previous models the USB ports and network shared bandwidth, also the PI4 was a big jump up in CPU power and 1 gb of ram is not enough. You will see a big difference because the 4 is a far better device for many reasons.

org.openhab.binding.ipcamera-2.5.4-SNAPSHOT is the one I´m using on my Rpi4 right now. I think its from the 15. of May.

Must have missed that part of the readme.

I need to test this some more cause I have not been able to reproduce it. But I think it happened if I turn off Sub stream 1, and only having main and sub2 turned on in the camera… As mentioned, Sub stream 1 doesnt provide many options, but sub stream 2 does. Right now I have all three streams turn on in the camera settings. And there is no issue.

I know… I just havnt had the time to move my whole system. I also got a Odroid C2 as test setup.


I had a little time, and I have tried to use the IP camera binding (ONVIF) with this mod on my camera:

ONVIF enabled, ports double checked, no authentication.
The Thing comes online automatically, so I assume it receives the rtsp stream and snapshot url.
However I can’t display anything in openHAB.
For example, creating a Video element like this, won’t even work in openHAB:

Video item=Camera_Stream

Also I tried to show the Image from the Snapshot channel but nothing is displayed there also.
Everything is on default in the Thing configuration, I just set the IP address. I have tried turning the UpdateImage to ON, but nothing changes.
FFmpeg is installed on the right path.

So my 2 question:

  • Do you have any idea why I can’t even view the Image from Snapshot? Maybe that fw does not report a snapshot url (it should) or something is wrong there?
  • How I could view the video in a sitemap?

Ps.: I was able to get working URLs for jpg image and streams. However for example viewing that jpg, I only get a little empty rectangle…

Please read the readme on what to do if u have problems, first section and hint: logs.

Always use the examples in the readme as they are tested examples.

New build 2020-06-08 has these changes:

  • JAR is now much, much smaller and is not a mistake as it now uses a full set of re-written ONVIF methods using only Netty.IO and hence it has removed a lot of dependencies and made the JAR smaller.
  • Discovery of new cameras does not work due to other features took preference when getting new onvif working.
  • New auth method for Onvif. Cameras that previously needed auth disabled for onvif to connect, now may work fine with the auth re-enabled.
  • More Onvif event methods have been added to fetch alarms. More on this below.

If you have an ONVIF camera that does not have an API, then set it up as a generic ONVIF thing type and look at your logs in DEBUG mode as the camera is connecting. Any events that get detected will get listed and if they are not recognised, I just need a copy of the text when there is no alarm and when there is an alarm state.

Some cameras may only give a single output when it first connects and then nothing more, please report this if it happens and what camera you use.

Any issues with the camera connecting, then I will need a TRACE level log of when the camera is connecting.

DEBUG = handy to watch the events with without all the other info.
TRACE = all the replies back from the camera that I need to look at issues with.


Seem like my Reolink RCL-410 now works using ONVIF. Still configuring, just wanted to inform you, that it went online just fine using onvif.

It doesnt seem like I can get the motion or Pir sensor to work with the Reolink. How much trace logging do you need? I just activated trace, but it looks like its the same info over and over again.

See my last post, use DEBUG for watching the events. If you see no events at all then I will need some trace for only the connecting sequence and yes it is a a lot of lines. Some cameras may only send a single reply when they connect, so be sure to have debug on and then restart or change a config in the things file to trigger a reconnect.

When creating the log if you can make sure only 1 camera is setup and you turn off the snapshots to keep the log clean and for only a single camera. If using a thing file that is very easy as you can just comment out cameras temporarily whilst testing.

I did set loglevel to debug as well. I can see some info about the onvif, but no events.
I´ll do some more logging tonight and send you making it as clean as possible.

This is the startup with debug logging:

2020-06-09 19:04:47.770 [hingStatusInfoChangedEvent] - 'ipcamera:DAHUA:DAHUA1' changed from UNINITIALIZED to UNINITIALIZED (DISABLED)
2020-06-09 19:04:47.790 [hingStatusInfoChangedEvent] - 'ipcamera:ONVIF:Reolink' changed from UNINITIALIZED to INITIALIZING

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

2020-06-09 19:04:47.800 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Possible NIC/IP match found:
2020-06-09 19:04:47.962 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - File server for camera at has started on port 54321 for all NIC's.
2020-06-09 19:04:47.985 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetSystemDateAndTime

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

2020-06-09 19:04:47.998 [vent.ItemStateChangedEvent] - Cam001HlsUrl changed from NULL to
2020-06-09 19:04:48.001 [vent.ItemStateChangedEvent] - Cam001ImageUrl changed from NULL to

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

2020-06-09 19:04:48.228 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetCapabilities
2020-06-09 19:04:48.239 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Cameras  UTC time is : 17:4:47
2020-06-09 19:04:48.242 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Cameras  UTC date is : 2020-6-9
2020-06-09 19:04:48.244 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Openhabs UTC dateTime is:2020-06-09T17:04:48.244Z
2020-06-09 19:04:48.256 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - deviceXAddr:/onvif/device_service
2020-06-09 19:04:48.257 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - eventsXAddr:/onvif/event_service
2020-06-09 19:04:48.258 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - mediaXAddr:/onvif/media_service
2020-06-09 19:04:48.260 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - <tt:PTZ> was not found in :<?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:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:ns1="http://www.onvif.org/ver10/actionengine/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:ns10="http://www.onvif.org/ver10/events/wsdl/PullPointBinding" xmlns:ns11="http://www.onvif.org/ver10/events/wsdl/CreatePullPointBinding" xmlns:ns12="http://www.onvif.org/ver10/events/wsdl/PausableSubscriptionManagerBinding" xmlns:ns13="http://www.onvif.org/ver10/network/wsdl/RemoteDiscoveryBinding" xmlns:ns14="http://www.onvif.org/ver10/network/wsdl/DiscoveryLookupBinding" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:ns3="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding" xmlns:ns4="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:ns5="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" xmlns:ns6="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:ns7="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:ns8="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:ns9="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding" xmlns:tad="http://www.onvif.org/ver10/analyticsdevice/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tls="http://www.onvif.org/ver10/display/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:trv="http://www.onvif.org/ver10/receiver/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><tds:GetCapabilitiesResponse><tds:Capabilities><tt:Analytics><tt:XAddr></tt:XAddr><tt:RuleSupport>false</tt:RuleSupport><tt:AnalyticsModuleSupport>false</tt:AnalyticsModuleSupport></tt:Analytics><tt:Device><tt:XAddr></tt:XAddr><tt:Network><tt:IPFilter>false</tt:IPFilter><tt:ZeroConfiguration>false</tt:ZeroConfiguration><tt:IPVersion6>false</tt:IPVersion6><tt:DynDNS>false</tt:DynDNS></tt:Network><tt:System><tt:DiscoveryResolve>false</tt:DiscoveryResolve><tt:DiscoveryBye>false</tt:DiscoveryBye><tt:RemoteDiscovery>true</tt:RemoteDiscovery><tt:SystemBackup>false</tt:SystemBackup><tt:SystemLogging>false</tt:SystemLogging><tt:FirmwareUpgrade>false</tt:FirmwareUpgrade><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>1</tt:Minor></tt:SupportedVersions></tt:System><tt:Security><tt:TLS1.1>false</tt:TLS1.1><tt:TLS1.2>false</tt:TLS1.2><tt:OnboardKeyGeneration>false</tt:OnboardKeyGeneration><tt:AccessPolicyConfig>false</tt:AccessPolicyConfig><tt:X.509Token>false</tt:X.509Token><tt:SAMLToken>false</tt:SAMLToken><tt:KerberosToken>false</tt:KerberosToken><tt:RELToken>false</tt:RELToken></tt:Security></tt:Device><tt:Events><tt:XAddr></tt:XAddr><tt:WSSubscriptionPolicySupport>true</tt:WSSubscriptionPolicySupport><tt:WSPullPointSupport>true</tt:WSPullPointSupport><tt:WSPausableSubscriptionManagerInterfaceSupport>false</tt:WSPausableSubscriptionManagerInterfaceSupport></tt:Events><tt:Imaging><tt:XAddr></tt:XAddr></tt:Imaging><tt:Media><tt:XAddr></tt:XAddr><tt:StreamingCapabilities><tt:RTPMulticast>false</tt:RTPMulticast><tt:RTP_TCP>true</tt:RTP_TCP><tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP><tt:Extension></tt:Extension></tt:StreamingCapabilities><tt:Extension><tt:ProfileCapabilities><tt:MaximumNumberOfProfiles>10</tt:MaximumNumberOfProfiles></tt:ProfileCapabilities></tt:Extension></tt:Media></tds:Capabilities></tds:GetCapabilitiesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
2020-06-09 19:04:48.263 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - We hit an issue parsing url:
2020-06-09 19:04:48.265 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetProfiles
2020-06-09 19:04:48.293 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetSnapshotUri
2020-06-09 19:04:48.301 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetStreamUri
2020-06-09 19:04:48.310 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetNodes
2020-06-09 19:04:48.319 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetEventProperties
2020-06-09 19:04:48.330 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - GetSnapshotUri:/cgi-bin/api.cgi?cmd=onvifSnapPic&amp;channel=0
2020-06-09 19:04:48.372 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:CreatePullPointSubscription
2020-06-09 19:04:48.375 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetStatus
2020-06-09 19:04:48.381 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:Subscribe
2020-06-09 19:04:48.387 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - ptzNodeToken=000
2020-06-09 19:04:48.392 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetConfigurations
2020-06-09 19:04:48.418 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Processing new PTZ location now
2020-06-09 19:04:48.420 [WARN ] [nding.ipcamera.onvif.OnvifConnection] - turning off PTZ functions as binding could not determin current PTZ locations.
2020-06-09 19:04:48.429 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - GetStreamUri:rtsp://
2020-06-09 19:04:48.435 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:PullMessages
2020-06-09 19:04:48.489 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetPresets
2020-06-09 19:04:48.494 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - ptzConfigToken=000
2020-06-09 19:04:48.495 [DEBUG] [nding.ipcamera.onvif.OnvifConnection] - Sending ONVIF request:GetConfigurationOptions

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

2020-06-09 19:04:51.240 [hingStatusInfoChangedEvent] - 'ipcamera:ONVIF:Reolink' changed from INITIALIZING to ONLINE
2020-06-09 19:04:51.248 [vent.ItemStateChangedEvent] - Cam001RtspUlr changed from NULL to rtsp://openhab:openhab0101@
2020-06-09 19:04:51.250 [vent.ItemStateChangedEvent] - Cam001Switch changed from NULL to OFF

And this is the trace log (file attached).
Reolink ipcamera trace.txt (80.6 KB)

Hope its usefull.

Yes that was perfect just need the time to go over it in more detail. Can you confirm that the camera updates alarms inside onvif device manager? There’s a page called events and it should update the list as your camera sees movement. Everything looks like it is working except PTZ because your camera does not have that feature, so just need to fault find the events.