IpCamera: New IP Camera Binding

Hi I have this camera and I cannot setup the FTP server. I have a FTP server which works fine, I can connect in localhost, but I do not get conection from the IP camera.

Anyone has got it?
Other solution to save photos from the camera to my FTP server? thanks.

39

First of all many thanks for this great binding! Something like this has really been missing in OH2.

I can report a Foscam FI9900P working just fine with it.

My Foscam C2, though, is producing some errors though, as it does not have ONVIF in contrast to the FI9900P. Whatā€™s the recommended thing type for the C2? Still FOSCAM and ignoring the ONVIF errors?

@robert2 Thanks, glad you like it and find it useful. I have added your camera to the known working list. Yes ignore the error which will only occur when the camera connects, the ONVIF is only used for PTZ features for the cameras with an API.

1 Like

Hi! Iā€™ve put different times just in case. I had an impresion that openhab slows down.
Unfortunately Iā€™m getting ā€œjava out of heap spaceā€ after some time (1-5 days) when using your binding, therefore Iā€™ve removed it for now to check if thatā€™s the issue.

I think Iā€™m not alone here with this issue Max Heap Size

See this post here on how I fixed this in my setupā€¦

This binding uses the image item in a more aggressive way than other bindings, as well as the amount of RAM that is used and requires garbage clean up is also very high. Possibly there are settings for garbage collection that could be tweaked, have not looked into this yet as I do not see the error since the post above. Recently I have been setting up a new Odroid C2 server because it has more RAM than a PI2 so I have been rebooting daily whilst getting it setup, but Iā€™ll leave it running for a week to see what happens. Can you provide any more information on how you are using the setup? Are you running the picture on multiple tablets that are displaying 100% of the time? Anything in the logs?

1 Like

Iā€™ve done some test and can confirm your statement. I can open 4 parallel streams in browser and on 5th tab after trying to login receives a ā€œExceeded the maximum user numberā€ messages and jumps back to login prompt.
During these parallel streams I was still able to send control commands without problmes.
So the poll approched might work here

Thanks Skinah, for now I will try to increase memory following @Pedals2Paddles instruction and let you know if OOME will occur. If the issues will continue then some investigation will need to be done I guess as you posted in the Max Heap Size topic.

Sending eMail from the IP Camera (HIKVision in my case)

Hope this helps someone on the thread . . .

rule ā€œFront Door Camera Sees Motionā€
when
Item HIKFrontDoorMotion changed
then

	if (HIKFrontDoorMotion.state == ON)  {

		logWarn("HIK Motion", "** HIK Front Door Motion Detected **")

		val string FrontDoorCam = "FrontDoor"+ now.toString ("HH-mm_dd-MM-yyyy") +".jpg"

		Thread::sleep(4000)  // 4 second wait

		executeCommandLine("wget http://xxx:xxx@192.168.0.11:81/ISAPI/Streaming/channels/101/picture -O /tmp/" +FrontDoorCam)

		Thread::sleep(8000) // give OH time to download picture

		// send an email
		var toemailfrontmotion = "xxxxxxx@gmail.com"
		var subjectemailfrontmotion = "OpenHAB - HIK Motion Detected at Front Door"
		var bodyemailfrontmotion = "OpenHAB - HIK Motion Detected at Front Door."
		val URLfrontmotion = "file:///tmp/" + FrontDoorCam

		sendMail(toemailfrontmotion, subjectemailfrontmotion, bodyemailfrontmotion, URLfrontmotion)

		Thread::sleep(2000)  // 2 second wait

		toemailfrontmotion = ""
		subjectemailfrontmotion = ""
		bodyemailfrontmotion = ""

		executeCommandLine("rm /tmp/FrontDoor*.jpg")  // delete image file

		Thread::sleep(240000)  // 4 min wait for motion to clear so no excessive emails
	}

end

Best, Jay

1 Like

Hi Skinah,
still have issues with out of memory. Could there be some bug? I have 5 cameras so 5 image items with automatic refresh set up as above. It looks like OpenHAB fails pretty fast after I open up Basic UI to view those images.

Sure, but I have been over my code so many times since I had a few reports and it would have to only occur under certain situations for it to have slipped through. I have used Visual VM to analise the binding for memory leaks in an Openhab 2.2 runtime using Eclipse IDEā€¦

The binding does not do a single thing different when a UI is opened. As far as the binding goes it will fetch an image and place it in the IMAGE item which is part of the openhab framework, then the UI will fetch the image from the IMAGE item which is all openhab code and not mine. If it only occurs when you open Basic UI then it could be a bug in the openhab framework, or it may be an issue with garbage clean up. Perhaps try some of the following ideas to see if you see a patternā€¦

  1. Does it happen if you have all UI closed and only use paperUI control tab to watch the picture?
  2. Does stopping the image from updating in the bindings settings change anything?
  3. Does it occur when using the Android app on a tablet or phone?
  4. What happens with only 1 Camera? 2 cams, 3ā€¦ Is it only when you increase the amount of cameras, or use a certain model?

