IpCamera: New IP Camera Binding

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.

Check if the camera has locked you out or if the camera is setup to have a whitelist and openhab is not on the list.

Hi Matt,

The camera seems to have no whitlist/blacklist capability. I also looked for blocked and locked. Looked at google, the manual, and the config interface.

Access seems OK. The GCI API config screen has a section for authorised users and so I tried changing a password. When I re-started OH I got a lot of log messages of “!!! Camera possibly closed the channel …” so I think it suggests access control is working as expected

The cameras I have are all new, professionally installed, and have the latest firmware.

Kind Regards

Martin

Hi everyone, I’m trying to connect my HIKVISION DS-2CD2142FWD-I cameras to openhab.
I saw that I can connect them via Paper UI, but I read that through text configuration it is better.
Could you help me?
I insert my things and items files.

Things file:

Thing ipcamera:HIKVISION:005 "GiardinoPost"
[
    IPADDRESS="Camera IP",
    USERNAME="USER",
    PASSWORD="PASSWORD",
    POLL_CAMERA_MS=1000,
    SERVER_PORT=8000,
    UPDATE_IMAGE=false,
    FFMPEG_OUTPUT="/tmpfs/GiardinoPostCam/",
    FFMPEG_INPUT="rtsp://192.168.178.64:554/Streaming/Channels/101"
]

items file:

Switch GiardinoPostGif "Create animated GIF" { channel="ipcamera:HIKVISION:005:updateGif" }
Dimmer GiardinoPostPan "Pan [%d] left/right" { channel="ipcamera:HIKVISION:005:pan" }
Dimmer GiardinoPostTilt "Tilt [%d] up/down" { channel="ipcamera:HIKVISION:005:tilt" }
Dimmer GiardinoPostLED "IR LED [%d]" { channel="ipcamera:HIKVISION:005:enableLED" }
Switch GiardinoPostAutoLED "Auto IR LED" { channel="ipcamera:HIKVISION:005:autoLED" }
String GiardinoPostTextOverlay "Text to overlay" { channel="ipcamera:HIKVISION:005:textOverlay" }
String GiardinoPostAPIAccess "Access the API" { channel="ipcamera:HIKVISION:005:apiAccess" }
String GiardinoPostStreamUrl "Mjpeg Stream" { channel="ipcamera:HIKVISION:GiardinoPost:streamUrl" }
String GiardinoPostHlsStreamUrl "HLS Stream" { channel="ipcamera:HIKVISION:GiardinoPost:hlsUrl" }
String GiardinoPostRTSPStreamUrl "RTSP Stream" { channel="ipcamera:HIKVISION:GiardinoPost:rtspUrl" }
DateTime GiardinoPostLastMotionTime "Time motion was last detected [%1$ta %1$tR]"
String GiardinoPostLastMotionType "Last Motion Type" { channel="ipcamera:HIKVISION:GiardinoPost:lastMotionType" }
Switch GiardinoPostStartHLS { channel="ipcamera:HIKVISION:GiardinoPost:startStream" }
Switch GiardinoPostEnableMotionAlarm "MotionAlarm on/off" { channel="ipcamera:HIKVISION:005:enableMotionAlarm" }
Switch GiardinoPostMotionAlarm "Motion detected" { channel="ipcamera:HIKVISION:005:motionAlarm" }
Switch GiardinoPostEnableLineAlarm "LineAlarm on/off" { channel="ipcamera:HIKVISION:005:enableLineCrossingAlarm" }
Switch GiardinoPostLineAlarm "Line Alarm detected" { channel="ipcamera:HIKVISION:005:lineCrossingAlarm" }

At the moment I have 5 cameras and obviously I try to make the first one work and then repeat the same steps with the others.
I would like to see the thumbnails in Paper UI if possible and then in the sitemap, I’d like to configure all possible features.
I saw that there is a huge work behind it and therefore I would like to thank the author @ matt1
Thanks

Jad

Hi Francesco, I’m not so expert but Matt help me a lot every time I needed
Anyway, your configurations seems to be ok, despite the info I guess you expressely hide (user pass and IP). Better if you pubblish the sitemap also
For the tumbhnail see follow this

TnX Elenio,
My sitemap:

Text label=“Giardino Post” icon="camera"{Image url="http://192.168.178.64:8000/ipcamera.jpg" refresh=1000} 
        
        Text label="Advanced Controls" icon="settings"{
            Slider item=GiardinoPostLED
            Default item=GiardinoPostAutoLED
            Text label="Cameras Mjpeg Stream" icon="camera"{Video url="http://192.168.178.64:8000/ipcamera.mjpeg" encoding="mjpeg"}
            Text label="Snapshot 1FPS Stream" icon="camera"{Video url="http://192.168.178.64:8000/snapshots.mjpeg" encoding="mjpeg"}
            Text label="autofps Stream" icon="camera"{Video url="http://192.168.178.64:8000/autofps.mjpeg" encoding="mjpeg"}
            Text label="HLS Video Stream" icon="camera"{Video url="http://192.168.178.64:8000/ipcamera.m3u8" encoding="hls"}
            Text label="HLS Webview Stream" icon="camera"{Webview url="http://192.168.178.64:8000/ipcamera.m3u8" height=15}
            Text label="Image using jpg method" icon="camera"{Image url="http://192.168.178.64:8000/ipcamera.jpg" refresh=2000}        
    }

