IpCamera: New IP Camera Binding

Sorry my mistake, I have edited my reply above so people dont copy wrong examples…
It should be the following.

Thing ipcamera:ONVIF:Bedroom
[
    IPADDRESS="192.168.1.13",
    IMAGE_UPDATE_EVENTS=1,
    UPDATE_IMAGE=true,
    ONVIF_PORT=8899,
    PORT=80,
    SERVER_PORT=-1,
    POLL_CAMERA_MS=2000,
    IP_WHITELIST="DISABLE",
    ONVIF_MEDIA_PROFILE=0
]

Getting a picture from the camera in OH2 works, everything is fine. How to force or check the possibility of running a motion event from a camera ?

Ahh, I did look, but a change like this is very easy to overlook :slight_smile:

No worry… This is a fresh new installation onto my new Odroid C2. So the cache/tmp should be empty regarding ipcamera binding :smiley:

Need to ask all of you using ipcamera binding and ffmpeg. Do any of you also use Zigbee?

Last night when I installed the latest ipcamera bindning. I also installed the ffmpeg using sudo apt-get ffmpeg.
After this, Zigbee stopped working, (it simply stopped… No errors or anything). I then removed FFMPEG using sudo apt remove ffmpeg. Unfortunatly I also used sudo apt autoremove to remove unused packages, which may have been a big mistake. Now I cant get Zigbee to even find the USB port anymore. And I have no idea what exactly went wrong…

Please note, this may have nothing to do with the ipcamera binding at all. It probably got wrong from installing ffmpeg. But perhaps others have experience simular.

I changed the typo mistake in my config file, and the cam went online. But then I got this:

019-08-02 17:07:01.558 [me.event.ThingUpdatedEvent] - Thing 'ipcamera:HTTPONLY:001' has been updated.

==> /var/log/openhab2/openhab.log <==

2019-08-02 17:07:03.279 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 10.4.28.202 is now online.

==> /var/log/openhab2/events.log <==

2019-08-02 17:07:03.283 [hingStatusInfoChangedEvent] - 'ipcamera:HTTPONLY:001' changed from INITIALIZING to ONLINE

==> /var/log/openhab2/openhab.log <==

