IpCamera: New IP Camera Binding

I synchronised the time and checked the timezone is the same. No change. I think the camera is configured correctly with ONVIF and user credential, as it worked fine before the upgrade. Thanks for your help, I am looking forward to root causing and fixing my issue.

@ppieczul

Did you set your camera to Basic/Digest auth?

@Nanna_Agesen thanks, it is a hint in the right direction. I have only digest authentication. When I allow basic, it starts working. So there is some issue with authentication using digest. But I don’t want to allow basic authentication as it gives away the credentials over the network. Thanks!

1 Like

Thanks to both of you for the info, I can reproduce it here and have it fixed already, just need time to test it before making a build.

@ppieczul
Build is now uploaded, please try it out.

Sorry for the noob question (one more)

Setting httponly protocol on SV3C camera, … when motioncontrol channel is finally triggering?
Perheaps there’s no guarantee by the bind that this will happen with the two SV3C & HTTPONLY?

I doubt "enableMotionAlarm channel, is requested to be switched on to have motionalarm ready to trigger. I’m I wrong?

Sorry but documentation doesn’t clarify to me

Switch      Batu_CamEnableMotion "MotionAlarm on/off" { channel="ipcamera:HTTPONLY:001:enableMotionAlarm" }
Switch      Batu_CamMotionAlarm "Motion detected"   { channel="ipcamera:HTTPONLY:001:motionAlarm" }

I assume this because I never see the switch changing in my sitemap definition

        Default item=Batu_CamMotionAlarm icon=siren

Please use this thread instead for any further questions, feedback and requests to have the features added to for cropping ability which so far no one seems interested so have not bothered to add it. Seems to work fine on my cameras with the time ticking over, but for tree movement cropping is a must have IMHO.

Readme has full example for a http only camera and you are using the wrong channel for turning the motion on and off. Cameras with APIs will probably get the control added at some stage so you can use the built in motion control of the camera or use the ffmpeg one on demand. There is also a newish channel for hooking in an external PIR sensor.

https://github.com/Skinah/IpCamera#full-example

Dimmer HttpOnlyMotionControl "Motion Threshold [%d]" { channel="ipcamera:HTTPONLY:TestCam:controlMotionAlarm" }
Switch HttpOnlyMotionAlarm "Motion detected" { channel="ipcamera:HTTPONLY:TestCam:motionAlarm" }

Thanks Matthew, you’re so kindly as always
You’re right, channel was wrong but it was a pubblishing problem as I’d have pubblish this instead to enabling motion

Switch      Batu_CamEnableMotion "MotionAlarm on/off" { channel="ipcamera:HTTPONLY:001:enableMotionAlarm" }

I was tumbling into the thread you suggested but the basic question and the reason why I was not considering as a primary solution is:
So direct motioncontrol via the binding is only for API camera?

Yes only for api cameras right now
Onvif will also use it when/if it gets implemented.

All cameras will at some point get the ffmpeg motion controls which will work separately on two types of motion detection. It uses no cpu when turned off.

1 Like

Hi, do not know if I’m in the right topic, can someone help me? I have several PTZ YOOSEE cameras, not sure about the brand, but they support RTSP streaming in the following format over VLC: rtsp://login:password@CAMERAIP:554/onvif1

How can I display the image from ipcamera in openhab2’s basicui?

You can do a mjpeg, jpeg, or hls stream, make sure you have your thing defined correctly for server port (i.e. 50001 or a unique number) , ip_whitelist, FFMPEG_OUTPUT, etc.

My snapshot url was different and I had to put in an override for that.

I have had to read the readme on github several times, but i think all the information is there. Its a really good aid.

Text label="Camera Mjpeg Stream" icon="camera" {Video url="http://192.168.x.xxx:50001snapshots.mjpeg" encoding="mjpeg" }
        Text label="jpeg Stream" icon="camera" {Image url="http://192.168.x.xxx:50001/ipcamera.jpg" refresh=2000}
        Text label="HLS Webview Stream" icon="camera"{Webview url="http://192.168.x.xxx:50001/ipcamera.m3u8" height=15}
String FrontEntrywayStreamUrl "Mjpeg Stream" { channel="ipcamera:ONVIF:FrontEntryway:streamUrl" }
String FrontEntryjpeg "jpeg" { channel="ipcamera:ONVIF:FrontEntryway:imageuUrl" }
String FrontEntrywayHlsStreamUrl "HLS Stream" { channel="ipcamera:ONVIF:FrontEntryway:hlsUrl", ga="Camera" [ protocols="hls" ] }

Hi,
is it possible to add V380 camera support? As ONVIF it can’t be added as snapshot URL is not supported (only rtsp stream)
https://github.com/brusdev/V380-SDK

If it has no snapshot then it is not onvif. For RTSP only cameras they work using the http only examples in the readme.

Hi
I have a hikam A7 with onvif. The only thing I want to have is to view the livestream of my camera. Maybe turned on by an external motion detector.
When I try to install ffmpeg via apt install, i get the following:
Package ffmpeg is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package ‘ffmpeg’ has no installation candidate

Do I have to do something else?
BR
Daniel

