IpCamera: New IP Camera Binding

Hi Matt, Thanks for inplementation, In general output control is working ok i will test it longer but need to fix first connection issue to cam (switch to POE 48V to have less voltage drop on line)

I’d like to have a look into this as my China-ONVIF-camera (doesn’t have a brand Name, but identifies as HIKVISION?) has no API also.
I’m running OH2 2.4stable on my raspberry3. So I dropped the 2.4 (31.12.2018) version and the 2.5 (12.01.2019) in /srv/openhab2-addons but nothing happens afterwards… tried it in two instances? Do I miss something?

Hi Matt,

Thanks, I removed everything I’d done and re-added through the PaperUI - I had tried to do it manually as per your guide, but I’d obviously messed something up. Added using Hikivision module through the PaperUI and everything works seemlessly inc motion detection.

Thanks for the reassurance about the images and thanks again for a really great binding.

New build 19-01-2019 has these changes:

  • Cameras now default to updating snapshot every 2 seconds by default instead of 5. Examples in readme also updated.

  • Now PTZ is delayed so if a rule sends updates to all three values they get processed once and the camera makes the movement in a single motion. Example rule and how I use the PTZ feature to give default locations that can be jumped between is found in the readme under the full example section.

  • Less logging is created especially if a camera goes offline it now only logs a single error when the camera first goes offline and not everytime the binding checks if the camera can be reached.

New build 26-01-19 has following changes:

  • Dahua stream should now stay open and not need reopening over and over. Was able to reproduce it @yfaway had this issue. This means you can increase the polling time if you dont want 1 second updates without effecting the alarm stream.
  • Changes to logging.
  • New Netty library version.
  • Changes to way cameras reconnect when they go offline.
1 Like

I have the binding from 31-12-2018 working with a HikVision DS-2CD2042WD-I on firmware v180730 which I believe is the latest firmware for the camera.

I have used the motion detection switch to trigger a rule that sends the most recently captured picture to my devices via Telegram:

rule "Send telegram with fixed message when front door camera intrusion detected"
when
    Item FrontDoorCamera_IntrusionAlarm changed from OFF to ON
then
    logInfo("Dev", "Front door camera intrusion detected.")
    sendTelegram("TelegramBot", "Front door camera intrusion detected")
    var String base64Image0 = FrontDoorCamera_JPGImage.state.toFullString
    sendTelegramPhoto("TelegramBot", base64Image0, "Intrusion detected at front door")
	TVLGWebOSTV_1_Toast.sendCommand("Front door camera intrusion detected")
end

Thanks for this great binding. Are there any tests you’d like me to perform with this camera that would help with further development?

1 Like

Thanks Matt,

I try to install your binding, but after dropping the JAR in the /srv/openhab2-addons Directory, nothing happens: I don’t get entries in the logfiles. I’m running openHABian on a Raspberry PI: openHAB 2.4 stable. Do I miss something?

You need to start your own thread, something is wrong with your openhab installation. It will mean looking at the bundles in Karaf console or may be a config file stopping it. This is not something I know much about.

1 Like

A similar thing happened to me. After a few restarts and clearing the cache using the command “openhab-cli clean-cache” the binding appeared as an option when trying to add things from the Paper UI.

1 Like

Thanks for reporting the camera model, added it to the list in the first post of this thread. If you want to help with testing, then download the latest version and see if you can find a bug. Also it would be great to have some more examples of rules like the one you posted in the readme.md file. Feel free to do a PR on github to add your example rule and any others you think people may find useful.

Just wondering if this binding will work with any of the Panasonic ONVIF IP cameras?

The answer to that in detail is found here first paragraph of readme.

Hi matt1,
You can add my cameras and the recorder to the list.
They work well with binding (only without PTZ control)

NVR - DS-7616NI-K2 / 16P
CAM - DS-2DE3304W-DE

1 Like

Thanks - now after cleaning the cache, I had the binding up and running - but still no entry in the log for “Installation”. @matt1 perhaps you could add a log entry after successfully Installation of the item. Other JAR-Drop-Bindings offer that, so I guess, there must be some Kind of Event for add-on Installation! would be great to know I guess?

