IpCamera: New IP Camera Binding

Thanks Matt, Sure, thats the snapshot but the URL i used was apparently the substream (MJPEG feed)

EDIT: Found it inside a sitemap example

@dastrix80
Thanks for feedback, the readme is now updated to better cover this and also the other urls which were also missing for the animated gif.

The idea of the binding is that you do not need to open the api for your camera, and if you own multiple brands they should all work the same way inside Openhab without needing to hunt around this forum for examples.

For now, ignore any warnings or errors when your camera is connecting as they relate to ONVIF possibly not working with your camera, I will be taking a look at this when I have some time but since I did not write the ONVIF library and I don’t have any issues with 3 different brands of cameras that I own, this makes it hard to track down. The good news is you only need ONVIF if the camera is PTZ and you wish to move the camera. If the camera is not PTZ then you will gain nothing.

1 Like

No worries mate! it’s working now and yes, no PTZ so I’m not too concerned. Thanks for all your help!

Which one are you using? I have here 2 Luowice Cameras and dont get them configured as well.

I have the LWS-V180-2MP-GSDE.

I have the same issue and what you can do is turn off the update image so the image doesn’t need to refresh. Then you can right a rule that take a image every time there is motion. The one thing i don’t find is how I can turn the update off because persistence don’t set it off and start up rule won’t set it off either. Maybe someone can help?

Continous crashes only for ip cameras:

Thing ipcamera:HTTPONLY:001 "Webcam garage" @ "Garage"
        [
                IPADDRESS="192.168.1.81",
                PASSWORD="xxxxxxxx",
                USERNAME="xxxxxxxx",
                SNAPSHOT_URL_OVERRIDE="http://192.168.1.81:8080/stream/snapshot.jpg",
                PORT=8080,
                POLL_CAMERA_MS=2000,
                UPDATE_IMAGE=true,
                IMAGE_UPDATE_EVENTS=1
        ]
//
//
Thing ipcamera:HTTPONLY:002 "Web HTTP Sud" @ "Webcams"
        [
                IPADDRESS="192.168.1.82",
                PASSWORD="xxxxxxx",
                USERNAME="xxxxxxx",
                SNAPSHOT_URL_OVERRIDE="http://192.168.1.82/dms?nowprofileid=1",
                PORT=80,
                POLL_CAMERA_MS=2000,
                UPDATE_IMAGE=true,
                IMAGE_UPDATE_EVENTS=1
        ]
//
//
Thing ipcamera:HTTPONLY:003 "Web HTTP Est" @ "Webcams"
        [       IPADDRESS="192.168.1.83",
                PASSWORD="xxxxxxx",
                USERNAME="xxxxxxx",
                SNAPSHOT_URL_OVERRIDE="http://192.168.1.83/dms?nowprofileid=2",
                PORT=80,
                POLL_CAMERA_MS=2000,
                UPDATE_IMAGE=true,
                IMAGE_UPDATE_EVENTS=1
        ]
//