Also if you get an out of memory error with this active

EXTRA_JAVA_OPTS="-XX:+HeapDumpOnOutOfMemoryError -Xmx512m"

It will create a memory dump file that you can open and analyze with a program like Visual VM or Eclipse MAT that will tell you what it causing the memory to fill up.

Any chance we could get this binding to support saving the image to file, rather than an image item?

Bindings like the Pushover Action donā€™t support image items natively.

Cross posted on a Pushover thread:

I am trying to use the IPcamera binding to capture movement at the front door - then send the notification to my phone / watch.

Pushover is a tidy solution, since it can display the imageon my watch if needed :slight_smile:
Thanks

Nice post - can you tell me where the memory dump goes please?

I believe they will go into your user-data folder. The location was setup as a samba share in openhabian so it was easy to find as the file is large and I think had a extension of .hprof
I noticed in a forum post here that you can create a heap dump using the openhab console using this command, it may output to a zip fileā€¦

dev:dump-create

PR are welcome as that would be a simple change, but I donā€™t have the time to add such a feature. That is possibly a good idea for a standalone ā€œhelperā€ binding that could be created similar to the expire binding if there are other use cases for itā€¦ I am currently ā€œplayingā€ with a new feature for this binding and that is the ability to ā€œECHOā€ serve files. Basic idea is the binding is a http server and it can detect how many clients are connected to it and will only fetch the picture or a video stream when a UI is asking for it. This would mean for cameras that can not have authentication disabled or have a connection limit like Foscam it would open up more options as you use URLs from the bindings and not from the camera. Does this pose another solution to you? is the issue authentication or the need for an actual file?

My Intro: IP camera n00b

@matt1

From the list of cameras in your binding documentation, I cannot tell if cameras such as the WyzeCam (Xiaomi Xiaofang) or WyzeCam Pan (Xiaomi Dafang) are compatible with your binding. I donā€™t know if those cameras are ONVIF compatibleā€¦ even with the OpenIPC or the Dafang Hacks firmware flashed on them (it only mentions RTSP).

Iā€™m looking to deploy several cameras and looking for a cost effective (i.e., cheap) approach. Those cameras seem like good options in that sense. And, for all the reasons why I have openHAB in the first place, I want to keep control of the cameras localized (i.e., not on the camera vendorā€™s cloud or subscription).

If the answer to my camera question is no, is there a comparable line of inexpensive cameras that are compatible with your binding?

Thanks.

Mike

No one has reported if they work so I have no idea other than they will not have motion alarms and other features as they do not have an API afaik. If they have a snapshot URL that works then u possibly may get a picture.
I should stress that this binding is NOT an ONVIF binding, to be called that it needs to pass tests and support a minimum set of features, the same goes for cameras. Sadly the onvif tests are not independently tested/verified, so even if a camera claims it is ONVIF if the price tag of the camera is too low expect it to not really be 100% onvif without issues. A camera can pass onvif v1.0 spec and still advertise it is onvifā€¦
This binding only uses ONVIF for moving the camera with absolutue PTZ movements, there are two more types of ONVIF movements which are not implemented currently as they are not as useful in an openhab setup. The other thing it does is via ONVIF asks a camera what link to use for a snapshot and RTSP feeds, but currently the binding does not do RTSP. It is a long way from being able to call itself onvif and I have no plans to do that.

Check this post out, you may be able to use the same method to get RTSP feed with those cheap cameras you listed, but you still will have no alarm features without setting up a server using the software in my first post.

The foscam C1 (non lite model) is 4x the price and will give night vision and PIR sensor so will be far better against false movement alarms. The lite model is only 2x the price and has no night vision compared to WyzeCam.

WyzeCam Pan seems pretty close to what you can get Amcrest PTZ cameras for. Amcrest appears to be made by Dahua the second biggest ip camera manufacturer after Hikvision and the firmware seems good from what I have used so far.

I see it as silly to look at it as 2 or 4 times the price, instead consider it as an extra $50 per camera to save you from needing to spend a few hundred on a server to get video motion alarms and a lot easier setup in Openhab. Plus you may just get extra features in the camera like a better quality night vision picture or PIR sensors. Sometimes spending a little more is better value and a whole lot less headaches.

Thanks for the detailed response.

True - you get what you pay forā€¦ and sometimes you pay for what you get :wink:

Iā€™ll add your information to my research file. I have a couple other projects I want to tackle before I get to deploying cameras and integration to my openHAB instance.

Cheers!

Mike

This is great work, thanks.
Works great on my cheapo Sannce / Annke cams. Can get the Onvif paths using iSpy or the soutcefourge onvif app.
It is a little resource intensive though - kinda grinds my RaspberryPi in to the ground.

For now, I simple have an external PIR motion detector and run Ffmpeg using exec binding to snapshot and forward images via Pushover when needed.
Iā€™ll be keeping tabs on this binding though and will re-install when I upgrade my hardware.

Thanks for the hard work

1 Like

Hi @matt1

I just back to tesitng of Dahua IP cam with IPC-HFW4431R-Z

