IpCamera: New IP Camera Binding

Thanks @matt1. Just tried the doorbell as a HIKVISION Thing. I am not sure how the binding works regarding authorization, but it looks like authorization fails the first time, but then the binding successfully connects to a ONVIF service. However, then there are a series of 404 errors :frowning:. Maybe it does not use the HIKVISION API. I believe the events that are available are transmitted via OVNF. You are correct that an rtsp feed is available at the usual location for Hikvision devices, IPADDRESS:554/Streams/Channels/101.

You are correct - for some reason the doorbell press is not sent as an event. However, I know that the PIR events are sent. Someone has put out a Docker container that does ONVIF to MQTT translation. I could run that and then set up MQTT in OH, but that means running another server that can stall/fail.

There seems to be an onvif API library available that does authenticate with the doorbell successfully.

As I understand it, @matt1, you are using an external ONVIF library. Maybe this is the same issue as issue Skinha/IpCamera/#53 that is currently open in your GitHub repo? I completely understand not wanting to put in 160 hours to recreate something that already exists in a library you can download. If I get time, I will raise the issue over at GitHub RootSoft/ONVIF-Java.

Here is the Thing file:

Thing ipcamera:HIKVISION:back1
[
	IPADDRESS="192.168.18.30",
	USERNAME="admin",
	PASSWORD="JEGRAK",
	POLL_CAMERA_MS=200000,
	SERVER_PORT=54030,
	FFMPEG_OUTPUT="/tmpfs/doorbell/"
]

Here is the log.

2020-05-19 12:48:49.190 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'ipcamera.things'
2020-05-19 12:48:50.432 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.18.30:80
2020-05-19 12:48:50.446 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'ipcamera.things'
2020-05-19 12:48:50.531 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.18.30/ISAPI/Streaming/channels/101/picture
2020-05-19 12:48:50.594 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - We sucessfully connected to a ONVIF SERVICE:/onvif/device_service
2020-05-19 12:48:50.629 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - ONVIF error 400:<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12" xmlns:http="http://schemas.xmlsoap.org/wsdl/http" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tnsn="http://www.eventextension.com/2011/event/topics"><env:Body><env:Fault><env:Code><env:Value>env:Sender</env:Value>
<env:Subcode><env:Value>ter:NotAuthorized</env:Value>
</env:Subcode>
</env:Code>
<env:Reason><env:Text xml:lang="en">The action requested requires authorization and the sender is not authorized</env:Text>
</env:Reason>
</env:Fault>
</env:Body>
</env:Envelope>

