IpCamera: New IP Camera Binding

Can somebody help me i configed my (chinese) Onvif PTZ Camera.

PTZ is working with Onvif Device manager.

My ipcamera.things

Thing ipcamera:ONVIF:001 [ IPADDRESS=“192.168.178.34”, PASSWORD=“12345”, USERNAME=“admin”, ONVIF_PORT=80, PORT=80, SERVER_PORT=50001, POLL_CAMERA_MS=2000, FFMPEG_INPUT=“rtsp://admin:admin@192.168.178.34:554”, FFMPEG_OUTPUT=“/tmp/camera1/”]`

But i get this info in the logs

2019-06-29 23:28:45.188 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Following NPE occured when trying to connect to the camera with ONVIF.java.lang.NullPointerException
2019-06-29 23:28:45.191 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Since an NPE occured when asking the camera about PTZ, the PTZ controls will not work. If the camera does not come online, give the camera the wrong ONVIF port number so it can bypass using ONVIF and still come online.
2019-06-29 23:28:45.207 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.178.34:80 is now online.
2019-06-29 23:28:45.293 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IpCamera file server for camera 192.168.178.34 has started on port 50001

What can I do to get the PTZ working? That would be the most important thing for me. Thanks in advance

In your addons folder is a file called javax.xml.soap-api-1.3.7.jar Try changing this file to an older version which you can download them from here…

https://mvnrepository.com/artifact/javax.xml.soap/javax.xml.soap-api

You will need to make sure only 1 version is in the folder at a time and after changing the contents of the addons folder you will need to clean the cache and tmp folders and reboot.

I have only ever seen this once with my cameras and it was caused by using 1.4.0 version of that file.

Also posting the output from your logs in TRACE mode that shows a single camera connecting would also be helpful to look into it. The readme has info on log modes.

Tried I but unluckyly no success

This is my trace log:

13:52:21.743 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Fetching the number of Media Profiles this camera supports.
13:52:24.812 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Checking the selected Media Profile is a valid number.
13:52:24.816 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Fetching a Token for the selected Media Profile.
13:52:24.820 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Auto fetching the snapshot URL for the selected Media Profile.
13:52:27.963 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - About to fetch some information about the Media Profiles from the camera
13:52:27.967 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - *********** Media Profile 0 details reported by camera at IP:192.168.178.34 ***********
13:52:27.970 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Camera will use this Media Profile unless you change it in the bindings settings.
13:52:27.973 [INFO ] [ding.ipcamera.handler.IpCameraHandler] - This can be used to stream HLS with low CPU overhead
13:52:27.976 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Media Profile 0 is named:VideoEncoder_1
13:52:27.980 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video encoder       :H_264
13:52:27.983 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video quality       :10.0
13:52:27.987 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video resoltion     :1920 x 1080
13:52:27.990 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video bitrate       :0
13:52:27.993 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - *********** Media Profile 1 details reported by camera at IP:192.168.178.34 ***********
13:52:27.997 [INFO ] [ding.ipcamera.handler.IpCameraHandler] - This can be used to stream HLS with low CPU overhead
13:52:28.000 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Media Profile 1 is named:VideoEncoder_2
13:52:28.003 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video encoder       :H_264
13:52:28.006 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video quality       :10.0
13:52:28.009 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video resoltion     :640 x 360
13:52:28.012 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video bitrate       :0
13:52:28.015 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - About to interrogate the camera to see if it supports PTZ.
13:52:33.715 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Camera is reporting that it supports PTZ control with Absolute movement via ONVIF
13:52:33.719 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Checking Pan now.
13:52:39.172 [WARN ] [ding.ipcamera.handler.IpCameraHandler] - Following NPE occured when trying to connect to the camera with ONVIF.java.lang.NullPointerException
13:52:39.176 [ERROR] [ding.ipcamera.handler.IpCameraHandler] - Since an NPE occured when asking the camera about PTZ, the PTZ controls will not work. If the camera does not come online, give the camera the wrong ONVIF port number so it can bypass using ONVIF and still come online.
13:52:39.180 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Sending camera GET: http://192.168.178.34:80/onvif/snapshot
13:52:39.197 [TRACE] [.ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for      GET:/onvif/snapshot
13:52:39.200 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - Have  opened  a  brand NEW channel:0     GET:/onvif/snapshot
13:52:39.206 [INFO ] [ding.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.178.34:80 is now online.
13:52:39.212 [DEBUG] [ding.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0     URL:/onvif/snapshot
13:52:39.221 [INFO ] [ding.ipcamera.handler.IpCameraHandler] - IpCamera file server for camera 192.168.178.34 has started on port 50001


 14:27:02.099 [hingStatusInfoChangedEvent] - 'ipcamera:ONVIF:001' changed from INITIALIZING to OFFLINE (CONFIGURATION_ERROR): Camera failed to report a valid Snaphot URL, try over-riding the Snapshot URL auto detection by entering a known URL.

Hi! I’v updated binding to the new one and verified with one of my Foscam cameras. I still get 0.0.0.0 streamURL address and can’t find where is problem. I tried to use streamURL item in Image Widget (Openhab String Item) in habpanel but it doesn’t work. To make it work I need to directly put the address to the camera stream as string e.g. http://192.168.1.171:54322/ipcamera.mjpeg.

I’ve also checked if TILT and PAN works and… it works, however… after setting slider in habpanel i need to wait ~30 seconds for a reaction. I’ve enabled TRACE log and it can’t find there anything wrong.ZOOM doesn’t work at all. My Foscam cameras are all FI9826P models. Here is some loge from TILT and PAN and ZOOM.

2019-06-30 21:11:29.762 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Cameras Pan  has changed to:0.100000024
2019-06-30 21:11:40.268 [INFO ] [del.script.UPS Runtime Duration is: ] - 00 hours, 53 minutes, 00 seconds
2019-06-30 21:11:46.826 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Cameras Tilt has changed to:-0.28000003
2019-06-30 21:12:39.947 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Cameras Zoom has changed to:0.3399999
2019-06-30 21:13:16.176 [INFO ] [del.script.UPS Runtime Duration is: ] - 00 hours, 54 minutes, 00 seconds

Hi,

I am just adding a note here in relation to this binding and Sricam IP Cam (SP012). I’ve spent way to much time trying to get OH2 to talk to the camera and I don’t believe it works at all. I have OH2 on a Raspberry Pi 3.

Using the Onvif settings I can get it to detect the camera and it can see it online but I can get a snapshot to display at all, I’ve tried multiple variations but nothing. I know its a cheap camera but I’ve started out with it and has served a purpose.

I initially had issues with the camera being detected, getting the error “OFFLINE - COMMUNICATION_ERROR”. Once I added an overwrite URL for the snapshot or streaming this changed to online. I tried to repeat this but it doesn’t come back so I am not sure what caused it to change the 1st time.

I tried to to find URLs online where OH2 could take a snap shot from and grab a stream but everything I found didn’t work.

The below were from two different sites, https://shinobi.video/docs/cameras/Sricam & https://www.ispyconnect.com/man.aspx?n=sricam&page=2

http://192.168.0.110/videostream.cgi?rate=0&user=USERNAME&pwd=PASSWORD
http://192.168.0.110/snapshot.cgi?user=USERNAME&pwd=PASSWORD

None of the URL suggestions work. I also added the camera to MotionEye which works fine cause its using RTSP. Once the camera was added it gave me the below URLs for snapshots and a stream. Again none of these work when I put them into a browser, I assumed the video might not but since a browser can render images that they should appear. No responses to all these.

http://192.168.0.74/picture/1/current/
http://192.168.0.74:8081
http://192.168.0.74/picture/1/frame/

The only way I can get a stream from the camera is with rtsp://192.168.0.110:554/onvif1 via VLC or as mentioned through MotionEye. Anyhing that supports RTSP.

I had a a look online and I can see OH2 doesn’t support RTSP yet so I think its not going to happen.

Hopefully this info is helpful to someone and they don’t waste as much time as I did.

Think I’ll buy a new camera since I prefer OH2 over Home Assistant.

@zacofunny

  1. re: 0.0.0.0 I would need to add some more logging to narrow down why it happens, but as you mention if you use the Openhab servers IP instead of the 0.0.0.0 it should still work.

  2. Re delay on PTZ, yes I get around 8 seconds here on mine so some delay is to be expected but if it is really 30 seconds I would suggest you look at what the poll time is setup for the camera as it will wait until the next poll time before it starts to process the new location. If you have a 20 second poll time selected it will move faster if you drop that value down. I just looked at the logs and it appears the 3 location values are not set all at the same time? Are you just moving them manually? When set all at the same time in a rule they should all move at the same time after around 8-10 seconds if you camera behaves the same as mine. The readme has an example rule and how I setup buttons to make a camera jump to a set location.

@spudatron
Yes the binding needs a snapshot to determine if the camera is online or not so without one the camera will stay offline, otherwise you could use it for casting the cameras with HLS as these come from a rtsp source. I would personally get a better camera as the other features in the firmwares are very useful depending on your use case. You could work around it using a script or using the command action to call ffmpeg to generate snapshots or a non stop stream for openhab to use. This would use the rtsp feed as the source…

This will chew your CPU which wont be much for a snapshot. The other option would be to use a Pi and the motion software to keep the rtsp stream alive and generate what you need and would give you decent movement detection and more…

Hi @matt1,

Great work with the binding and the gif’s, Thanks.
Can you please add the following to the supported list?

  1. Dahua IPC-HDW2431R-ZS
  2. Dahua DH-SD22404T-GN PTZ

Still experimenting with all the features and channels.

I’m also having the same problem with a Hikvision PTZ camera.
Model: DS-2DE3304W-DE
FW: V5.4.8 build 170210

Trace:

2019-07-01 20:25:18.663 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Fetching the number of Media Profiles this camera supports.
2019-07-01 20:25:22.951 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Checking the selected Media Profile is a valid number.
2019-07-01 20:25:22.954 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Fetching a Token for the selected Media Profile.
2019-07-01 20:25:22.957 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to fetch some information about the Media Profiles from the camera
2019-07-01 20:25:22.959 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - *********** Media Profile 0 details reported by camera at IP:192.168.1.9 ***********
2019-07-01 20:25:22.962 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera will use this Media Profile unless you change it in the bindings settings.
2019-07-01 20:25:22.964 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Following NPE occured when trying to connect to the camera with ONVIF.java.lang.NullPointerException
2019-07-01 20:25:22.967 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Since an NPE occured when asking the camera about PTZ, the PTZ controls will not work. If the camera does not come online, give the camera the wrong ONVIF port number so it can bypass using ONVIF and still come online.
2019-07-01 20:25:23.428 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera GET: http://192.168.1.9:80/Streaming/channels/101/picture
2019-07-01 20:25:24.065 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for    GET:/Streaming/channels/101/picture
2019-07-01 20:25:24.067 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have  opened  a  brand NEW channel:0   GET:/Streaming/channels/101/picture
2019-07-01 20:25:24.096 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.1.9:80 is now online.

Thanks for the reply @matt1, appreciated the feedback. I’ll go with the better more supported cameras i think. I’d prefer better integration than using work arounds.

@Zippochonda and @lfs_alp5

Yes there does appear to be an issue in the onvif library that I am using as the NPE is occurring in the library and not my code. I am looking at it as I have time and a work around may be possible or there are a number of new onvif libraries being created however they do not yet have PTZ features. This only happens with some cameras, others like mine are working great just with a 8 second delay from when you ask the camera to move to when it actually moves.

@spudatron
Yes you get a lot more value out of cameras that cost a little more.
For example some of my security cameras can produce 3 streams with different settings all at the same time.

  1. 4K video feed with h265 compression goes to storage.
  2. mjpeg format stream
  3. h264 stream to cast to TVs as my older chromecasts don’t support 4k so feed 1 can’t be used.

The cameras can tell me if people are walking towards the house or away from the house plus more via smart alarms. Even the basic video motion alarms can be fine tuned to ignore small animals and only detect humans. Cheap cameras don’t have the highly polished firmwares and features and usually have far lower picture quality especially at night time.

Get 1 decent camera to trial and you will soon see the value in them.

Hello @matt1, congrats on your work on this binding!

I have encountered an issue when using it with my Hikvision DVR.
Since each camera sets up its own streams, there are multiple connections to /ISAPI/Event/notification/alertStream, one for each camera.
Unfortunately the DVR borks after 4-5 concurrent connections with statusCode:4, causing events to not be registered for all cameras.

If you can use a single stream for events for cameras which have the same ip:port configuration, and notify each thing depending on the channelID present in the stream, I thing it would work OK, and we would actually be conserving resources.

I am available to test and provide feedback whenever you need.

Glad to hear you find the binding useful and thanks for reporting the issue, I was not aware there was a limit. I have though about fetching a single stream but so far I have not thought of an easy way to program doing that between multiple things. If it was a HIK only binding it would be to create bridges for the NVR.

I believe there are two ways to use the NVR, one is the way you are now and the second is to enable access to each camera via different ports. See the manual for the NVR for how as I wont assist with that. Then each camera is still the same IP which is the IP of the NVR but each port will be different. If you could test and see if that works around the issue that would be great and I’ll put a note in the readme file for HIK cameras/nvr.

Yes that is the way to go; i use camera direct access this way, every camera on the NVR get’s an unique portnumber.

It is a DVR with 16 Analog cameras (DS-7216HUHI-K2), not an NVR. I don’t see an option to have a different port for each camera, since the event processing is done directly on the DVR and not on the camera itself.

I think a Bridge type object would be a welcome future addition for supporting multicam devices.

New build 2019-07-08 has these changes:

  • updated methods to support the Esp32 cameras. These cameras used two different ports so I had to make some changes to get these running. Example thing and item files can be found here https://community.openhab.org/t/diy-digital-doorbell-peephole-camera/76417/8
    NOTE: These cameras can not provide more than 1 stream at a time unless you use this bindings features to copy and serve the stream. This means you can not start the stream inside the cameras webpage and in openhab at the same time as only the first one you try to open will work.

  • Temporary work around for a bug where some urls were getting reported as being at double port :80:554 from possible issue in onvif library.

  • Updated channel cleaning to keep track of Netty’s channels.

@AchilleGR
I’ll keep it in mind to see if there is an easy way to do it.

I just updated the binding from version a 2.4. Snapshot version to the latest version. With the new binding, my Amcrest camera starts to produce the following messages in the log (nothing has changed in the config of the camera, the thing and the item):

2019-07-11 12:55:52.616 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.2.203:80 is now online.

2019-07-11 12:55:59.625 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.2.203, re-starting it now

2019-07-11 12:56:04.627 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.2.203, re-starting it now

2019-07-11 12:56:09.627 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.2.203, re-starting it now

2019-07-11 12:56:14.638 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.2.203, re-starting it now

2019-07-11 12:56:19.621 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.2.203, re-starting it now

I am in the process of adding a second camera (also Amcrest, but different model). This new camera does not produce the same errors, although it is configured exactly the same ways as the first camera.

@matt1: if you need more information on the configurations, than please get back to me.

Did you clean the cache and tmp folders? in Linux enter this…

sudo service openhab2 stop && sudo rm -rf /var/lib/openhab2/cache/* && sudo rm -rf /var/lib/openhab2/tmp/* && sudo reboot

Also how did you add the camera, with paperUI or with .things files? If with paperUI you will need to delete and re-add the camera due to the way Openhab works, this is not needed if you used things files.

1 Like

thanks for the super quick response.
the cameras are added via things-files.
I cleared cache and temp files with your command above and also restarted openhabian another time afterwards- did not help. The “old” camera continues to report the warning above, whereas the new camera only warns once, and then seems to be ok.

can you disable the working camera, stop snapshots and enable trace mode logging please? I will need some log output to work out why. The first two things just stop loads of logs to make it clearer when the trace is enabled. The readme file covers how to change the log mode.

I will do that in a minute. one question upfront:
I deactivated the running camera in the text file - this became active immediatly.
Then I activated the “old” camera in the text file - the camera does not show up in the log, is not started. Only after a restart of openhab for the camera starts working in openhab.

QUESTION: How do I stop the snapshots?? I took the polling out of the thing file definition and disabled the IMAGE channel, but it still did the snapshots.