IpCamera: New IP Camera Binding

I open my cams trough a http-link in habpanel, works perfect

1 Like

@matt1 I’ll follow here. Hopefully you can get this binding with alle the features running. would be really great and I except a lot people wants to use their camera in e.g. habpanel with ptz control, two way audio for door phones, … !

@Dappie yes but I believe just the video stream without any mentioned functions we are talking here about isnt it?

I have some Axis cams and every function is supported.
In HabPanel I just use a widget with a ipaddress and it functions just like in a webbrowser.

btw: I also have some small php-scripts that display temperature or displays pictures from a memorystick in the raspberryPI (as widget allmost everything is possible but not everyone will or can make his own programs)

But the idea of building something to manage cams is great :slight_smile:

@dappie I dont think that you can talk with habpanel/basic ui with your tablet microphone to the camera speaker and vise versa. If you can do, please tell me the modell.

that native applications can do this work, that is clear. also on PC and webbrowser with help of flash, activex or silverlight. but for me I dont know a ready working way to use two way audio with android webbrowser and the openhab ui’s

There is no mic on this cam, but everything whats possible in php, html or anything else you can do in a browser is possible in a widget (ip). I havent found any limitations.

Even a php-based webradio or whatever you can think of is possible, there are some limitations since there is no feedback to openab since its browserbased only :-).
So: if audio in a webbrowser is possible it would be possible in a widget window too.
I will try it one of these days with a cam with all options and get back to you (and I never use silverlight and try to avoid flash since they gather more than I wish, but that’s a other discussion.

but dont hold back please :slight_smile:

@dappie Yes the Axis is one of the brands I mentioned above that does have a published API and is one of the brands I could implement so that it is faster and easier for people that buy cameras from that brand and the other brands in my post. What is usually the hard part with API use is motion detection, have you got that working and if so how? A number of Openhab users have external scripts that check for snapshot files and the like. The hacked together solutions end up not user friendly for new Openhab users.

Currently I am writing code with the Netty project library as it will allow HTML and also RTSP support with only the 1 dependency. Once I have the main code written and working with my camera the features should roll out pretty quickly it is just the initial hurdle to get over.

I have now added basic ONVIF features and have PTZ and fetching a static image link working. It is now ready for anyone that wishes to help test it and give feedback on how it works on different brands of ONVIF ip cameras. I have to upload to github and take care of including license files before sharing, if anyone can give me advice on what I need to do with license files that would be great.

milg0 ONVIF library and io.netty both use Apache License 2.0

Next up is to finish off the HTTP code to turn the image and video links into working streams. I have done 50% of the work needed for this to happen using io.netty and can send requests and get responses back from the camera.

Hit my first hurdle with AMCREST cameras which was they have removed basic auth and now require digest authorisation in recent firmwares. This means you can not use their API in widgets without a binding like you can with Axis and Foscam, it has also meant a big jump in work for me to get the camera going.


See updated first post of this thread for the download link and info as I have uploaded the binding for people to give feedback on. As I have spare time I will be adding more features with Alarms that can be used in Openhab to trigger rules as a main goal as I have a picture and PTZ controls already functioning.

If you do use the binding and it works then please post what camera you have and how it functions for you as it has only been used on a single camera so far.

You mentioned you have a dynamic ip that changes when the router reboots, have you tried the openhab cloud service yet? It may solve that for you as you don’t need to port forward to get it working. Check it out as it was very simple to setup and I believe it will solve the issue for you.

This binding coupled with the openhab cloud should work well if you stick to basic controls with a sitemap.

Progress update:
I now have basic and digest auth methods working and can now connect to my Amcrest API with digest. So I am close to being able to roll out features like motion and audio alarm features that can trigger openhab rules. If you wish your camera did something that is in an API now is the time to make a request as I would like some people using this to give feedback.

Thanks for the link you provided, I am looking at implementing it now which has raised a security issue. The link you are using has plain text passwords over a http connection. Can you try using the same link but using https at the start to see if it still works please? Because the binding will be used by people with lower security knowledge I’m considering making the binding only use https if a camera does not use digest auth. Any thoughts on this? I can always put in an override setting that makes users aware of the security issue should a camera only work this way.

Hi Matt,
I am very new to openhab and up until now just have a few lights working so please bare with me!

I have tried your binding and first thing of note was that I had to change the onvif port on my ip cam to 80 in order to get the camera online (this was not the manufacturers default port). Doesn’t bother me but something worth noting for anyone trying to use the binding.

Anyway my main issue is when the camera is “online” log viewer shows that there are 2 profiles and that the camera supports ptz via onvif but gives me the following error :-

[ERROR] [ing.saaj.soap.ver1_2.SOAPPart1_2Impl] - SAAJ0415: InputStream does not represent a valid SOAP 1.2 Message

On my sitemap I get the error:-

SOAP-ENV:ClientHTTP GET method not implemented

I am using a Foscam fi9821 v2 and have tried both profiles. I have tested the onvif stream successfully using an app (ip camera viewer for mac). Not sure if I am doing something wrong?

Thanks in advance

@reeso3000 First of all welcome to Openhab. Does the binding move your camera? Can you post what does work if anything and also please give a few lines from the logs before an error occurs as that helps me track down the issue faster if I know what was happening right before an error. Look at turning on DEBUG log output for this binding using karaf as you will get a lot more output. Thanks for reporting.

The first issue seems to be raised as a bug here that was fixed, but it appears the error still goes to the logs but the code should still work, see here:

The second issue I will look at it tonight. I suspect your camera only supports RTSP and not http/s streams via onvif, so I will need to add some checks and a new way to fetch the http link. Does the static image link work for you? Next build I make should be more useful so any feedback you give I can take on board for the next build.

New build 16-04-2018:

  • No new features other than better logging to show what video stream urls can be reported by a camera.

  • Fixed two parts in the code that may have caused SOAP issues.

  • New thing types for each brand that has an API, getting ready for new features that only some brands are able to do.

  • ONVIF_PROFILE_NUMBER changed to ONVIF_MEDIA_PROFILE as that made more sense as ONVIF have another meaning for profile.

I should have alarms added soon (only for cameras with API) as I have this already 99% done then I will update documentation. I am please to say that the coding with the API on my amcrest is very responsive.

hi, tried to implement the generic ONVIF IP camera but ended with these errors:

2018-04-18 10:34:31.800 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to IP Camera at IP:

2018-04-18 10:34:31.825 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - java.net.ConnectException: Host not available.

2018-04-18 10:34:31.825 [hingStatusInfoChangedEvent] - 'ipcamera:ONVIF:48ef4ade' changed from INITIALIZING to OFFLINE (CONFIGURATION_ERROR): Can not access camera: Check that your IP ADDRESS, USERNAME and PASSWORD are correct and the camera can be reached.

doublechecked my inputs, any idea how to debug that?
the camera is a SANNCE I41DC and should support ONVIF, at least I get a video via rtsp… It was cheap, looks robust, has a wide angle view and high resolution.
is it possible to switch on/off the alerting function via the binding too? I get a thousand email alertes when my kids are playing outside, so enabling and disabling the cameras alarm function together with my other alarms would be great.
I appreciate your work on that binding, thanks!

My guess is you will need to include the PORT that your camera uses for ONVIF. In the IP Address field for now try putting the port in like this. Ignore that it tells you not to.
In the case that your camera uses port 81.

In the next build there will be a separate port field to use as I just added this feature, but for now this will work around it as the binding has no http code that the above will break.

I would have to check if it is possible by ONVIF and what minimum onvif version your camera needs to support. Does your camera have an API via http?

the http URL is
this results in an authorization failure. user/password is 100% true, I also tried other user/password combination as the camera supports admin, operator and visitor users, for what ever reason…

2018-04-18 12:52:45.942 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to IP Camera at IP:

2018-04-18 12:52:45.944 [me.event.ThingUpdatedEvent] - Thing 'ipcamera:ONVIF:21cd17f5' has been updated.

2018-04-18 12:52:46.064 [ERROR] [l.internal.messaging.saaj.client.p2p] - SAAJ0008: Ungültige Antwort; Unauthorized

2018-04-18 12:52:46.067 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (401Unauthorized

the rtsp URL is rtsp://
port 6554 results in the following error.

2018-04-18 12:56:22.452 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to IP Camera at IP:

2018-04-18 12:56:22.462 [me.event.ThingUpdatedEvent] - Thing 'ipcamera:ONVIF:21cd17f5' has been updated.

2018-04-18 12:56:22.562 [ERROR] [l.internal.messaging.saaj.client.p2p] - SAAJ0008: Ungültige Antwort; null

2018-04-18 12:56:22.568 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (-1null

Does your camera have an API via http?
not 100% sure if this is fully functional http API. I need to run a program (Saneye) or an app to get full control to the camera. enabling and disabling alerting can not be done via the web GUI.

This opensource application can be used to check your cameras settings and what it supports. Since ONVIF allows auto discovery a program like that will find your camera and then allow you to check the port and other settings.

thanks for that hint, thats a great tool! port is 8080, what surprise :wink:
camera is now online and reports those messages:

2018-04-18 13:34:29.634 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to IP Camera at IP:
2018-04-18 13:34:29.644 [me.event.ThingUpdatedEvent] - Thing 'ipcamera:ONVIF:21cd17f5' has been updated.
2018-04-18 13:34:39.018 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - ********************* Media Profile 0 details reported by camera at IP: *********************
2018-04-18 13:34:39.020 [INFO ] [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-04-18 13:34:39.023 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 is named:VideoEncoderConfiguration_000
2018-04-18 13:34:39.025 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video encoder	:H_264
2018-04-18 13:34:39.028 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video quality	:1.0
2018-04-18 13:34:39.031 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video resoltion	:1920 x 1080
2018-04-18 13:34:39.034 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video bitrate	:1024
2018-04-18 13:34:39.036 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - ********************* Media Profile 1 details reported by camera at IP: *********************
2018-04-18 13:34:39.039 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 is named:VideoEncoderConfiguration_001
2018-04-18 13:34:39.041 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video encoder	:H_264
2018-04-18 13:34:39.043 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video quality	:1.0
2018-04-18 13:34:39.046 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video resoltion	:704 x 576
2018-04-18 13:34:39.048 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video bitrate	:512
2018-04-18 13:34:46.022 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - This camera supports the following Video links. NOTE: The camera may report a link or error that does not match the header, this is the camera not a bug in the binding.
2018-04-18 13:34:46.024 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - HTTP Stream:rtsp://
2018-04-18 13:34:50.406 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - TCP Stream:rtsp://
2018-04-18 13:34:55.203 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - RTSP Stream:rtsp://
2018-04-18 13:34:59.536 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - UDP Stream:rtsp://
2018-04-18 13:35:28.291 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Camera is reporting it supports PTZ controls via ONVIF
2018-04-18 13:35:30.463 [hingStatusInfoChangedEvent] - 'ipcamera:ONVIF:21cd17f5' changed from OFFLINE (COMMUNICATION_ERROR): Camera gave a SOAP exception during initial connection attempt to ONLINE

I can`t figure out how to get a image or video posted to the basicUI. those items I could create:

String camera_image_URL {channel="ipcamera:ONVIF:21cd17f5:imageurl"}
String camera_video_URL {channel="ipcamera:ONVIF:21cd17f5:videourl"}

but what about the sitemap then and how to link the URL Strings?
Webview url=“” height=30
doesn`t work.
neither does (which I found on the device manager)

The links (assuming they are correct links for your camera) when used out of the binding probably fail as your camera needs credentials and the binding can’t do that if you r using the link manually. Look in PaperUI at what it shows as the video and snapshot links after the camera comes online.

You may need to wait until the binding has more work done to it, or disable the need for user and pass on your camera which is never a good idea but up to you. Your camera does what mine does and only reports RTSP links so to get moving video I will need to write the methods first that can do that which will take a while.

I completed motion detection for Amcrest and Foscam last night but need to have some users test it out. Will make a new build with this soon.

New build 19-04-2018 now available for testing with following changes:

  • Motion Alarm working for Amcrest

  • Motion and Audio Alarms added but not tested for Foscam. Need someone to test and post log file output in DEBUG should it not work.

  • PORT can now be set.

  • Digest and Basic auth is both working for me but needs testing on more cameras.

A lot has changed so any issues use previous build.