2020-05-19 12:48:50.635 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Possible NIC/IP match found:xxx.xxx.xxx
2020-05-19 12:48:50.635 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Possible NIC/IP match found:xxx.xxx.xxx
2020-05-19 12:48:50.643 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - File server for camera at 192.168.18.30 has started on port 54030 for all NIC's.
2020-05-19 12:48:50.654 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 404 Not Found
Date: Tue, 19 May 2020 17:48:50 GMT
Server: webs/
X-Frame-Options: SAMEORIGIN
Content-Length: 212
Content-Type: text/html
Connection: keep-alive
Keep-Alive: timeout=60, max=99
2020-05-19 12:48:50.658 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 212, cap: 212/212, unwrapped: PooledUnsafeDirectByteBuf(ridx: 421, widx: 421, cap: 1024)), decoderResult: success)
2020-05-19 12:48:50.658 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:<!DOCTYPE html>
<html><head><title>Document Error: Not Found</title></head>
<body><h2>Access Error: 404 -- Not Found</h2>
<p>Can't locate document: /ISAPI/Streaming/channels/101/picture</p>
</body>
</html>
:
2020-05-19 12:48:54.646 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.18.30/ISAPI/Streaming/channels/101/picture
2020-05-19 12:48:54.663 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.18.30, re-starting it now
2020-05-19 12:48:54.664 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.18.30/ISAPI/Event/notification/alertStream
2020-05-19 12:48:54.690 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 404 Not Found
Date: Tue, 19 May 2020 17:48:54 GMT
Server: webs/
X-Frame-Options: SAMEORIGIN
Content-Length: 212
Content-Type: text/html
Connection: keep-alive
Keep-Alive: timeout=60, max=99
2020-05-19 12:48:54.691 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 212, cap: 212/212, unwrapped: PooledUnsafeDirectByteBuf(ridx: 421, widx: 421, cap: 1024)), decoderResult: success)
2020-05-19 12:48:54.691 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:<!DOCTYPE html>
<html><head><title>Document Error: Not Found</title></head>
<body><h2>Access Error: 404 -- Not Found</h2>
<p>Can't locate document: /ISAPI/Streaming/channels/101/picture</p>
</body>
</html>
:
2020-05-19 12:48:54.692 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 404 Not Found
Date: Tue, 19 May 2020 17:48:54 GMT
Server: webs/
X-Frame-Options: SAMEORIGIN
Content-Length: 212
Content-Type: text/html
Connection: keep-alive
Keep-Alive: timeout=60, max=99
2020-05-19 12:48:54.693 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 212, cap: 212/212, unwrapped: PooledUnsafeDirectByteBuf(ridx: 421, widx: 421, cap: 1024)), decoderResult: success)
2020-05-19 12:48:54.694 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:<!DOCTYPE html>
<html><head><title>Document Error: Not Found</title></head>
<body><h2>Access Error: 404 -- Not Found</h2>
<p>Can't locate document: /ISAPI/Event/notification/alertStream</p>
</body>
</html>
:
2020-05-19 12:49:08.665 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - ! Channel was found idle for more than 15 seconds so closing it down. !

Correct with the addition that hopefully the library gets fixed/extended to work. The good news is that a few people have split the rootsoft lib into a new GitHub repo and have recently done some improvements so it may now be possible to take the library further and get changes accepted. Worth posting a request into the newer sub version by looking at the issues at rootsoft.

Yeah looks like the API is not implemented in it which is a shame. You can always use the ffmpeg based motion detection as the last build unlocked that for all brands. Also check out the hacks that people do with a zwave reed based door sensor to detect when a magnetic bell is ringing to detect the button pushes.

@matt1
Did you have a working solution for streaming the ipcamera to a Google Nest Hub?
I struggled with it last night, but no matter what settings IĀ“m using, I get the respons ā€œUnfortunatly, something went wrongā€. It doesnt even activate the streaming switch. Using Microsoft Edge it works just fine. So I assume its a matter of settings for ffmpeg? But I have tried everythingā€¦
IĀ“m using a dauhua IPC-HDW4631C-A and the OnVif Dahua setup.

New build 2020-05-20 has these changes:

  • MP4 recording now works with no audio cameras as it defaults to no audio in the recording. @MrTBone
  • HLS streams will now auto restart if they close when the user has moved the start stream switch to ON.
  • Bug fix that could cause snapshots not to update when GIFā€™s were created with prerolls.

Then the binding does not get asked for the stream which may indicate a firewall rule blocking it? Check the logs in DEBUG mode as it should tell you when it gets the requests.

Okay - I will do that.

One question - from the logs, does it look as if the library is failing to authenticate with the doorbell? I ask because I saw the same sort of error message when the binding accesses my Hikvision bullet cameras, but obviously the binding tries another authentication method (maybe Digest?) and succeeds.

I saw you had implemented the ffmpeg-based motion detection. I will look into that. What I am curious about and would love to have access to is the ONVIF output of the on-board motion analysis and PIR events. It looks like when you flash the Hikvision FW, you get the Hikvision on-board motion detection analysis, which you find in their other cameras. Using ffmpeg in the binding implementation is fine, but as a general rule, I am looking to offload the motion processing to the cameras so I can save on CPU load.

The fact that the doorbell press is not an event does not make sense to me - seems obvious that people would want access to that, but maybe they just want to keep people captive to their cloud/app environment.

Thanks for the great work on this binding.

How is that possible, when it works fine from a PC using Microsoft Edge?
I have disabled whitelist.