Thanks - now I’m working through my camera.

Ok - as my cam is a nobrand China IP camera (here the link at gearbest), I used the “ONVIF”-channel in my thing-configuration (I masked the credentials):

Thing ipcamera:ONVIF:001 [ IPADDRESS="192.168.xx.yy", PASSWORD="<<PASS>>", USERNAME="<<USER>>", ONVIF_PORT=8080, PORT=80, POLL_CAMERA_MS=10000]

while using the Sliders in your .sitemap example, the camera just moves but never stops until it is at the end of physical movement…

It appears, the camera says it supports absolute PAN/TILT, but doesn’t? Or do I miss something? (I use the .items and .sitemap from your examples)
the log in TRACE:

2019-01-28 13:15:46.628 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.xx.yy:8080
2019-01-28 13:15:50.688 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Fetching the number of Media Profiles this camera supports.
2019-01-28 13:15:53.892 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Checking the selected Media Profile is a valid number.
2019-01-28 13:15:53.894 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Fetching a Token for the selected Media Profile.
2019-01-28 13:15:53.896 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Auto fetching the snapshot URL for the selected Media Profile.
2019-01-28 13:15:56.596 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to fetch some information about the Media Profiles from the camera
2019-01-28 13:15:56.600 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - *********** Media Profile 0 details reported by camera at IP:192.168.xx.yy ***********
2019-01-28 13:15:56.602 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera will use this Media Profile unless you change it in the bindings settings.
2019-01-28 13:15:56.605 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 is named:main_video_encoder_cfg
2019-01-28 13:15:56.607 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video encoder	:H_264
2019-01-28 13:15:56.609 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video quality	:6.0
2019-01-28 13:15:56.611 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video resoltion	:1280 x 720
2019-01-28 13:15:56.613 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video bitrate	:4096
2019-01-28 13:15:56.614 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - *********** Media Profile 1 details reported by camera at IP:192.168.xx.yy ***********
2019-01-28 13:15:56.616 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 is named:sub_video_encoder_cfg
2019-01-28 13:15:56.618 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video encoder	:H_264
2019-01-28 13:15:56.620 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video quality	:6.0
2019-01-28 13:15:56.621 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video resoltion	:640 x 352
2019-01-28 13:15:56.623 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video bitrate	:1024
2019-01-28 13:15:56.624 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to interrogate the camera to see if it supports PTZ.
2019-01-28 13:16:02.516 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Camera is reporting that it supports PTZ control with Absolute movement via ONVIF
2019-01-28 13:16:02.519 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Checking Pan now.
2019-01-28 13:16:08.060 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Checking Tilt now.
2019-01-28 13:16:14.089 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Checking Zoom now.
2019-01-28 13:16:25.077 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has reported the range of movements it supports via PTZ.
2019-01-28 13:16:25.080 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - The camera can Pan  from -1.0 to 1.0
2019-01-28 13:16:25.082 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - The camera can Tilt from -1.0 to 1.0
2019-01-28 13:16:25.085 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - The camera can Zoom from -1.0 to 1.0
2019-01-28 13:16:25.087 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Fetching the cameras current position.
2019-01-28 13:16:27.659 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Camera did not give a good reply when asked what its position was, going to fake the position so PTZ still works.
2019-01-28 13:16:27.662 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Finished with PTZ with no errors, now fetching the Video URL for RTSP from the camera.
2019-01-28 13:16:32.836 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.xx.yy, 	URL:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:32.844 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 0 channels tracked (some of these may be closed).
2019-01-28 13:16:32.851 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:32.855 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have  opened  a  brand NEW channel:0 	GET:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:32.869 [hingStatusInfoChangedEvent] - 'ipcamera:ONVIF:001' changed from INITIALIZING to ONLINE
2019-01-28 13:16:32.879 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Pan is updating to:50 and the cam value is 0.0
2019-01-28 13:16:32.884 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Tilt is updating to:50 and the cam value is 0.0
2019-01-28 13:16:32.884 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Zoom is updating to:50 and the cam value is 0.0
2019-01-28 13:16:32.900 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
2019-01-28 13:16:32.904 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:0 	URL:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:32.923 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: PooledUnsafeDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
2019-01-28 13:16:32.935 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 8192, widx: 16384, cap: 16384)), decoderResult: success)
2019-01-28 13:16:32.968 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 16384, widx: 16384, cap: 16384)), decoderResult: success)
2019-01-28 13:16:32.973 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 8192, widx: 30660, cap: 65536)), decoderResult: success)
2019-01-28 13:16:32.979 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 16384, widx: 30660, cap: 65536)), decoderResult: success)
2019-01-28 13:16:32.983 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 24576, widx: 30660, cap: 65536)), decoderResult: success)
2019-01-28 13:16:32.989 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 6084, cap: 6084/6084, unwrapped: PooledUnsafeDirectByteBuf(ridx: 30660, widx: 30660, cap: 65536)), decoderResult: success)
2019-01-28 13:16:33.000 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Snapshot recieved: Binding will now close the channel.
2019-01-28 13:16:33.003 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0 	URL:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:33.005 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:33.862 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.xx.yy, 	URL:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:33.872 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 1 channels tracked (some of these may be closed).
2019-01-28 13:16:33.879 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:33.880 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:0 	GET:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:33.905 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
2019-01-28 13:16:33.912 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:0 	URL:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:33.925 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: PooledUnsafeDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
2019-01-28 13:16:33.930 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 8192, widx: 16384, cap: 16384)), decoderResult: success)
2019-01-28 13:16:33.936 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 16384, widx: 16384, cap: 16384)), decoderResult: success)
2019-01-28 13:16:33.943 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 8192, widx: 30690, cap: 65536)), decoderResult: success)
2019-01-28 13:16:33.948 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 16384, widx: 30690, cap: 65536)), decoderResult: success)
2019-01-28 13:16:33.955 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 24576, widx: 30690, cap: 65536)), decoderResult: success)
2019-01-28 13:16:33.960 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 6114, cap: 6114/6114, unwrapped: PooledUnsafeDirectByteBuf(ridx: 30690, widx: 30690, cap: 65536)), decoderResult: success)
2019-01-28 13:16:33.971 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Snapshot recieved: Binding will now close the channel.
2019-01-28 13:16:33.975 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0 	URL:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:33.977 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:43.859 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.xx.yy, 	URL:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:43.866 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 1 channels tracked (some of these may be closed).
2019-01-28 13:16:43.875 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:43.877 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:0 	GET:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:43.919 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
2019-01-28 13:16:43.924 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:0 	URL:/web/auto.jpg?-usr=<<USER>>&-pwd=<<PASS>>&
2019-01-28 13:16:43.947 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: PooledUnsafeDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
...

