IpCamera: New IP Camera Binding

Hi Skinah,
for me the warn become an error and often, I attach a part of my log.
my things file for camera:


Thing ipcamera:GROUPDISPLAY:OutsideCameras
[
        POLL_CAMERA_MS=2000,
        SERVER_PORT=54320,
        FFMPEG_OUTPUT="/tmpfs/OutsideGroup/",
        FIRST_CAM="GiardinoPost_Camera",
        SECOND_CAM="Portico_Camera",
        THIRD_CAM="Garage_Camera",
        FORTH_CAM="TerrazzaCan_Camera",
        FIFTH_CAM="Terrazza_Camera",
        MOTION_CHANGES_ORDER=true
]

Thing ipcamera:HIKVISION:GiardinoPost_Camera "GiardinoPost_Camera" @ "Cameras"
[
        IPADDRESS="192.168.178.64",
        PORT=80,
        SERVER_PORT=54300,
        PASSWORD="MyPSW",
        USERNAME="MyUsr",
        POLL_CAMERA_MS=1000,
        UPDATE_IMAGE=false,
        IMAGE_UPDATE_EVENTS=1,
        STREAM_URL_OVERRIDE="http://192.168.178.64:80/ISAPI/Streaming/channels/102/httpPreview",
        GIF_PREROLL=2,
        GIF_POSTROLL=5,
        FFMPEG_OUTPUT="/tmpfs/GiardinoPost_Camera/",
        FFMPEG_INPUT="rtsp://192.168.178.64:554/Streaming/channels/103",
        IP_WHITELIST="DISABLE"

I stop here, but I configured 5 cameras.

log.pdf (51.7 KB)

Can be somethings directly in hikvision camera configuration?
Without “STREAM_URL_OVERRIDE” it dont work for me in Mjpeg, so I gived the URL and it fast connect when I open the page in BasicUI or mobile phone APP. showing me the video.
If I take off “STREAM_URL_OVERRIDE” I have the same issue.

If can help I can change log type and send you the file.

My item file:

Group gCameraEvent
Group gCameraGif

Switch GiardinoPost_Camera_CreateGif "Create animated GIF" (gCameraGif) { channel="ipcamera:HIKVISION:GiardinoPost_Camera:updateGif" }
String GiardinoPost_Camera_TextOverlay "Text to overlay" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:textOverlay" }
String GiardinoPost_Camera_APIAccess "Access the API" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:apiAccess" }
String GiardinoPost_Camera_MjpegStreamUrl "Mjpeg Stream" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:streamUrl" }
String GiardinoPost_Camera_HlsStreamUrl "HLS Stream" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:hlsUrl" }
String GiardinoPost_Camera_RTSPStreamUrl "RTSP Stream" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:rtspUrl" }
Switch GiardinoPost_Camera_StartHLS "HLS on/off" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:startStream" }
Switch GiardinoPost_Camera_EnableMotionAlarm "MotionAlarm on/off" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:enableMotionAlarm" }
Switch GiardinoPost_Camera_MotionAlarm "Motion detected" (gCameraEvent) { channel="ipcamera:HIKVISION:GiardinoPost_Camera:motionAlarm" }
Switch GiardinoPost_Camera_EnableLineAlarm "LineAlarm on/off" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:enableLineCrossingAlarm" }
Switch GiardinoPost_Camera_LineAlarm "Line Alarm detected" (gCameraEvent) { channel="ipcamera:HIKVISION:GiardinoPost_Camera:lineCrossingAlarm" }
DateTime GiardinoPost_Camera_LastMotionTime "Time motion was last detected [%1$ta %1$tR]"
Switch GiardinoPost_Camera_FieldDetectionAlarm "Intrusion detected" (gCameraEvent) { channel="ipcamera:HIKVISION:GiardinoPost_Camera:fieldDetectionAlarm" }
Switch GiardinoPost_Camera_EnableFieldDetectionAlarm "Allarme intrusione on/off" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:enableFieldDetectionAlarm" }
String GiardinoPost_Camera_LastMotionType "Last Motion Type" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:lastMotionType" }
Dimmer GiardinoPost_Camera_MotionControl "Motion Threshold [%d]" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:controlMotionAlarm" }
String GiardinoPost_Camera_ImageUrl "Image Url" { channel="ipcamera:HIKVISION:GiardinoPost_Camera:imageUrl" }

Also here I stopped at the first camera, all the others has the same configuration.
I removed the LED Switch and Dimmer items because it seems to have no effect on the camera.

Currently all streams are functional.
All alarm switches work, the indication of the last alarm with the time rule to know at what time it occurred works.
But when I had enabled the creation of GIFs in the log I had the folder full alarm and another HTML alarm, but I both deleted them at the moment, just to focus on one problem at a time.

Can I do somethings to help you in helping me?

Jad

Now the GROUPDISPLAY:OutsideCameras is not working, I have this in log:

2020-04-25 22:47:13.729 [WARN ] [ra.internal.StreamServerGroupHandler] - Exception caught from stream server:{}

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[?:1.8.0_222]

at java.util.ArrayList.get(ArrayList.java:433) ~[?:1.8.0_222]

at org.openhab.binding.ipcamera.internal.StreamServerGroupHandler.sendSnapshotImage(StreamServerGroupHandler.java:154) ~[?:?]

at org.openhab.binding.ipcamera.internal.StreamServerGroupHandler.channelRead(StreamServerGroupHandler.java:114) ~[?:?]

at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [bundleFile:4.1.48.Final]

at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [bundleFile:4.1.48.Final]

at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [bundleFile:4.1.48.Final]

at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) [bundleFile:4.1.48.Final]

