Generic IP Camera binding

BTW - The Mobile SDK documentation is here: http://doc.developer.milestonesys.com/mipsdkmobile/index.html

Hello Dave,

I installed already over 7 years milestone systems for my work. There is no other camera system that works the same as Milestone. Im not an programmer im sorryā€¦ But as reseller i can do some tests if you want. Please let me know if i can do something. Kind regards.

Milestoneā€™s latest re-work making Essential+ the new free version is pretty awesome! It adds a lot of features to the free version which really make it stand head and shoulders above all the other offerings as long as you can live with that 8 camera limit.

I would love to see an openhab integration for it. I hope you get the time to do that.

Hey @_Thomas ,
Can you please post your .items .sitemaps and .things configurations for this binding,
Thanks in Advance.

For HikVision, url is:

http://login:password@your.ip.address.here/ISAPI/Streaming/channels/101/picture?snapShotImageType=JPEG

so, you should use this url: http://your.ip.address.here/ISAPI/Streaming/channels/101/picture?snapShotImageType=JPEG

and paste login and password in settings. Worked with my HikVision.

camera.things:

camera:camera:garage [ urlUsername="admin", urlPassword="yourpass", poll=5, urlVideo="http://ip.camera.ip.or.fqdn/ISAPI/Streaming/channels/101/picture?snapShotImageType=JPEG", urlSnapshot="http://ip.camera.ip.or.fqdn/ISAPI/Streaming/channels/101/picture?snapShotImageType=JPEG" ]

camera.items:

Image CameraGarage "Garage Camera" <camera> { channel="camera:camera:garage:image" }

camera.sitemap:

sitemap default label="IP Camera"
{
	Frame label="Home" {
	    Text label="Garage Camera" icon="camera" {
					Image item=CameraGarage 
	    }
	}
}
2 Likes

Thanks for the reply @Bagumka,

there is one more query,
does all ip camera has same url format you provided??
iā€™ve sannce 720p ip camera, is there any other url format than this ??
(Sorry for the noob question but iā€™m just getting started with the cameras and donā€™t know much about itā€¦)

As I know, brands have their own unified url format. I mean:

HikVision have:
http://login:password@your.ip.address.here/ISAPI/Streaming/channels/101/picture?snapShotImageType=JPEG

Dahua have:
something otherā€¦

Hello Vadym,

The url is working you are right!! Thanksā€¦ but there is one problem.
When i worked on the habpanel and i save and run i get an error.

java.lang.OutOfMemoryError: Java heap space

It isnā€™t directly but most of the time after 2 or 3 times save and run.
Do you know how i can fix this.

Caused by: java.lang.OutOfMemoryError: Java heap space

2018-03-09 09:39:16.493 [ERROR] [ops4j.pax.logging.pax-logging-log4j2] - FrameworkEvent ERROR - org.ops4j.pax.logging.pax-logging-log4j2

java.lang.OutOfMemoryError: Java heap space

2018-03-09 09:39:19.868 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ā€˜ThingHandler.handleCommand()ā€™ on ā€˜org.openhab.binding.camera.handler.CameraHandler@1250720ā€™: Java heap space

java.lang.OutOfMemoryError: Java heap space

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

2018-03-09 09:46:07.637 [ome.event.ItemCommandEvent] - Item ā€˜CamTuin_Imageā€™ received command REFRESH

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

2018-03-09 09:46:13.040 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ā€˜ThingHandler.handleCommand()ā€™ on ā€˜org.openhab.binding.camera.handler.CameraHandler@1250720ā€™: Java heap space

java.lang.OutOfMemoryError: Java heap space

I donā€™t saw that problem, but I donā€™t have OpenHAB in production, just testing. I Try to run it for some time to test.

Is there any Onvif or RTSP protocol support in any bindings in Openhab2?

Because RTSP is not supported yet, I used ffmpeg (ffserver) to transform the only available feed of my old Kaicong camera from RTSP to HTML (MJPEG).

It works fine and Iā€™m able to use that HTML feed with Habpanel. The feed look like this: http://xxx.xxx.x.xx:8090/camera1.mjpeg

Now, Iā€™m trying to use the Camera binding to get an image feed on my sitemap. I probably do not understand yet what is supported and what is not supported but Iā€™m unable to make it work.

I do understand that video URL is not supported yet, but only Snapshot URL. I tried to use the mjpeg feed into snapshot URL field but the Openhab Thing remain always OFFLINE.

What should I do to get the Thing Online? Thanks.