2019-09-04 09:00:59.480 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - !!!! Camera has closed the channel     URL:/stream/snapshot.jpg Cause reported is: {}
java.lang.NullPointerException: null
        at java.util.Base64$Encoder.encode(Base64.java:261) ~[?:?]
        at java.util.Base64$Encoder.encodeToString(Base64.java:315) ~[?:?]
        at org.eclipse.smarthome.core.library.types.RawType.toFullString(RawType.java:84) ~[?:?]
        at org.eclipse.smarthome.core.items.events.ItemEventFactory.createStateEvent(ItemEventFactory.java:254) ~[?:?]
        at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.sendUpdate(ProfileCallbackImpl.java:137) ~[?:?]
        at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onStateUpdateFromHandler(SystemDefaultProfile.java:54) ~[?:?]
        at org.eclipse.smarthome.core.thing.internal.CommunicationManager.lambda$9(CommunicationManager.java:477) ~[?:?]
        at org.eclipse.smarthome.core.thing.internal.CommunicationManager.lambda$11(CommunicationManager.java:497) ~[?:?]
        at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
        at org.eclipse.smarthome.core.thing.internal.CommunicationManager.handleCallFromHandler(CommunicationManager.java:493) ~[?:?]
        at org.eclipse.smarthome.core.thing.internal.CommunicationManager.stateUpdated(CommunicationManager.java:475) ~[?:?]
        at org.eclipse.smarthome.core.thing.internal.ThingManagerImpl$1.stateUpdated(ThingManagerImpl.java:167) ~[?:?]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.updateState(BaseThingHandler.java:287) ~[?:?]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.updateState(BaseThingHandler.java:306) ~[?:?]
        at org.openhab.binding.ipcamera.handler.IpCameraHandler.access$5(IpCameraHandler.java:1) ~[?:?]
        at org.openhab.binding.ipcamera.handler.IpCameraHandler$CommonCameraHandler.channelRead(IpCameraHandler.java:718) ~[?:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [230:io.netty.transport:4.1.34.Final]
        at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.channelRead(MyNettyAuthHandler.java:235) [232:org.openhab.binding.ipcamera:2.5.0.201908030247]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [230:io.netty.transport:4.1.34.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323) [227:io.netty.codec:4.1.34.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297) [227:io.netty.codec:4.1.34.Final]
        at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [230:io.netty.transport:4.1.34.Final]
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [225:io.netty.handler:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:677) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529) [230:io.netty.transport:4.1.34.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491) [230:io.netty.transport:4.1.34.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [229:io.netty.common:4.1.34.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [229:io.netty.common:4.1.34.Final]
        at java.lang.Thread.run(Thread.java:748) [?:?]

Hi,

my Foscam 9900p is working. But I dont understand the setting IMAGE_UPDATE_EVENTS. I have configured the camera as follows:

Blockquote
Thing ipcamera:FOSCAM:Einfahrt “Kamera Einfahrt” @ “Kameras”
[
IPADDRESS=“192.168.0.xxx”,
USERNAME=“xxxx”,
PASSWORD=“xxxxxxx”,
PORT=80,
SERVER_PORT=50001,
UPDATE_IMAGE=false,
POLL_CAMERA_MS=5000,
GIF_PREROLL=0,
GIF_POSTROLL=6,
IMAGE_UPDATE_EVENTS=2,
IP_WHITELIST=“(127.0.0.1)(192.168.0.xxxxx)(192.168.0.xxxxx)”,
SNAPSHOT_URL_OVERRIDE=“http://192.168.0.xxx/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xxxx&pwd=xxxxx”,
FFMPEG_OUTPUT=“/tmpfs/Einfahrt/”,
FFMPEG_INPUT=“rtsp://xxxxx:xxxxx@192.168.0.xxxxx:80/videoSub”
]

and the following items

Blockquote
Image IP_Kamera_Einfahrt_Image “Kamera Bild” { channel=“ipcamera:FOSCAM:Einfahrt:image” }
Switch IP_Kamera_Einfahrt_Image_Update “Neues Bild” { channel=“ipcamera:FOSCAM:Einfahrt:updateImageNow” }
Switch IP_Kamera_Einfahrt_Create_Gif “Erstelle animiertes GIF” { channel=“ipcamera:FOSCAM:Einfahrt:updateGif” }
Switch IP_Kamera_Einfahrt_Motion_Alarm “Einfahrt Bewegung” { channel=“ipcamera:FOSCAM:Einfahrt:motionAlarm” }
String IP_Kamera_Einfahrt_Image_URL “Image URL” { channel=“ipcamera:FOSCAM:Einfahrt:imageUrl” }
String IP_Kamera_Einfahrt_Stream_URL “HLS Stream URL” { channel=“ipcamera:FOSCAM:Einfahrt:hlsUrl” }
String IP_Kamera_Einfahrt_RTSP_Stream_Url “RTSP Stream” { channel=“ipcamera:FOSCAM:Einfahrt:rtspUrl” }

I wnat that the Image item is only updated in the PaperUI on motion. But the picture is only updated if I turn on the updateImageNow channel. But than I get all the time ( each 5 sec. ) new images which I want to prevent. What do I wrong here?

best regards René

Hi,

Is it possible for IpCamera binding to work with Foscam R2 camera and use PTZ functions?
That camera has these options (https://www.foscam.es/descarga/Foscam-IPCamera-CGI-User-Guide-AllPlatforms-2015.11.06.pdf) and ONVIF protocol.
I have tried to adjust all settings but cannot force OpenHAB to send PTZ commands to camera.
So far only picture in a frame works with options like below. No PTZ.

My setup is:

  • OpenHAB 2.5.0.M3 on RPi3 (openHABian)
  • IpCamera binding from 03-Aug-2019
  • Foscam R2 camera

During the startup in log (with TRACE log level) there is:

2019-09-13 18:04:39.171 [DEBUG] [org.openhab.binding.ipcamera        ] - BundleEvent STARTING - org.openhab.binding.ipcamera
2019-09-13 18:04:39.178 [DEBUG] [org.openhab.binding.ipcamera        ] - BundleEvent STARTED - org.openhab.binding.ipcamera
2019-09-13 18:04:39.246 [DEBUG] [org.openhab.binding.ipcamera        ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=332, service.bundleid=209, service.scope=bundle, component.name=org.openhab.binding.ipcamera.internal.IpCameraHandlerFactory, component.id=185} - org.openhab.binding.ipcamera
2019-09-13 18:04:40.965 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - initialize() called.
2019-09-13 18:04:41.999 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.138:8885
2019-09-13 18:04:42.141 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Following NPE occured when trying to connect to the camera with ONVIF.java.lang.NullPointerException
2019-09-13 18:04:42.144 [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-09-13 18:04:42.839 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.138/cgi-bin/CGIProxy.fcgi?usr=user&pwd=password&cmd=snapPicture2
2019-09-13 18:04:43.828 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/CGIProxy.fcgi?usr=user&pwd=password&cmd=snapPicture2
2019-09-13 18:04:43.831 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have  opened  a  brand NEW channel:0 	GET:/cgi-bin/CGIProxy.fcgi?usr=user&pwd=password&cmd=snapPicture2
2019-09-13 18:04:43.938 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IpCamera file server for camera 192.168.0.138 has started on port 50001
2019-09-13 18:04:43.945 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.0.138 is now online.

ipcamera.things

Thing ipcamera:FOSCAM:001 [
    IPADDRESS="192.168.0.138",
    PASSWORD="password",
    USERNAME="user",
    ONVIF_PORT=8885,
    PORT=88,
    POLL_CAMERA_MS=60000,
    SERVER_PORT=50001,
    UPDATE_IMAGE=false
]

ipcamera.items

Switch  CamUpdateImage  "Get new picture"       { channel="ipcamera:FOSCAM:001:updateImageNow" }
Image   CamImage                                { channel="ipcamera:FOSCAM:001:image" }
Dimmer  CamPan          "Pan [%d] left/right"   { channel="ipcamera:FOSCAM:001:pan" }
Dimmer  CamTilt         "Tilt [%d] up/down"     { channel="ipcamera:FOSCAM:001:tilt" }
Dimmer  CamZoom         "Zoom [%d] in/out"      { channel="ipcamera:FOSCAM:001:zoom" }
String  CamVideoUrl     "url"                   { channel="ipcamera:FOSCAM:001:videourl"}

cam.sitemap

sitemap cam label="Cam" icon="home" {

        Text label="Camera" icon="camera"{
        Image url="http://192.168.0.138:88/cgi-bin/CGIProxy.fcgi?usr=user&pwd=password&cmd=snapPicture2" item=CamImage
                Switch item=CamUpdateImage
                Slider item=CamPan icon=movecontrol
                Slider item=CamTilt icon=movecontrol
                Slider item=CamZoom icon=zoom
        }
}

I was trying different options like ONVIF port and authorization:

Also cache and temp were cleaned and everything was restarted at least few times.

Maybe someone can help me with that issue. Especially @matt1’s help would be appreciated :slight_smile:

Thanks

Resolved creahes for HTTPONLY cameras :
IMAGE_UPDATE_EVENTS=1
causes random crashes. I took it away from all cameras and they run correctly.

@rene54321

Try changing UPDATE_IMAGE=false to true instead otherwise it only updates when you switch the updateImageNow control to on. Think of UPDATE_IMAGE as the state that the binding starts up in
 @Bucofski this is the info you were looking for.

@kristofejro
I suggest you test the camera out with the opensource program called ONVIF Device Manager, you need to use absolute movement controls to test what the binding tries to do. If it works in there then it will need a change to the ONVIF library that does the ptz functions.

Thanks @matt1 for replay.
I have tried ONVIF Device manager and it works just fine with my camera. I can control it without any problem.

Can you please explain what it means to use: “use absolute movement controls” and this part “If it works in there then it will need a change to the ONVIF library that does the ptz functions.” How and where can I do it?

Sorry for so much questions but I am not proficient in that subject.

Hi, I have 4 Annke Onvif compatible cameras (checked with the Onvif device manager software listed above).

I am looking for a very simple implementation into my OpenHAB environment. I simply want to see the streams of each of the 4 cams. No need to control their movement, or have any alarms or anything. I just want to see the live streams. I’ve sifted through the 1000+posts in this thread, but can’t find the simple solution.

Just looking for the exact text I should put in the .items, .things, and .sitemap files.

Thanks in advance.

@kristofejro
There are 3 ways to control an ONVIF camera and it is possible a camera only implements 1 of them and will be moved by that program using a different method to what this binding uses. You need to select ABSOLUTE in the program to use absolute control methods and make sure your not trying to use RELATIVE or CONTINUOUS methods which are the other types from memory.

@TonyN
See the readme and google what the URLs for your camera are and then you will need to piece it together yourself from the examples given, or you can use PaperUI and forget about textual config.

Still completely confused, and I’m a beginner at OpenHAB. I’ve read the readme several times.

I added the THING in PaperUI, but not sure how to implement it. I’ve tried your items and sitemaps examples. No luck.

I would like to use RTSP, and this is my confirmed rtsp URL for my first camera:

rtsp://192.168.1.100:554/Streaming/Unicast/channels/101

Working great with HIKVision DS-2CD2512F-IS!

Thanks for the good work.

1 Like

That’s the setup I have!

Any chance you can post your .sitemap, .items, and any other relevant code you used to get it working?

I see the camera “online” in PaperUI but I don’t know how to get it to show in on the app

Have a look at the github of the binding: https://github.com/Skinah/IpCamera
There is a full example with HIKVision camera at the bottom of the page. I used this to make mine work.

For the image of the camera I used this line on my sitemap.

Image url="http://user:password@ipaddress/onvif-http/snapshot?Profile_1" refresh=2000

Yeah, I have the image working. I was hoping to get video streaming working. I’ve tried following the examples on github and here.

I’m using the technique from the github instructions with no success (IP is the IP for OpenHAB server and the 101 is the unique Port I assigned to the camera):

Video url="http://192.168.1.39:101/ipcamera.mjpeg"

On browser and the mobile app the link above works for streaming.