How good are Dahua´s motion detection? Is it rubbish? How fast is it to trigger/re-trigger?

That depends on which motion detection you refer to. You always find the tripwire/line crossing alarms and intrusion alarms to have less false positives than a generic ‘motion alarm’, this is true of both the big selling brands so choose a camera that has at least these smart alarms to give more options as even the entry level cameras now have them. You can also do masking of areas to ignore tree branch movement. Camera with alarm inputs are working and it is common to use external PIR sensor connected to these alarm inputs if that suits what you are trying to do more than other alarm triggers. This forum is not the best place to get feedback on what the alarms are like. A good forum is “IP cam talk”.

Dahua are great for this as they have the ability to change a DEBOUNCE setting by the API, the binding sets this to 1 second so you can have it trigger right away and then have retriggers 1 second later if the movement is start/stop motion. Constant movement is seen as only a single trigger.

Thanks…
My idea was to use ip cameras insted of traditional motion sensors specially outside around our house.

Traditional sensors are cheaper, use less power to run and work based on heat and movement. You can get ones that ignore pets like a neighbours cat. But even PIR sensors trigger false positives but less often than a generic motion alarm.
Cameras with built in pir cost more than ones that do not but they are made.

I know cameras are more expencive also on energy. It´s just that I want motion detection outside around the house, (I was original planning to use traditional motion sensors). But I also wants cameras. Then I thought, why not combine this option and go for cameras with build in motion detection. But the motion detection has to be as good as traditional motion sensors.