https://www.ffmpeg.org/
Or use google to find a guide.

Hey all,

I have observed a behavior from using snapshots to create GIFs and I am wondering if this is normal behavior. So I am using 2 ONVIF cameras (Reolinks 520’s) and they require a Snapshot_url_override.

This is fine, set up first camera. Everything working as expected. Set up 2nd camera. Different SERVER_PORT. All values in thing definition are unique to each camera as needed. First camera not working to create GIFs now. I check the debug logs and 1s camera no longer generating snapshots at polling interval.

So after some verifying and experimenting, I set the ONVIF_Media_Profile=1 on the 1st camera (It is =0 on 2nd camera) Now both are generating snapshots per the debug log and everything is back to normal.

Is this the expected behavior?

Hi All,
I am using Hikvision 2CD2646G1-IZS cameras and am having trouble getting alerts. In the log I see messages indicating the channel was closed and that the alarm stream was not running, but it appears to correct itself - at least I dont see ongoing problems. The alerts are Smart Events. Access is via CGI - ONVIF is disabled.

2020-03-26 09:45:15.204 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - !!!! Camera possibly closed the channel on the binding, cause reported is: {}
        at org.openhab.binding.ipcamera.handler.IpCameraHandler.sendHttpRequest(IpCameraHandler.java:566) ~[?:?]
        at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.processAuth(MyNettyAuthHandler.java:177) ~[?:?]
        at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.channelRead(MyNettyAuthHandler.java:232) ~[?:?]
2020-03-26 09:45:16.084 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture
2020-03-26 09:45:16.086 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.1.212, re-starting it now
2020-03-26 09:45:16.087 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Event/notification/alertStream

I have checked the alertstream via URL and the camera responds to an intrusion event with:

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.1.212</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>bc:ba:c2:e3:db:fd</macAddress>
<channelID>1</channelID>
<dateTime>2020-03-26T11:06:51+00:00</dateTime>
<activePostCount>1</activePostCount>
<eventType>fielddetection</eventType>
<eventState>active</eventState>
<eventDescription>fielddetection alarm</eventDescription>
<DetectionRegionList>
<DetectionRegionEntry>
<regionID>1</regionID>
<sensitivityLevel>50</sensitivityLevel>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>156</positionX>
<positionY>926</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>710</positionX>
<positionY>157</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>981</positionX>
<positionY>253</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>964</positionX>
<positionY>966</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
</DetectionRegionEntry>
</DetectionRegionList>
<channelName></channelName>
<Extensions version="1.0" xmlns="urn:psialliance-org">
<serialNumber xmlns="urn:selfextension:psiaext-ver10-xsd">DS-2CD2646G1-IZS20190911AAWRD60961157</serialNumber>
<eventPush xmlns="urn:selfextension:psiaext-ver10-xsd">DS-2CD2646G1-IZS20190911AAWRD60961157,2020-03-26T11:06:51+00:00,0,1.0</eventPush>
</Extensions>
</EventNotificationAlert>

I assumed this would create an alert on the following item:

Switch   East_Camera_FieldDetectionAlarm             "Intrusion alarm"   (gCameraEvent)  {channel="ipcamera:HIKVISION:KitchenCam:fieldDetectionAlarm"}

But I see nothing in the events log or openhab log to even suggest that the binding actually received the alert.
Any ideas on what I can do next to troubleshoot?

Kind Regards
Martin

The readme tells you what to do next, hint TRACE logs.

edit:
@hoggm2
I checked the code for bugs or typos and found none, it should work fine with the output you posted. My best guess at this stage is you need to reboot as Openhab has not created the items or the links correctly. It can take 3+ reboots if you have never used the binding before or if you clear the cache and tmp.

Hi Matt,
thanks for what you are doing. Really Openhab newbye over here,
trying to connect to my 3 dahua cameras. I can’t get the snapshot or stream in PaperUI control.
The cameras has ONVIF support:


This link works in vlc: rtsp://admin:password@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
and this is the snapshot http link (with authentication)
/onvifsnapshot/media_service/snapshot?channel=1&subtype=0
My log:
2020-03-27 16:58:36.400 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 48, cap: 48/48, unwrapped: PooledUnsafeDirectByteBuf(ridx: 138, widx: 138, cap: 1024)), decoderResult: success)
2020-03-27 16:58:36.401 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.108http://192.168.1.108/onvifsnapshot/media_service/snapshot?channel=1&subtype=0
2020-03-27 16:58:36.410 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.108http://192.168.1.108/onvifsnapshot/media_service/snapshot?channel=1&subtype=0
2020-03-27 16:58:36.410 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 404 Not Found
It seems like ip appears twice. Thing configuration seems ok, any idea?
Thanks.
Andrea

Thanks Matt for taking a look. Before originally posting I had also had a quick look at the code to ensure the XML string was correct. I will reboot a few more times, but it has been done a fair bit already. I thought I already had trace set. And because I wasn’t seeing any trace entries for ipcamera I set trace for the whole system via org.ops4j.pax.logging. Sadly I had not appreciated that settings via the Karaf console are persistent between reboots on my Docker based system, and it was set to debug for ipcamera.