Hard to comment when I donā€™t have the logs, if you are getting a picture then it is not failing. The 404 errors are the API is missing in the cameraā€¦ One thing to be aware of is that ONVIF uses the date and time in the digest and if your openhab does not match the time in the camera then ONVIF fails to work. Ensure the timezone and time are set the same as a user has reported this fixed it for them.

I have done probably half the work needed to get onvif alarms working.

No idea, you will need to fault find. Could be the Home Hub is on a guest wifi access point and its restricted from accessing your local network. There are heaps of reasons how it can be possible.

Im almost possitive thats not the issueā€¦ IĀ“m at a laptop right now which is connected to the same access point. Microsoft Edge starts the stream just fine (except I see no pictureā€¦ HMPRF! But it do start the stream).
Im running GoogleTTS on my openhab, and I can send Say commands to the Home Hub just fine.

I have a problem activating trace logging for the binding. Yesterday when I did, Openhab crashed seriously :frowning:

This is really starting to get on my nerves!!
I have more than one issue with the binding and the cameraā€¦

  1. If I tell the binding to use sub stream 1 (or 2) and I have set this to MJPEG. I can not get any picture when streaming on Microsoft Egde. I only get sound.
    If I change from MJPEG to H264, I get picture and sound in Microsoft Edge.

  2. Looking at the tracelog, I see no start of stream request, when asking Google Home Hub to show me the cam. If I use Microsoft Edge, I do see a stream request.

My Google Home is on the same network as my Microsoft Edge and the openhab server, there are no restrictions or any firewall rules preventing the communication. It seems to me, the request simply dont come through from the Google Home Hub. Either this is yet another Google issue, or there are something wrong with the Google Integrationā€¦ Howeverā€¦ I can control all my lights etc from the Home hub wihtout any problemsā€¦ Which leave me to think, maybe the meta setting is wrong, (except Google should have complaint when asking to syncronize devices). I see the camera ikon in the Google Home app just fine.

This is my items:

String      Dahua1HlsUrl    "FordĆør [%s]"      { channel="ipcamera:DAHUA:4279bdf8:hlsUrl", ga="Camera" [ protocols="hls" ] }

I have setup the camera from PaperUI, so unfortunatly I can not show my configuration. But evertyhing seems to work fine, except the two issues mentioned above.

Now what to do? Any suggestions are highly appreciated!

A label should be static text or it can screw with the hub so get rid of the %s

Also if you donā€™t use a thing file you will at some
Point need to delete and re add the camera or you will get random unexplained issues. This is in the readme for a good reason.

Tried that, didnt make any difference. And it would have surprised me if it did, cause I have alot of GA tags with same settings, which works quite well.

I know, and I will eventually move it to a thing fileā€¦ I just wanted to test this option first. But I never had this idea, that that particular issue will become this hardā€¦ I simply have no idea why my Home Hub wont even activate the streamingā€¦ There are no logical explanation. Even with a bad ffmpeg setting, I would have suspected the streaming would be activated.

I have no idea how to troubleshoot this one :weary:

Is Debug logging better than Trace logging?

Regarding logging, I do see one ā€œissueā€. But I dont think it mattersā€¦ Here is a small snipp:

21-May-2020 19:15:51.702 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 24576, widx: 30501, cap: 65536)), decoderResult: success)
21-May-2020 19:15:51.710 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 5925, cap: 5925/5925, unwrapped: PooledUnsafeDirectByteBuf(ridx: 30501, widx: 30501, cap: 65536)), decoderResult: success)
21-May-2020 19:15:51.721 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Snapshot recieved: Binding will now close the channel.
21-May-2020 19:15:52.375 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://10.4.28.194/cgi-bin/snapshot.cgi?channel=1
21-May-2020 19:15:52.393 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://10.4.28.194/cgi-bin/snapshot.cgi?channel=1
21-May-2020 19:15:52.397 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest realm="Login to 5H09036PAA02069", qop="auth", nonce="483178654", opaque="ddbfe7d30dd2acd90488bb0aefc6220a8d503061"
Connection: close
CONTENT-LENGTH: 0
21-May-2020 19:15:52.397 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent
21-May-2020 19:15:52.479 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-type: image/jpeg
CONNECTION: close
CONTENT-LENGTH: 178985
21-May-2020 19:15:52.480 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 893, cap: 893/893, unwrapped: PooledUnsafeDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
21-May-2020 19:15:52.482 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 8192, widx: 13456, cap: 16384)), decoderResult: success)
21-May-2020 19:15:52.487 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 5264, cap: 5264/5264, unwrapped: PooledUnsafeDirectByteBuf(ridx: 13456, widx: 13456, cap: 16384)), decoderResult: success)