UPDATE:
I tried something else without success, so I still need help. I installed Zoneminder. RTSP feed is easy to configure. Zoneminder use ffmpeg to generate a new feed who can be used in an embeded URL link. This link (http://xxx.xxx.x.xx/zm/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=50&maxfps=15) is working in any browser. I copied it into the binding Snapshot URL field but Thing still offline.

Any help would be welcome.

@_Thomas
What is the current status of this binding? Is anyone actively coding as I am interested in making a binding with many more features but donā€™t wish to make huge changes if they are not going to get accepted.

@cailleute,

look at the zoneminder binding from @mr_eskildsen - I implemented the zm jpeg/mjpeg feed there. One thing with mjpeg (or any other stream) is that the default settings of the proxy in openhab will kill the feed after 1 minute. Youā€™ll need the patch in this bug report: https://github.com/eclipse/smarthome/issues/4873 to make it work longer than one minute. JPEG images work ok.

Cheers,
-Th

Be sure to grab the marketplace binding. Sine it is only implementering there

Thanks @captndelta and @mr_eskildsen! I didnā€™t know about your work Martin. Great binding! It will fit perfectly my needā€¦ if I succeed to make it work.

I do not want to use an hardware NVR so Iā€™m doing test with zoneminder on an hold PC running Linux. I will buy better hardware later to build an home made NAS based on FreeNas. So, I hope my current problem is not related to the poor hardware performance. So, maybe one of you could help me to figure it out what is my problem:

I didnā€™t change a lot of thing in the basic zoneminder configuration.

  • add a new admin user
  • check both option OPT_USE_API and OPT_TRIGGER to allow binding to make connection.

On the binding itself:

  • entered IP address of my zoneminder server
  • credentials of the new admin user I created. (Iā€™m using this user too to reach zoneminder console.)

From the zoneminder console, I see my camera feed. On Openhab side, Things are switching from online to offline to online etc. I have the following error in my log:

2018-04-05 16:05:33.737 [ERROR] [andler.ZoneMinderThingMonitorHandler] - [MONITOR-1]: context='fetchMonitorDaemonStatus' error in call to 'getMonitorData' Exception='name.eskildsen.zoneminder.exception.ZoneMinderAuthenticationException' Message='Unable to authenticate in ZoneMinder'

name.eskildsen.zoneminder.exception.ZoneMinderResponseException:  - HttpStatus='401', HttpMessage='Unauthorized', Request='http://192.168.x.xx/zm/api/monitors/1.json', ExceptionMessage='Not Authenticated'	

It looks like my credentials are not valid, but Iā€™m using exactly the same to reach console. Same credential is used if I call manually the JPEG feed at this address:

http://192.168.x.xx/zm/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=100&maxfps=25&user=myuser&pass=mypassword

Is there something I could try? Thanks.

That might be a little tricky to say soā€¦ The problem is that the process of determining that isnā€™t straight forward. So there might be a wrong conclusion in the code.
Since you are using the admin user, I guess that it shouldnā€™t be missing access rights.Since you can logon to ZoneMinder console it should be fine.
What happens if you logon to ZM console and the afterwards tries to access the api from the browser:
ā€œhttp://192.168.x.xx/zm/api/monitors/1.jsonā€?
That should return a JSON with data for monitor 1.

If that doesnā€™t work, the problem would be something in your ZoneMinder setup. If it does work, you should try to disable authentication in ZoneMinder. If you use any special characters in your password, try to change it to a more simple password (off course you should be able to use special characters, but for test purposes).

Thanks @mr_eskildsen, you show me the right direction. Accessing the api from the browser is the fastest way to see if there is access error. You were right, currently Iā€™m just able to make it work without authentication. I will make more test later on my zoneminder configuration.

So for the moment, just some more general questions. I probably miss something in the Openhab documentation but I donā€™t understand how to handle item related to video and image into sitemap.

I have two items:

Image Cam_monitor1_image  "Cam_1 image"	 {channel="zoneminder:monitor:aec1aeed:monitor-1:image"}
String Cam_monitor1_video  "Cam_1 video" {channel="zoneminder:monitor:aec1aeed:monitor-1:videourl"}
  1. With the image item, I cannot use: Image item= Cam_monitor1_image. SmartHome designer give an error. I can just use: Default item=Cam_monitor1_image. By this way, I get a static image.

2a) For the String item related to video. I just donā€™t understand how to use the String value returned by the binding. I can hardcode the url of this string in a Webview (Webview url=ā€˜http://192.168.x.xx/zm/cgi-bin/nph-zms?monitor=1&scale=20&buffer=1000ā€™ height=5) but nothing else directly by the way of the item name itself

2b) If I use a Webview, I get a static image, not a camera feed. However Iā€™m sure the url is good because if I use it directly into a browser, I get the real time camera feed.

  1. Iā€™m not able to use Video in sitemap. Just by the way of hardcoding an URL. Am I right to think this is useless for a real time camera signal?

  2. Finally, if I finish by getting something (static or real time feed) in BasicUi sitemap on my PC, should I get the same result from the IOS OpenHab app? If yes, should I get the same result if the IOS Openhab connection is remote (outside of my network)?

@cailleute,
for (1.): Iā€™ve only tried it in the ā€˜regularā€™ sitemap files, things were working for me there. You have to use the image item as the ā€˜itemā€™ in the sitemaps ā€˜Imageā€™ element (donā€™t use the url at the same time). There is a setting for images how often they are updated in the settings of the binding.
for (2.a): If you look at the ā€œvideoā€ element in https://docs.openhab.org/configuration/sitemaps.html#element-type-video , it says that ā€œitem can refer to a String Item whose state is a URL to a videoā€. Donā€™t set the URL in that case. You still have to set the encoding (only mjpeg supported). I have not tried that in Webview, itā€™ll probably not work (unless the ā€˜itemā€™ there has the same behavior, but canā€™t find anything documented to that effect)
for (3): see 2a
EDIT (forgot to answer 4.): As long as you can access your openhab site outside of your network, you should also see the video/image feed. Those are proxied thru your openhab server. (the internal URLā€™s are no longer used)

Cheers,
-Th

Strange, but if it doesnā€™t work from the browser, it wonā€™t work in the binding :slight_smile:

Default item=Cam_monitor1 should be fine. The Binding will update the image.

For the moment openHAB doesnā€™t support a video item type, this means that the binding has no way of returning the video stream. I am not using the video url myself, and it is also considered experimental. I think what you describe is just the way it is right now. :frowning:

You should get the same stream both in your PC, IOS app internal as well as external. But that is all core openHAB. If things works on your PC, everything should be fine.