I noticed in the logs that there is frequenly a TRACE response to a GET query, but nothing for the alert stream. I guess that is because it is a stream, but is that normal?

2020-03-27 16:23:08.818 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is        :<!DOCTYPE html>
2020-03-27 16:23:08.838 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/System/IO/inputs/1/status
2020-03-27 16:23:08.840 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
2020-03-27 16:23:08.841 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 178, cap: 178/178, unwrapped: PooledUnsafeDirectByteBuf(ridx: 612, widx: 612, cap: 1024)), decoderResult: success)
2020-03-27 16:23:08.841 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is        :<!DOCTYPE html>
2020-03-27 16:23:08.845 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture
2020-03-27 16:23:08.847 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.1.212, re-starting it now
2020-03-27 16:23:08.847 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Event/notification/alertStream
2020-03-27 16:23:08.847 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/System/IO/inputs/1/status
2020-03-27 16:23:08.850 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
2020-03-27 16:23:08.850 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 178, cap: 178/178, unwrapped: PooledUnsafeDirectByteBuf(ridx: 612, widx: 612, cap: 1024)), decoderResult: success)
2020-03-27 16:23:08.851 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is        :<!DOCTYPE html>
2020-03-27 16:23:08.853 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/System/IO/inputs/1/status
2020-03-27 16:23:08.857 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Event/notification/alertStream
2020-03-27 16:23:08.860 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture
2020-03-27 16:23:09.845 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture

Kind Regards

Martin

I have had a look at the code for the HikvisionHandler and so far as I can tell (I am far from a practised Java coder) for each EventNotification stanza received, there should be a TRACE message of “HTTP Result back from camera is…”.

But I am seeing nothing. Wireshark seems to confirm no continuous traffic to openhab. On closing openhab, I see that the status is 0 for the alertStream. The documentation indicates that 0 is a stream closing, but my suspicion is that it is already closed.

There is an entry in the logs which indicate that the alertstream is re-starting, but no recorded confirmation of successfull re-start in the logs
.
This is a log from close down to restart. A large number of /picture/ logs have been removed.

//openhab closing down

2020-03-28 15:20:03.722 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel status is 1 for URL:/ISAPI/Streaming/channels/101/picture
2020-03-28 15:20:03.796 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel status is 1 for URL:/ISAPI/Streaming/channels/101/picture
2020-03-28 15:20:03.796 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel status is 1 for URL:/ISAPI/Streaming/channels/101/picture
2020-03-28 15:20:03.797 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel status is 0 for URL:/ISAPI/Event/notification/alertStream
2020-03-28 15:20:03.797 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel status is 0 for URL:/ISAPI/System/IO/inputs/1/status

//openhab restart

2020-03-28 15:20:51.600 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'camera.items'
2020-03-28 15:20:52.861 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'camera.things'
2020-03-28 15:21:02.706 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'camera.rules'
2020-03-28 15:21:18.890 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The SERVER_PORT = -1 which disables a lot of features. See readme for more info.
2020-03-28 15:21:19.891 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.1.212:80
2020-03-28 15:21:19.989 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture
2020-03-28 15:21:20.068 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - We got an ONVIF error404:<!DOCTYPE html>
2020-03-28 15:21:20.209 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.1.212 is now online.
2020-03-28 15:21:20.255 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture
2020-03-28 15:21:20.290 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
2020-03-28 15:21:20.294 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture
2020-03-28 15:21:20.301 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 178, cap: 178/178, unwrapped: PooledUnsafeDirectByteBuf(ridx: 612, widx: 612, cap: 1024)), decoderResult: success)
2020-03-28 15:21:20.303 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:<!DOCTYPE html>
2020-03-28 15:21:20.310 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
2020-03-28 15:21:20.311 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 178, cap: 178/178, unwrapped: PooledUnsafeDirectByteBuf(ridx: 612, widx: 612, cap: 1024)), decoderResult: success)

***********LARGE NUMBER of 101/picture requests

2020-03-28 15:21:24.176 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture
2020-03-28 15:21:24.179 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
2020-03-28 15:21:24.180 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 178, cap: 178/178, unwrapped: PooledUnsafeDirectByteBuf(ridx: 612, widx: 612, cap: 1024)), decoderResult: success)
2020-03-28 15:21:24.181 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:<!DOCTYPE html>
2020-03-28 15:21:24.207 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture
2020-03-28 15:21:24.209 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture
2020-03-28 15:21:24.210 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
2020-03-28 15:21:24.211 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 178, cap: 178/178, unwrapped: PooledUnsafeDirectByteBuf(ridx: 612, widx: 612, cap: 1024)), decoderResult: success)
2020-03-28 15:21:24.211 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:<!DOCTYPE html>
2020-03-28 15:21:24.214 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.1.212, re-starting it now
2020-03-28 15:21:24.215 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Event/notification/alertStream
2020-03-28 15:21:24.217 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture
2020-03-28 15:21:24.219 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.212/ISAPI/Streaming/channels/101/picture

I have probably done as much as I can in diagnostics and testing with available logfile information.