This line:

21-May-2020 19:15:52.397 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 401 Unauthorized

IĀ“m I right in assuming its not an issue?

I have no changed to be using thing file instedā€¦ Still the same issue with Google Homeā€¦
This is my setup:

Thing ipcamera:DAHUA:DAHUA1 "Front door" @ "Cameras"
[
    IPADDRESS="10.4.28.194",
    USERNAME="admin",
    PASSWORD="password",
    POLL_CAMERA_MS=1000,
    SERVER_PORT=54321,
    IP_WHITELIST="DISABLE",
    IMAGE_UPDATE_EVENTS=1,
    UPDATE_IMAGE=false,
    ONVIF_PORT=80,
    PORT=80,
    ONVIF_MEDIA_PROFILE=0,
    GIF_PREROLL=2,
    GIF_POSTROLL=8,
    FFMPEG_LOCATION="/usr/bin/ffmpeg",
    FFMPEG_GIF_OUT_ARGUMENTS="-r 2 -filter_complex scale=-2:360:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse",
    FFMPEG_OUTPUT="/etc/openhab2/html/camera/dahua1/",
    FFMPEG_HLS_OUT_ARGUMENTS="-strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy -hls_flags delete_segments -hls_time 1 -hls_list_size 3",
    FFMPEG_MJPEG_ARGUMENTS="-qscale:v 5 -r 6 -update 1"
]

And my items:

String Dahua1HlsUrl    "FordĆøren [%s]"     { channel="ipcamera:DAHUA:DAHUA1:hlsUrl", ga="Camera" [ protocols="hls" ] }

In order to make sure the String URL is correct, I inserted the [%s] to the label of the item.
This is how it looks in BasicUI, (notice the last ā€œFordĆørenā€ state).

This tells me, setup should be just fine:

Issue:
When I ask Home Hub to ā€œshow me fordĆørenā€. Google respond in less than as second:
ā€œSorry something went wrong. I cant controle your Home Hub right nowā€.
The streaming switch do NOT get activated.

When I use the same link in Microsoft Edge:
Streaming switch gets activated.
It starts streaming just fine.

I have aprox 80-90 other GA tags, which are working just fine, all controlled from the same Home Hub, (as well as other Google devices IĀ“ve got in the house).
I use GoogleTTS to send say commands from the same openhab/rpi setup to the Home Hub, which is working just fine. This tells me, communication to/from this Home Hub is working just fine.
So this particular ga=ā€œCameraā€ tag or the ipcamera binding seems to be an issue somehow.

I have to include @michikrug as well, as he may have some deeper info from the GA integrationā€¦
In order to troubleshoot this one, I need to know:

When exactly do the streaming switch gets activated? Does Home Hub/chromecast devices check the media before it actually starts streaming, or is this check only beeing done, when the streaming activated has been switched on? If Home hub checks the media first, it may be some settings in the FFMPEG setup, which is breaking the stream for Home Hub.
But if it does not check the media before activating, I would say something is wrong, either in the GA integration (specific for the ga=ā€œCameraā€ tag, this is a Google issue, which seems to affect the danish languageā€¦
Personally I think this is a Google issue which may be only affect the danish language setup. But that dont fit with Google Nest Hello (Google own cameras) are working just fine in Denmark according to other users. Or Google checks the media before it actually activate the streaming switch, and therefore there might be a setup fault in the FFMPEG setup for the media.

I really could need some help with this one!!!

This will be my last reply because I stated you MUST NOT use labels with the string or any variable in them. IT WILL BREAK it from working. Create your own thread asking for help as your issue appears to not be with this bindingā€¦

items

String Dahua1ForSitemap "HLS" { channel="ipcamera:DAHUA:DAHUA1:hlsUrl" }
String Dahua1ForHub "FordĆøren" { channel="ipcamera:DAHUA:DAHUA1:hlsUrl", synonyms="The front door, front doorway, front entry", ga="Camera" [ protocols="hls" ] }

Then say, "ok google, sync my devices" After that succeeds say this "Show the front door" or any of the synonyms or the label, but they must be an exact match which is why you can not use the string in the label.

If the binding does not log the request then you must have 1 of a few things happening.

  1. The nest hub is trying to use the wrong url. Not likely as it is being sourced direct from the channel.
  2. There is an issue with your network stopping the request. Highly likely, but more likely it is caused by what is in my first sentence.
  3. The special character may be causing issues, change FordĆøren to something with more plain characters as the REST api may be having issues if it is a non legal character to be used in a GET request. This is not my area of knowledge hence why this should be in a new thread as it is not to do with this binding.

I use this feature for many hours every day, have been doing so for more than a year and it works.

I DID try everything youĀ“ve suggested. (I told you why IĀ“d add the [%s], simply to make absoluly sure the Url was correct, cause thats the only way to see it).
I tried with and without variable in the label.
I changed the label to something more accurate using more words etc.
I tried all possible combinations of whats in the docs.
I tried using different serverport.
I just tried your exact example above including with synonyms. (Synonyms does not seem to work at all in danish language).

I end up with the same result no matter what I try:
Google respons, ā€œSomething went wrong. Cant control your Google device right nowā€
ipcamera stream switch not activating.

IĀ“ll create a new thread, or find some help elsewhere.

EDIT - For who it may concern.

Seems like I have moved one big step forward a ā€œreasonā€ā€¦
My streaming is working just fine. But only if I pick up my phone, start the Google Assistant and tell Google to ā€œshow (cameraname) on (device)ā€ Then my Home Hub (device) will start streaming just fine.

But if I aks my Home Hub to ā€œshow (cameraname)ā€ I get the above error, ā€œsomething went wrongā€¦ā€

Its highly strangeā€¦ But at least I no longer have to deal with the videoformat beeing wrong!

Considere the new Google home assistant integration wich change a bit the TAG call method

I am able to view an image if I set the FFMPEG_INPUT to the rtsp stream URL. So I guess authentication is working with the doorbell camera.

I continue to troubleshoot the Hikvision/EZVIZ DB-1 type doorbells, trying to get them to work with this great binding. If we can work it out, I will post something on the ipcamtalk site and see if we can get some OH converts.

Here are the issues I am aware of with this binding and these cameras:

  • Binding fails to retrieve rtsp and shapshot URLs over ONVIF even though camera supports ONVIF with Hikvision Firmware, and URL info is available (see below)
    ** Solution for now: Manually add URLs using SNAPSHOT_URL_OVERRIDE, and FFMPEG_INPUT Thing file definitions.

FWIW, I do not see why I would need to set STREAM_URL_OVERRIDE=ā€œffmpegā€ even though this is recommended in the README. With or without this, as long as FFMPEG_INPUT is set to the rtsp url, the binding seems to fire up ffmpeg and create the stream just fine. Am I missing something?

  • No MJPEG available on any stream (doorbell supports two streams, but only with h.264 encoding)
    ** Solution: Let binding create mjpeg stream on the fly by using the FFMPEG_INPUT Thing set to the rtsp stream IP address

  • No web interface
    ** No solution, but interface really not needed

  • No regular Hikvision API for reporting events from the camera
    ** Solution - an ONVIF to MQTT docker container is available here. This allows events from the doorbell to be used by OH with the MQTT addon.
    ** Feature request - Would it be possible to have this binding get events thorough ONVF from this doorbell? It would simplify the use of the doorbell with OH substantially.

Here is some other information about this doorbell and getting it to work with this binding:

  • It supports discovery (camera is found by Hikvision iVMS-4200 app)
  • It supports ONVIF IF it is running Hikvision Firmware (ONVIF Device Manager is able to connect to the device)
    ** Camera reports ONVIF version 2.60
    ** ONVIF URL is camera.ip.address/onvif/device_service
    ** It is possible to set the camera to use the same NTP server as the OH server (eliminates timing/authentication errors)
    ** ONVIF may be used to retrieve the rtsp streaming URL (proven because it can be seen in ONVIF Device Manager)
    ** ONVIF may be used to report motion events (PIR for sure, not positive if Hikvision motion analysis events are reported or not)

Snapshot URL: http://camera.ip.address/onvif/snapshot.jpg (no username/password needed)
Streaming URL: rtsp://camera.ip.address:554/Streaming/Channels/101 for Main Profile
Streaming URL: rtsp://camera.ip.address:554/Streaming/Channels/102 for substream profile

The HTTPONLY Thing definition seems to work. I am not using the HIKVISION Thing because the doorbell does not support the Hikvision API. The ONVIF definition reports errors getting the snapshot and stream URLs.

Thing ipcamera:HTTPONLY:doorbell
[
	IPADDRESS="camera.ip.address",
	USERNAME="admin",
	PASSWORD="mypassword",
	POLL_CAMERA_MS=2000,
	SNAPSHOT_URL_OVERRIDE="http://camera.ip.address/onvif/snapshot.jpg",
	SERVER_PORT=54030,
	FFMPEG_INPUT="rtsp://camera.ip.address:554/Streaming/Channels/101",
	FFMPEG_OUTPUT="/tmpfs/doorbell/"
]

If something works in onvif device manager but not the binding then it is worth creating an issue and attaching some trace logs of when the camera is connecting.

I have been adding the feature for onvif events but it is not yet ready for release but it is for alpha level testing. @bgilmer If interested I have already uploaded a build for you to try as it is working on 1 of my cameras and still yet to find the time to try it on a number of brands.

  1. It only works if the thing type is ONVIF
  2. You can use the over ride urls if the onvif does not detect them automatically just the same way you are with httponly.
  3. Use DEBUG level log output and you should see the onvif events getting logged, If it does not work I will need a copy of the log output.
  4. Only motion detection is coded, but if people send me the log output I can add any other events very easily.

Any idea why I get this netty warning?

2020-05-24 22:19:39.960 [WARN ] [io.netty.channel.nio.NioEventLoop   ] - Selector.select() returned prematurely 512 times in a row; rebuilding Selector io.netty.channel.nio.SelectedSelectionKeySetSelector@1d1a4aa.
2020-05-24 22:19:39.992 [WARN ] [io.netty.channel.nio.NioEventLoop   ] - Selector.select() returned prematurely 512 times in a row; rebuilding Selector io.netty.channel.nio.SelectedSelectionKeySetSelector@37459f.
2020-05-24 22:19:39.990 [WARN ] [io.netty.channel.nio.NioEventLoop   ] - Selector.select() returned prematurely 512 times in a row; rebuilding Selector io.netty.channel.nio.SelectedSelectionKeySetSelector@a7f2a7.

Using latest ipcamera binding, running openhab (openhabian) 2.5(stable) on a Rpi3B+

Thatā€™s great! I have not been able to get back to this since I made my last post. Was just in the process of grabbing some wireshark captures of the onvif2mqtt utility setting up a pullpoint subscription, and then capturing the dialog when I trigger a PIR event. This is with the EZVIZ DB1 running LaView Firmware.

The problem with dmitrifā€™s utility is that while it works with the LaView firmware, it does not seem to work with the Hikvision firmware. This is not good because the Hikvision FW provides a lot more in terms of software-based motion detection, line crossing, etc. Anyway, I do not know how much I can work on this tomorrow since it is a holiday, but if I get a chance, I will pull down your new version and see if it works. Will post as soon as I get a look. Thanks very much for working on this.

Hi @matt1, I gave it a quick try, but no luck so far. Here are some config. filesā€¦

Thing file

Thing ipcamera:ONVIF:doorbell
[
	IPADDRESS="camera.ip.address",
	USERNAME="admin",
	PASSWORD="my.secret.password",
	POLL_CAMERA_MS=2000000,
	SNAPSHOT_URL_OVERRIDE="http://camera.ip.address/onvif/snapshot.jpg",
	SERVER_PORT=54030,
	FFMPEG_INPUT="rtsp://camera.ip.address/Streaming/Channels/101",
	FFMPEG_OUTPUT="/tmpfs/doorbell/"
] 

Here is the .items fileā€¦

String doorbell_MJPEGStreamURL "MJPEG URL" { channel="ipcamera:ONFIV:doorbell:streamUrl" }
Switch doorbellMotionAlarm "Motion Detected" { channel="ipcamera:ONVIF:doorbell:motionAlarm" }
Dimmer doorbellMotionThreshold "Motion Threshold" { channel="ipcamera:ONVIF:doorbell:ffmpegMotionControl" }

Here is the sitemap file

sitemap ipcamera label="IP Cameras" {

	Frame label="Doorbell Camera" {
		Text item= doorbell_MJPEGStreamURL
		Text label="Snapshot" icon="camera"{Image url="http://oh2.server.ip:54030/ipcamera.jpg"}
		Text label="MJPEG Stream" icon="camera"{Video url="http://oh2.server.ip:54030/ipcamera.mjpeg" encoding="mjpeg"}
		Switch item= doorbellMotionAlarm
		Slider item= doorbellMotionThreshold
	}
}

I have set DEBUG level on the logs, and they produce a LOT of data. What is the best practice for getting that to you?

Here is the contents of the event.log.

2020-05-24 21:16:05.087 [hingStatusInfoChangedEvent] - 'ipcamera:ONVIF:doorbell' changed from UNINITIALIZED to INITIALIZING
2020-05-24 21:16:06.227 [hingStatusInfoChangedEvent] - 'ipcamera:ONVIF:doorbell' changed from INITIALIZING to ONLINE

Moving my hand around the PIR sensor does not cause any new entries in the openhab.log file. But I know the ONVIF event is available. Here is the output of the onvif2mqtt utility.

root@OH-Test /opt/onvif2mqtt # npm run dev

> onvif-cam@1.0.4 dev /opt/onvif2mqtt
> cross-env CONFIG_PATH=./config.dev.yml nodemon -e js,yml --exec babel-node src/index.js | pino-pretty

[nodemon] 2.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,yml
[nodemon] starting `babel-node src/index.js`
[1590369536807] INFO : Loading configuration. {"configPath":"./config.dev.yml"}
[1590369536814] INFO : Validating configuration file.
[1590369536889] INFO  (Manager): Beginning initialization...
[1590369536889] INFO  (MQTT on 127.0.0.1:1883): Connecting.
[1590369536918] INFO  (MQTT on 127.0.0.1:1883): Successfully connected.
[1590369536918] INFO  (ONVIF/doorbell on 192.168.18.30): Attempting connection.
[1590369536919] DEBUG (MQTT on 127.0.0.1:1883): Publishing. {"topic":"onvif2mqtt/doorbell/motion","value":"OFF","retain":true}
[1590369537122] INFO  (ONVIF/doorbell on 192.168.18.30): Successfully connected.
[1590369540338] DEBUG (MQTT on 127.0.0.1:1883): Publishing. {"topic":"onvif2mqtt/doorbell/motion","value":"ON","retain":true}
[1590369545427] DEBUG (MQTT on 127.0.0.1:1883): Publishing. {"topic":"onvif2mqtt/doorbell/motion","value":"OFF","retain":true}

Thatā€™s it for now. Please let me know the best way to get the openhab2.log file to you.