Jad

Please don’t assume they have the latest firmware when they are new, it is very common for cameras to ship before firmware is fully written so it is extremely important to update firmware on new cameras that may have been sitting in warehouses for months with firmware not was not fully finished before shipping.

I don’t understand in your case why you can get the stream output manually in a browser, but you can not get it via the binding and shown in the trace logs. This does not add up, hence why I feel this could be the camera not wanting to talk to X ip address. Try power cycling the camera as that resets the lockout which may have been tripped and keep looking for white lists as my Hikvision cameras have that feature.

Confirm that the binding is using the exact same URL that you are using for the alarm stream.

Hi Matt, Appologies for my lack of clarity. I had manually verified latest firmware against the UK Hikvision download pages.
The URL for the alarm stream I used is the one listed in the logs so I would have expected them to be the same. Your insight has given me a another thing to try, short of setting up Eclipse, which is to elimiate docker. First I will try the other things you mention.

Matt, thank you for your assistance so far, it is much appreciated. It will take me a while to do all of these things and will report back in due course.

KInd regards
Martin

Don’t see any error
Only I don’t see port in your thing file following this specs
PORT This port will be used for HTTP calls for fetching the snapshot and alarm states.’
In my case I setup this: 80

You don’t see any image or stream opening the sitemap tile on your system?

Anyway these are my sitemap entries:

// (Potrebbe avere Peggiore risoluzione) Text label="Cameras Mjpeg Stream" icon="camera"{Video url="http://192.168.1.180:54324/ipcamera.mjpeg" encoding="mjpeg"}
Text label="Snapshot 1FPS Stream" icon="camera"{Video url="http://192.168.1.180:54324/snapshots.mjpeg" encoding="mjpeg"}
// (Minimizza il traffico dati) Text label="autofps Stream" icon="camera"{Video url="http://192.168.1.180:54324/autofps.mjpeg" encoding="mjpeg"}
Text label="HLS Video Stream" icon="camera"{Video url="http://192.168.1.180:54324/ipcamera.m3u8" encoding="hls"}
Text label="HLS Webview Stream" icon="camera"{Webview url="http://192.168.1.180:54324/ipcamera.m3u8" height=15}
Text label="Image using jpg method" icon="camera"{Image url="http://192.168.1.180:54324/ipcamera.jpg" refresh=1000}

Hi Matt,

I am currently facing some “load” issues with my camera as i am accessing it in parallel with my NVR and directly with openhab ipcamera binding.

I’d like to reduce the load openhab is generating (by the ipcamera binding) to only use the xml alarm stream. So to speak: only grab the alarms but NO image data (hence reduce encoding/decoding load of the camera).

Is it possible to run the binding without any binary input stream - so only for the XML alarms and like “deactivate” RTSP/the FFMPEG input?
My NVR is not passing through smart alarms from HIKVISION, that’s why i want to still use those (without the image data).

I would then setup a second ipcamera thing as generic HTTP camera pointing to the NVR for an rtsp passthrough image channel.

Cheers,
Stefan

I inserted port 80 in things configuration, but still no video in PaperUI and openhab app (IOS).
Following conf. camera port.

Schermata 2020-03-30 alle 16.50.50

Do I have to put something in rules?

Jad

No rules as far as I know Francesco for simple video streaming
Anyway we have now to address to Matt suggestion
Sorry I reached my limit but here two more personal suggestion
a) don’t even see this entry:

    IP_WHITELIST="DISABLE"

b) enable trace log as Matth always suggest us

Added IP_WHITELIST=“DISABLE”, but no way here.
Log is enabled, but is very long file and continue to imcrement.
log.pdf (26.7 KB)
The camera has the last FW V5.5.82 build 190220.
Jad

You can stop any fetching of the snapshot with the update image events option as explained in the readme. Then it will only occur on demand when you request something from the server port.

You wont see them in PaperUI with the image updates turned off. I recommend you leave it turned off and instead use the other methods described in the readme. PaperUI is not a user interface.

What is the correct UID, is it 005 or GiardinoPost? your clearly not reading the logs as it will be complaining about that when openhab starts. I am sure you will solve it if you start reading the logs that get created.

Ok, thanks for confirming!

Thanks fr reply, I don’t have http mjpeg stream, only RTSP stream from ipcamera, how can I display that?
My camera accessible via VLC on the following address: rtsp://user:password@192.168.1.119:554/onvif1

Skinah… is there any way to deal with frequently stopping video feed from camera? I’d love to have a solution for refreshing video feed when it stops for some reason. Refreshing the Item is not the solution since you need to wait long to refresh stream and you can miss something. With your knowledge at the moment is there any chance for a solution to detect that camera stream crashed?

I have tried several ip cameras, but can’t get this working (( Who can tell me how you display stream from cameras in OpenHAB interface? Is it possible to display RTSP stream in BasicUI interface? Why I’m asking is because all well known browsers block RTSP streams…
I have tried relatively old camera with HTTP interface- AMOVISION AM-Q6320-WIFI, it supports FFMPEG for sure, however can’t geit it to show stream either other than in BasicUI webview window opening on raspbian, not windows.