IpCamera: New IP Camera Binding

Currently I would like to fix any issues with Dahua that are currently implemented before moving to new features. Testing the current build it appears that the stream stops when u turn it on and off via the binding controls. Not sure if it is the on commands need extra arguments to enable different days and times or if the stream itself stops. An improvement to the framework to allow easy checking if a stream is still running is needed then I will look in more depth.

on my dahua eavent without any motion switch change via binding, event manager didnā€™t detect any activity

New build 28-10-2018 has following changes:

  • Changes to check and ensure the alarm stream for both HIK and DAHUA is always running.
  • Different url for dahua alarm stream.

@Kristo
See if this works for you as I can now turn the alarm on and off and the stream works fine. Every 15 seconds it is normal for it to reopen the stream.

Yes now motion works fine - after quick testing :slight_smile:
Line cross - tripwire is working too

I just thinking if switch to on/off linecross detection will work as now dahus have IVS including many different smart detection. i will look in API

1 Like

Hi Matt has any one used an Digoo came. Itā€™s 1:shows an IP.
2: cheep to getting me started with things.

I am testing a Phylink PLC-132PSW 1080HD camera as HTTP only camera. Snap shot of stream 0 is cut in half, Snapshot of stream 1 is OK.

org.openhab.binding.ipcamera-2.3.0-SNAPSHOT

  • Stream 1 768x432
  • Stream 0 1920x1080 >>>> ā€™ we get too much data please report thisā€™

Here is part of the log. The full TRACE log is too long to post here.

2018-11-01 14:12:47.356 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 5286, cap: 5286/5286, unwrapped: PooledUnsafeDirectByteBuf(ridx: 38054, widx: 38054, cap: 65536)), decoderResult: success)

2018-11-01 14:12:47.361 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 8192, widx: 40000, cap: 65536)), decoderResult: success)

2018-11-01 14:12:47.368 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 16384, widx: 40000, cap: 65536)), decoderResult: success)

2018-11-01 14:12:47.374 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 24576, widx: 40000, cap: 65536)), decoderResult: success)

2018-11-01 14:12:47.381 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 8192, cap: 8192/8192, unwrapped: PooledUnsafeDirectByteBuf(ridx: 32768, widx: 40000, cap: 65536)), decoderResult: success)

2018-11-01 14:12:47.387 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 7232, cap: 7232/7232, unwrapped: PooledUnsafeDirectByteBuf(ridx: 40000, widx: 40000, cap: 65536)), decoderResult: success)

2018-11-01 14:12:47.392 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - !!!! Camera has closed the channel 	URL:/live/0/jpeg.jpg Cause reported is: {}

	at org.openhab.binding.ipcamera.handler.IpCameraHandler$CommonCameraHandler.channelRead(IpCameraHandler.java:526) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.channelRead(MyNettyAuthHandler.java:229) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:646) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:581) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:460) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [228:org.openhab.binding.ipcamera:2.3.0.201808150817]

2018-11-01 14:12:47.397 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent

2018-11-01 14:12:47.401 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - We got too much data from the camera, please report this.

2018-11-01 14:12:47.450 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Snapshot recieved: Binding will now close the channel.

2018-11-01 14:12:47.453 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0 	URL:/live/0/jpeg.jpg

2018-11-01 14:12:47.456 [DEB

Hello,

Iā€™have been trying for a while now without succes.
Anyone got a Dahua IPC-HFW 3200C working?

thank you

@m4rk
What does the list of headers that the camera replies with look like?
It is something like
200 OK
http 1.1
content-length 190000
ā€¦

My guess is the camera does not report a content length and the size of the snapshot is > 500,000 bytes try playing with the compression settings of the camera to lower the size and it will probably be fine, otherwise some more of the log sent to me in a PM would be helpful to track it down.

@jpcolin
Number one step with any linux or openhab fault finding is to look into the log files, the first post in this thread goes into how to change the log level to get more information and also how to see the log.

Sure when I get some spare time Iā€™ll look at that and/or submitting to be included in Openhabā€™s core bindings but currently any spare time is put into extending features. I still need certain features to be added for my own home and needs.

@matt1

to keep in mind i created issue on github to implement more detection control

New build 06-11-2018 has new changes all are for DAHUA only (works on Amcrest if you setup as Dahua):

  • DAHUA now has new alarms for:
    0 and 1 external alarm inputs
    CrossLineDetection //: tripwire event
    CrossRegionDetection //: intrusion event
    ParkingDetection //: parking detection event
    FaceDetection //: face detect event
    AudioMutation //: intensity change

  • Ability to turn audio alarm on and off

  • Ability to change the audio alarms threshold. Note 0 will turn off the alarm as it is a non valid number for dahua. 100 levels of control.

  • Dejitter value has been added to movement and audio alarms to smooth out the switch movements.

Hi @matt1, I have a Foscam FI9900P. Setup worked fine. I have defined in Web interface of the camera for Motion Detection that Mail shall be send, snapshot been taken, changed the durations and intervalls and selected all hours in the schedule. When I now via sitemap in Openhab switch the trigger ā€œEnable/Disable the Motion Alarmā€ to OFF and later back to ON, all my settings for Motion Detection in the camera are cleared and intervalls back to initial value.

My question: do you set them all back to initial values within the binding when the switch is set to OFF? Because when I disable the Motion Detection in the cameras web interface and later enable it again, all settings of the fields of that screen are kept with my changes.

I mean the best solution would be to keep the other fields of this screen unchanged, because they are not available as channels in the interface.

Regards, Siggi

Please read the readme file at github as I added a new special step for foscam that contains the fix. It is not possible to not touch those settings due to how Thier api works hence a work around was needed.

Hi @matt1,

I tested all alarms and controls are working well on Dahua. Thanks for this perfect work!

If you will find time please remember about output control

Thanks Matt. I was not aware that this description is related to my issue :slight_smile: Got it! Siggi

How does facedetection work??

You need a camera that supports it, then when the camera detects ANY face openhab has a switch move that can trigger a rule to do whatever you wish. All faces are treated the same way as it is not advanced face recognition to ID who the face belongs to.

A number of the ā€œSmartā€ alarms can be used to drastically reduce the false positive alarms that a generic movement alarm can make. IE a branch moving in the wind, dog or cat in your yard or even a shadow from a cloud causing a false alarm.

Which Dauha cam supports face detection?

Hi Kim ,

If you are looking china version iā€™m using two of them IPC-HDBW4433R-AS and IIPC-HFW4431R-Z , please note that if you will switch on face detection no other smart detection will work in same time. Only simple motion will work with Face detection

New build 10-11-2018 has following changes:

  • Amcrest has a lot of the dahua stuff copied across but will leave it on the old alarm method for older cameras. Recommend amcrest cameras that work get setup as dahua from now on.

  • Dahua has 2 new alarms in this build item taken and item left.

  • Updated readme file

  • older http version 1.0 cameras can now use more ram for larger quality snapshots

  • PTZ changes to try and catch all errors that stem from cameras not supporting their current location when asked via onvif.