2019-08-02 17:07:08.550 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - !!!! Camera has closed the channel 	URL:/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=xxxxxxx&password=xxxxxx Cause reported is: {}
java.lang.ArrayIndexOutOfBoundsException: 218409
	at org.openhab.binding.ipcamera.handler.IpCameraHandler$CommonCameraHandler.channelRead(IpCameraHandler.java:699) ~[?:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [279:io.netty.transport:4.1.34.Final]
	at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.channelRead(MyNettyAuthHandler.java:235) [281:org.openhab.binding.ipcamera:2.5.0.201908011244]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [279:io.netty.transport:4.1.34.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323) [276:io.netty.codec:4.1.34.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297) [276:io.netty.codec:4.1.34.Final]
	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [279:io.netty.transport:4.1.34.Final]
	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [275:io.netty.handler:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:677) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529) [279:io.netty.transport:4.1.34.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491) [279:io.netty.transport:4.1.34.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [277:io.netty.common:4.1.34.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [277:io.netty.common:4.1.34.Final]
	at java.lang.Thread.run(Thread.java:748) [?:?]

EDIT:
Found the reason…
I have my rpi calling the cam as well as my Odroid… I guess two cant use the same config at the same time…
Now I need to figure how to stop the damn thing from spamming my logfile :slight_smile:

If your camera is not one with an API (see list of camera brands to buy in the first post of this thread) so you will need to source the motion detection another way. Some ideas are:

  • Zwave PIR sensor, $30 pet friendly ones have been posted on this forum before. Advantages are you can mount away from bugs that go to the IR lights and the way a PIR works will mean less false positive alarms.
  • Software running to do the detection. motion (motioneyeos), blue iris and a few others.

When I searched for your camera model I found it mentioned as often having malware hidden in the cameras firmware, see here…

@Kim_Andersen

Yes that is pretty common, some cameras only allow 1 connection to be made at a time, you can test it by trying to open multiple streams on different tabs of a browser. The binding will allow you to work around this limitation.

The readme has this covered and much more.

Also I strongly recommend if you have multiple cameras to stop using the image channel and to move to this method below. When I setup >4 cameras the Odroid c2 that I am using could not handle the images going to Openhabs event bus at 1fps. More data was being sent then openhab could handle and I got a crash. You lower CPU usage by half and also the memory leaks I have seen are no longer happening and it is simply turning 1 single line of code off that sends the image to Openhabs framework.

New build 2019-08-03 has these changes: NOTE: Delete the older javax soap lib as the binding now uses a newer version, more info below.

  • New ability to fetch any changes made to the cameras controls if made via a 3rd party app and not by Openhab. Currently being trialed on Instar only but if it works nicely can roll it out to other brands.
  • Instar now has the ability to detect when an alarm is occurring and will auto setup what is needed in the cameras settings.
  • Instar PIR alarm channels and controls added.
  • Changes to PTZ made to hopefully work around issues people may have had in the past. The below changes also may help with PTZ failing to work for some people…
  • Changes made to the bindings dependencies. New version of the javax soap lib requires you to delete the old version from the addons folder. This change was made as D-link smart home binding uses the same lib, so we use the same version now to ensure less chances of any issues.
  • Feature.xml changes made.

Install new bind, turned on TRACE logs, restart OH2, see error:

2019-08-05 09:48:32.909 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'ipcamera.things'
2019-08-05 09:48:34.627 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'ipcamers.items'
2019-08-05 09:48:34.732 [DEBUG] [org.openhab.binding.ipcamera        ] - BundleEvent STARTING - org.openhab.binding.ipcamera
2019-08-05 09:48:34.909 [DEBUG] [org.openhab.binding.ipcamera        ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=381, service.bundleid=241, service.scope=bundle, component.name=org.openhab.binding.ipcamera.internal.IpCameraHandlerFactory, component.id=235} - org.openhab.binding.ipcamera
2019-08-05 09:48:34.940 [DEBUG] [org.openhab.binding.ipcamera        ] - BundleEvent STARTED - org.openhab.binding.ipcamera
2019-08-05 09:48:35.597 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - initialize() called.
2019-08-05 09:48:36.614 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.1.13:8899
2019-08-05 09:48:36.640 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Following NPE occured when trying to connect to the camera with ONVIF.java.lang.NullPointerException
2019-08-05 09:48:36.640 [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-08-05 09:48:36.647 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Camera failed to report a valid Snaphot URL, try over-riding the Snapshot URL auto detection by entering a known URL.

Install the D-link smart home binding and that will install dependencies that this binding needs, I think a change was made in the new build system.
Alternatively you can do what it states in the log and provide a snapshot URL with this config
SNAPSHOT_URL_OVERRIDE

added SNAPSHOT_URL_OVERRIDE to things, that helped, Thanx.
Why is the lastMotionType event not working?

Hi Matt

Ive updated to the latest binding for my Dahua 5231R-ZE camears. Ive setup ONVIF users and the things file. Everything comes online but I cant open the url

http://192.168.1.3:54321/ipcamera.mjpeg

Any thoughts?


Thing ipcamera:DAHUA:Driveway[IPADDRESS="192.168.1.112",
PASSWORD="cxxxxx",
USERNAME="camuser",
POLL_CAMERA_MS=2000,
SERVER_PORT=54321,
IP_WHITELIST="DISABLE",
IMAGE_UPDATE_EVENTS=0,
ONVIF_MEDIA_PROFILE=1]

Thanks

Make that equal 0 for ffmpeg to access the main stream with h264. Then setup the first sub stream in the cameras setup as mjpeg format. After doing that try again.

Hi Matt

The substream is already setup as MJPEG on each camera, hence the 1. I only want a MPJEG stream, no H264

What happens if you put this in any browser?

http://camiphere/cgi-bin/mjpg/video.cgi?channel=1&subtype=1

This is what the binding uses and it will be the first substream as the source. You can override it to another url if you wish.

If you ever want to cast the cameras to chromecast you will need h264, this is why by default the mainstream (0) is for h264 and the substream is the mjpeg.
The media profiles setting does nothing to the mjpeg stream or source.

Lastly make sure the binding has admin and not a lower USER rights, turning alarms off and other parts of the API needs full admin.

1 Like

Ill give that all a go in a few days matt and see how I go, thanks!

Hi Matt

Setting up some hikvision cameras, first time. I see this message

09:22:35.560 [WARN ] [ding.ipcamera.handler.IpCameraHandler] - The Streaming Setup for this camera is not valid, check the SERVER_PORT and STREAM_URL_OVERRIDE settings are correct.


Camera is basically default.

And then:

[.ipcamera.internal.MyNettyAuthHandler] - !!!! Something is wrong with the reply back from the camera. WWW-Authenticate header: qop:auth, realm:

The camera is MJPEG stream, and thats working fine using URL:

http://192.168.1.201/Streaming/channels/102/httppreview

things:


Thing ipcamera:HIKVISION:North_Yard [
    IPADDRESS="192.168.1.200", PASSWORD="password",
    USERNAME="admin",
    POLL_CAMERA_MS=2000,
    SERVER_PORT=50001]


Thing ipcamera:HIKVISION:South_Steps [
    IPADDRESS="192.168.1.201", PASSWORD="password",
    USERNAME="admin",
    POLL_CAMERA_MS=2000,
    SERVER_PORT=50002]


Thing ipcamera:HIKVISION:Driveway [
    IPADDRESS="192.168.1.202", PASSWORD="password",
    USERNAME="admin",
    POLL_CAMERA_MS=2000,
    SERVER_PORT=50003]


Thing ipcamera:HIKVISION:Carport [
    IPADDRESS="192.168.1.203", PASSWORD="password",
    USERNAME="admin",
    POLL_CAMERA_MS=2000,
    SERVER_PORT=50004]

You must be using an older version as I can not find that text in the source code, I often change the logging to make things clearer or better formatted in the logs. Please make sure it is the latest version and you clean cache and temp folders.

I would need some trace level log output to be sure but it appears the realm is missing which is required for DIGEST to work. Check if your camera has a newer firmware version and update to it. The firmwares that ship in cameras usually are out of date.

hi matt, ive changed them all to basic auth. Ill check the firmware levels
binding version is:

212 x Active   x  80 x 2.5.0.201904071342     x IpCamera Binding

Hi Matt
Im now on 5.5.5 , latest for each camera.

Same errors. All are set to digest/basic


11:22:47.373 [ERROR] [ml.internal.messaging.saaj.client.p2p] - SAAJ0008: Bad Response; Not Found
11:22:47.373 [WARN ] [ding.ipcamera.handler.IpCameraHandler] - SOAP error when trying to connect with ONVIF. This may indicate your camera does not fully support ONVIF, check for an updated firmware for your camera. Will try and connect with HTTP. Camera at IP:192.168.1.201, fault was com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (404Not Found
11:22:47.377 [INFO ] [ding.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.1.201:80 is now online.
11:22:47.377 [WARN ] [ding.ipcamera.handler.IpCameraHandler] - The Streaming Setup for this camera is not valid, check the SERVER_PORT and STREAM_URL_OVERRIDE settings are correct.
11:22:47.380 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'ipcamera:HIKVISION:South_Steps' changed from INITIALIZING to ONLINE
11:22:47.384 [ERROR] [ml.internal.messaging.saaj.client.p2p] - SAAJ0008: Bad Response; Not Found
11:22:47.384 [ERROR] [ml.internal.messaging.saaj.client.p2p] - SAAJ0008: Bad Response; Not Found
11:22:47.384 [WARN ] [ding.ipcamera.handler.IpCameraHandler] - SOAP error when trying to connect with ONVIF. This may indicate your camera does not fully support ONVIF, check for an updated firmware for your camera. Will try and connect with HTTP. Camera at IP:192.168.1.202, fault was com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (404Not Found
11:22:47.384 [WARN ] [ding.ipcamera.handler.IpCameraHandler] - SOAP error when trying to connect with ONVIF. This may indicate your camera does not fully support ONVIF, check for an updated firmware for your camera. Will try and connect with HTTP. Camera at IP:192.168.1.203, fault was com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (404Not Found
11:22:47.385 [INFO ] [ding.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.1.202:80 is now online.
11:22:47.385 [INFO ] [ding.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.1.203:80 is now online.
11:22:47.385 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'ipcamera:HIKVISION:Driveway' changed from INITIALIZING to ONLINE
11:22:47.385 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'ipcamera:HIKVISION:Carport' changed from INITIALIZING to ONLINE
11:22:47.386 [ERROR] [ml.internal.messaging.saaj.client.p2p] - SAAJ0008: Bad Response; Not Found
11:22:47.386 [WARN ] [ding.ipcamera.handler.IpCameraHandler] - SOAP error when trying to connect with ONVIF. This may indicate your camera does not fully support ONVIF, check for an updated firmware for your camera. Will try and connect with HTTP. Camera at IP:192.168.1.200, fault was com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (404Not Found

Did you also upgrade to the latest version of the binding, the version you listed above is quite old.

1 Like