at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:321) [bundleFile:4.1.48.Final]

at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:295) [bundleFile:4.1.48.Final]

at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) [bundleFile:4.1.48.Final]

at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [bundleFile:4.1.48.Final]

at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [bundleFile:4.1.48.Final]

at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [bundleFile:4.1.48.Final]

at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [bundleFile:4.1.48.Final]

at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [bundleFile:4.1.48.Final]

at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [bundleFile:4.1.48.Final]

at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [bundleFile:4.1.48.Final]

at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [bundleFile:4.1.48.Final]

at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [bundleFile:4.1.48.Final]

at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [bundleFile:4.1.48.Final]

at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [bundleFile:4.1.48.Final]

at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [bundleFile:4.1.48.Final]

at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) [bundleFile:4.1.48.Final]

at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) [bundleFile:4.1.48.Final]

at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) [bundleFile:4.1.48.Final]

at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) [bundleFile:4.1.48.Final]

at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) [bundleFile:4.1.48.Final]

at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [bundleFile:4.1.48.Final]

at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [bundleFile:4.1.48.Final]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

You have it backwards, you have to try to help yourself first before I will bother to look. Read what to do if you have issues in the readme AND also re-read my previous reply as I already told you what you need to do.

Next build a nicer message will go into the DEBUG logs, guessing you had no online cameras when the group display ran that code. A single line of the log is useless without the preceding lines of TRACE output.

Currently it only supports up to 4 cameras in a group until it is a proven feature. Consider groups as experimental at the moment.

@Normann_P_Nielsen
Sorry I don’t use docker and I suspect it is related as docker will block 1 program from being able to talk to others. Best to create a whole new thread asking Dockers users how to get a binding to work. It may be related to the binding needing to talk with ffmpeg so allowing everything to have rights and access for it all to work will need a Docker expert which I am not. I know others have done it.

New build 2020-04-27 has these changes:

  • Instar alarm server changes which take advantage of features in the latest firmware for faster and more reliable alarm detection.
  • Ability to force the use of ffmpeg to generate snapshots with ONVIF capable cameras.
  • Fix issue with queries on group displays.

Has anyone had success with an Eufy camera? After several hours of testing I’m giving up now.

The camera has the specialty that it is battery operated and thus only sends an rtsp stream when motion is detected. And it does not support anything but rtsp. From the previous comments I read that might not (yet) be supported if I understood correctly?

It’d be great to be able to use those cameras. For the time when they are offline, either the last sent picture could be shown or a “camera not active” placeholder.

Yes that would cause major issues for the binding. What happens if you try and open the RTSP stream with VLC both when there is motion and when there is none?

Depending on how it handles things it may need a custom standalone binding to cover that use case.

Found this post about someone working on a binding?

Hey @matt1

Problably something missing in Docker , yes

New build 2020-04-28 has new features for all cameras. Readme not yet updated but below info should be enough to get people playing…

  • Ability to set the gif filename to anything you wish, handy for timestamping the file. Use the String channel called gifFilename.
  • Ability to record to MP4 by setting a number channel called recordMp4 to how many seconds you wish to record. You can also set the filename with a string channel called mp4Filename. The channel will reset to 0 when the recording file is available to be used and this can trigger a rule if you watch for when it is set back to 0.

The above features are not tested much and only just added, consider them experimental. To get them working you probably have to clean cache and tmp and reboot multiple times as they are new channels. If you used paperUI to setup the camera, it will need to be deleted and re-added.

When I open the rtsp stream with VLC while the camera is active, it displays the video. As soon an the motion stops, the video stops as well (VLC seems to automatically disconnect). When I try to establish the connection while there is no motion, I only get an error message, no video feed at all. I don’t remember the exact wording, but it was like “service not available”, “resource not found” or something like that.

The binding you mention seems to be not a good fit:

  • It uses the web Eufy API (eufylife.com) instead of the available local rtsp stream
  • It currently is broken because the Eufy API is “only” reverse engineered. So using the officially available rtsp seems like a more stable approach for me.
  • It does not support the Homebase 1 and the eufyCam (yet?)