On begnigng screenshot form Cam was working but after some time is not any more updated

Coudl you please look why ?

Please see first log:

> 2018-09-10 19:16:33.506 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.2.10, 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.507 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just locked in main1
> 2018-09-10 19:16:33.509 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just unlocked main1
> 2018-09-10 19:16:33.511 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 7 channels tracked (some of these may be closed).
> 2018-09-10 19:16:33.515 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.516 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:1 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.518 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.2.10, 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.519 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just locked in main1
> 2018-09-10 19:16:33.521 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just unlocked main1
> 2018-09-10 19:16:33.524 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 7 channels tracked (some of these may be closed).
> 2018-09-10 19:16:33.528 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.530 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:2 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.547 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - 401: Normal for DIGEST authorization. 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.549 [DEBUG] [ipcamera.internal.MyNettyAuthHandler] - 401: Mark as closing, the  channel:1 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.553 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Resending using a fresh DIGEST 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.555 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.2.10, 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.558 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just locked in main1
> 2018-09-10 19:16:33.560 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just unlocked main1
> 2018-09-10 19:16:33.561 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - 401: Normal for DIGEST authorization. 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.563 [DEBUG] [ipcamera.internal.MyNettyAuthHandler] - 401: Mark as closing, the  channel:2 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.565 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Resending using a fresh DIGEST 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.565 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 7 channels tracked (some of these may be closed).
> 2018-09-10 19:16:33.567 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.2.10, 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.569 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just locked in main1
> 2018-09-10 19:16:33.569 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.571 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Just unlocked main1
> 2018-09-10 19:16:33.574 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 7 channels tracked (some of these may be closed).
> 2018-09-10 19:16:33.574 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:4 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.578 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.580 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:5 	GET:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.580 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
> HTTP/1.1 401 Unauthorized
> WWW-Authenticate: Digest realm="Login to 3L08221PAA35018", qop="auth", nonce="1974546864", opaque="0ad03079faa3a901586f69bd4837dc33cfadeeb1"
> Connection: close
> CONTENT-LENGTH: 0
> 2018-09-10 19:16:33.583 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
> HTTP/1.1 401 Unauthorized
> WWW-Authenticate: Digest realm="Login to 3L08221PAA35018", qop="auth", nonce="1934386125", opaque="0ad03079faa3a901586f69bd4837dc33cfadeeb1"
> Connection: close
> CONTENT-LENGTH: 0
> 2018-09-10 19:16:33.585 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:2 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.586 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Message passed on from new code, must be EmptyLastHttpContent
> 2018-09-10 19:16:33.586 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:1 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.588 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent
> 2018-09-10 19:16:33.590 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:2 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.591 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Message passed on from new code, must be EmptyLastHttpContent
> 2018-09-10 19:16:33.592 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.595 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent
> 2018-09-10 19:16:33.598 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:1 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.600 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.633 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
> HTTP/1.1 400 Bad Request
> Connection: close
> Content-type: text/plain;charset=utf-8
> Content-Length: 21
> 2018-09-10 19:16:33.635 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:4 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.636 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Message passed on from new code, must be EmptyLastHttpContent
> 2018-09-10 19:16:33.638 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 21, cap: 21/21, unwrapped: PooledUnsafeDirectByteBuf(ridx: 128, widx: 128, cap: 1024)), decoderResult: success)
> 2018-09-10 19:16:33.641 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:Error
> Bad Request!
> :
> 2018-09-10 19:16:33.641 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
> HTTP/1.1 400 Bad Request
> Connection: close
> Content-type: text/plain;charset=utf-8
> Content-Length: 21
> 2018-09-10 19:16:33.643 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:5 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.645 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Message passed on from new code, must be EmptyLastHttpContent
> 2018-09-10 19:16:33.645 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:4 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.646 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 21, cap: 21/21, unwrapped: PooledUnsafeDirectByteBuf(ridx: 128, widx: 128, cap: 1024)), decoderResult: success)
> 2018-09-10 19:16:33.647 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/configManager.cgi?action=getConfig&name=VideoMotion
> 2018-09-10 19:16:33.648 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:Error
> Bad Request!
> :
> 2018-09-10 19:16:33.651 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:5 	URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.652 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/configManager.cgi?action=getConfig&name=CrossLineDetection
> 2018-09-10 19:16:33.685 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 566, cap: 566/566, unwrapped: PooledUnsafeDirectByteBuf(ridx: 566, widx: 566, cap: 2048)), decoderResult: success)
> 2018-09-10 19:16:33.687 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:--boundary
> Content-Type: application/xml; charset="UTF-8"
> Content-Length: 483

Your log is only 180ms long and does not show when the camera trys to fetch a picture.
The only interesting thing I see is the 400 bad request, which is probably because the feature being checked does not exsist on your camera ie it has no mic and hence no audio alarm.

I would need some log output showing where the picture URL is shown, if you do not see this happening it could be you have set the camera to not update the picture which if you move the update picture now switch it should update a single time.