I understand that it might be possible to extend that Eufy Doorbell binding so that it works again and eveneually supports the eufyCam. But since I don’t need the other web API functions I would prefer being able to use a binding that just solidly gets the rtsp stream into openHAB when available :slight_smile:

It would be possible to get it running but IMHO it should be a separate binding I cant see any easy way to include it in this one. It would be valuable to have that as a battery powered camera that can work without a cloud and still work when you internet connection goes down is a valuable thing to have.

A few options if you cant change to a different camera that uses a wired connection which is what I think is the better option…

Check the thread out here. It may be possible to do this with a script that keeps polling the camera but I think you will still hit issues and it will need a dedicated binding.

Check into using older firmware which is know to be less secure and using that binding it may work?

If you cant code, you can help out with a bounty.

i tried this:
I left only one camera configured in things file and in the sitemap and I no longer had any warnings for 24 h.
Then I added the second camera and after 2 hours the follow warnings reappeared

2020-04-29 22:04:51.001 [WARN ] [io.netty.channel.nio.NioEventLoop   ] - Selector.select() returned prematurely 512 times in a row; rebuilding Selector io.netty.channel.nio.SelectedSelectionKeySetSelector@11b3db7.

2020-04-29 23:06:52.114 [WARN ] [io.netty.channel.nio.NioEventLoop   ] - Selector.select() returned prematurely 512 times in a row; rebuilding Selector io.netty.channel.nio.SelectedSelectionKeySetSelector@14e52af.

2020-04-29 23:06:52.125 [WARN ] [io.netty.channel.nio.NioEventLoop   ] - Selector.select() returned prematurely 512 times in a row; rebuilding Selector io.netty.channel.nio.SelectedSelectionKeySetSelector@146c4c3.

Jad

log_30_04_20.pdf (51.9 KB)

How do you do fellow kids?
After successfully implementing the Homematic-binding, I currently despair trying to get my Reolink RLC-410-5MP running.
State says

OFFLINE - CONFIGURATION_ERROR Camera failed to report a valid Snaphot URL, try over-riding the Snapshot URL auto detection by entering a known URL.

openhab.log says

blablabla We got an ONVIF error400
blablabla <SOAP-ENV:Envelope blablabla>Sender not Authorized</SOAP-ENV:Envelope>

Manually calling the ONVIF-website refers to a missing GET-implementation:

<SOAP-ENV:Fault>
SOAP-ENV:Client
HTTP GET method not implemented
</SOAP-ENV:Fault>

Where did I go wrong?

First make sure the Timezone and time is correct on both the camera and also openhabs server. The UTC time needs to match for onvif to work.

A work around that the binding is telling you, Give the binding the URL from here.

If that does not work you can over ride the snapshot URL to be ffmpeg to create the snapshots from the RTSP stream using ffmpeg after you install that program of course.

Readme covers all of this in more detail.

1 Like

Sometimes it may be worth looking through the thread to see, if others have already been there :smiley: The Reolink RLC-410 has been mentioned quite a few times in this thread. And lately I have posted my setup for this specific camera. Look a few messages back, (14 days back).
It will NOT work with Onvif. You need to install it as a HTTP only.

1 Like

Kudos! Excellent advice!
Works like a charm on first try!

New build 2020-05-04 has these changes, it is a big bug fix release mostly for ONVIF cameras without an API:

  • ONVIF fix as snapshot urls where getting wrongly reported as having http in them twice.
  • Fixes for setting the snapshot to use ffmpeg not being reliable.
  • Fix bug that caused multiple connections when the binding soft restarted.
  • Better logging to guide users that miss or enter wrong details.
  • Fixed slow ONVIF reply back from camera stopping rtsp features from working.

Testing a lot of features at the moment for bugs after a lot of changes to make the binding closer to being merged may have broken things. If you upgrade from older versions and notice something stopped working please post as there are so many combinations to test.

FYI, Some useful tools for cheap cams:


Hi,
Have just setup a Foscam 9928P and having some problems with PTZ.
The ipcamera:FOSCAM:foscam:gotoPreset channel is of type number but the camera is expecting a string. It works ok using the cgi method.
http://CAMERA_IP:PORT/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=<PRESET_NAME>&usr=USR&pwd=PASS

The binding produces the following error:
2020-05-04 10:59:53.271 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘front’ of item CameraPreset with format ‘%.0f’: f != java.lang.String

The binding does not use the CGI method, it uses ONVIF methods to move. If you want me to look at it, please send some DEBUG level log when the camera is connecting and it should have a heap of long XML looking replies in it, send this in a private message and do a find / replace on your password to remove it.

@Sascha_
The binding has most if not all of those abilities already built in and done in java in hopefully a seamless experience for a user with no scripting knowledge. Thanks for the heads up on them thou as it is always good to know.