IpCamera: New IP Camera Binding

Fixed but have not tested nor built it yet, see my repo for changes.

Thanks, I will try to reproduce the issue and then try to get your changes to 2.5.10 for my production system to see, if it is fixed with that.
Cool, I see that you are using the HTTP protocol, that’s even better than the String approach.

EDIT: @sidamos I uploaded a precompiled jar if you want to try it out, see here for link and info on other changes:

There is a problem with using the snapshot URL for checking if the camera rebooted:
It does not work if setting “ffmpeg” as snapshot URL. Then it does not do checks.
Also, after further thinking, requesting a snapshot every 8s is probably problematic for some cameras. For example, mine does not return a snapshot if the sub stream is MJPEG. Other Amcrests sometimes stop returning snapshots.
Could you use another “simple” GET for some config for checking if the camera is still there? This would work in all cases.

If you have a camera that can not handle that then you should contact their support and complain as it is a basic feature and one that should work if it is to call itself ONVIF compatible.

No camera that has an alarm stream should need to set that, if it does it should be considered a camera firmware bug. ONVIF standard requires a snapshot for it to be considered able to be advertised as ONVIF compliant.

No it would not as there are cameras with only a RTSP server and nothing more. Cameras with only a snapshot url and nothing more in them. ESP32 based cameras that can only do snapshots and mjpeg streams and nothing more. But all of these do not have alarm streams, which brings me back to my statement that if it has an alarm stream it should have working snapshots unless it is a bug in the cameras firmware.

This binding is huge and covers many brands and methods, so it is like 6 bindings all thrown into 1 which makes testing all use cases very difficult especially when most people appear to not raise an issue when it is found.

Thanks for raising these multiple things recently, if you notice something then please test, narrow it down and then mention it as I probably have an idea on where to look or how to fix.

Hey,

ive got some problems with installing the yi dome 1080p in openhab. I use the ipcamera binding and made some configuration with visual studio Code.

I updated my cam with the yi hack from roleoroleo and tested also onvif with the onvif device manager without problems. Could pan and tilt. Then i tried to configure it in openhab, got an online Status, but no possibility to move the camera.

I hope that anyone can help me, no ideas to solve the problem.

Chris

Try this version If your using 2.5.x
http://www.pcmus.com/openhab/IpCameraBinding/ipcamera-2020-11-15.zip

A few compatibility fixes went into that build and are included in the V3.0 builds.

Also try turning using all four of the movement methods that the documentation explains as many cameras do not support all the types of movements.

1 Like

Had been using updateGif channel to create 10 second shorts (via a DSL rule) when my zwave PIR detected motion in 2.5.x. Migrated to OH3 M5 and can’t find that channel to start the recording. I also can no longer find in the documentation. I see the external motion channel, but is unclear what that will do. I’ve searched the 2194 entries in this post for updateGif and could not find where (or if) it was depreciated. BTW image and .jpeg & .jpg streaming work fine. Could use a pointer.

Bob

You have to use an action now in V3. See updated documentation here. When V3 goes live in a few weeks this will be reachable on the website.

Thanks a bunch !
I should have asked sooner :crazy_face:

Bob

As an FYI … I had trouble with your script (CommandLine /bin/mv, etc.) to time date the Gifs in OH3 (Worked perfect in OH2.5). Could not find the issue, but realized with the new Action, could time stamp the output directly.

> rule "Front_Door camera Zooz motion"
> when
>     Item  FrontDoorMotion38_AlarmMotion changed to ON
> then
>    val String timeNow = String::format( "%1$tY%1$tm%1$td-%1$tT", new java.util.Date ).replace(":", "")
>    getActions("ipcamera", "ipcamera:onvif:1921680133").recordGIF(timeNow,10)
> end

Tried different Types of Moving: absolute, relative, continouus , nothing worked. Is there any other preference which i should know? Camera is still showing online status, so i think that something happens there.

Hi everyone,

Some time ago, before ipcamera addon was in official openhab addons, I use this binding (ipcamera-2020-04-08.zip) for GIF creation and line crossing detections.

After migrating to OH 2.5.10 I have two problems.

  1. When binding is loading I get errors:
==> /opt/openhab/userdata/logs/openhab.log <==
2020-12-09 23:04:45.997 [WARN ] [me.config.core.internal.ConfigMapper] - Could not set field value for field 'updateImageWhen': Can not set java.lang.String field org.openhab.binding.ipcamera.internal.CameraConfig.updateImageWhen to java.math.BigDecimal
java.lang.IllegalArgumentException: Can not set java.lang.String field org.openhab.binding.ipcamera.internal.CameraConfig.updateImageWhen to java.math.BigDecimal
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[?:1.8.0_265]
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[?:1.8.0_265]
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) ~[?:1.8.0_265]
        at java.lang.reflect.Field.set(Field.java:764) ~[?:1.8.0_265]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523) ~[bundleFile:2.6]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500) ~[bundleFile:2.6]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560) ~[bundleFile:2.6]
        at org.eclipse.smarthome.config.core.internal.ConfigMapper.as(ConfigMapper.java:101) [bundleFile:?]
        at org.eclipse.smarthome.config.core.Configuration.as(Configuration.java:80) [bundleFile:?]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.getConfigAs(BaseThingHandler.java:232) [bundleFile:?]
        at org.openhab.binding.ipcamera.internal.handler.IpCameraHandler.initialize(IpCameraHandler.java:1595) [bundleFile:?]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.thingUpdated(BaseThingHandler.java:166) [bundleFile:?]
        at sun.reflect.GeneratedMethodAccessor220.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_265]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_265]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_265]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_265]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_265]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]

==> /opt/openhab/userdata/logs/events.log <==
2020-12-09 23:04:46.007 [me.event.ThingUpdatedEvent] - Thing 'ipcamera:hikvision:FURTKA' has been updated.

My config looks like:

Thing ipcamera:hikvision:FURTKA "FURTKA" @ "Cameras" [
    ipAddress="192.168.XXX.YYY",
    password="XXXXX",
    username="admin",
    pollTime=1000,
    ipWhitelist="DISABLE",
    serverPort=50011,
    updateImageWhen=2,
    onvifMediaProfile=1,
    mjpegUrl="ffmpeg",
    nvrChannel=1,
    gifPreroll=0,
    gifPostroll=3,
    ffmpegOutput="/tmpfs/cam01/",
    onvifPort=8000, //normally 80 check what it needs
    port=80,
    ffmpegInput="rtsp://192.168.XXX.YYY:554/ISAPI/Streaming/channels/101"
]

I try to define updateImageWhen=“1” but I get the same error:

Could not set field value for field 'updateImageWhen': Can not set java.lang.String field org.openhab.binding.ipcamera.internal.CameraConfig.updateImageWhen to java.math.BigDecimal

I use now the snapshot version:

openhab> bundle:list |grep -i ipcame
317 │ Active │  80 │ 2.5.10.202011141152     │ openHAB Add-ons :: Bundles :: IpCamera Binding
openhab> feature:list | grep -i ipcam
openhab-binding-ipcamera                          │ 2.5.10           │ x        │ Started     │ openhab-addons-2.5.10        │ ipcamera Binding
openhab>

The second problem is that, the recordGif stops working. I have rule like this:

rule "FURTKA Line Crossing detected"
when
  Item CamFurtkaLineCrossingAlarm changed to ON
then
  if (CamFurtkaRecordingGif.state == 0 || CamFurtkaRecordingGif.state == NULL ) {
    getActions("ipcamera", "ipcamera:hikvision:FURTKA").recordGIF("ipcamera",3)
  }
end

And I start to get errors in OH2.5.10:

2020-12-09 23:07:28.635 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'FURTKA Line Crossing detected': Instance is not a IpCamera class.

And my items:

Switch CamFurtkaStartHLS "Start HLS" { channel="ipcamera:hikvision:FURTKA:startStream" }
Number CamFurtkaRecordingGif "Update GIF" { channel="ipcamera:hikvision:FURTKA:recordingGif" }
Image CamFurtkaImage "Picture" { channel="ipcamera:hikvision:FURTKA:image" }
Switch CamFurtkaUpdateImage "Get new picture" { channel="ipcamera:hikvision:FURTKA:pollImage" }
//Switch CamFurtkaCreateGif "Create animated GIF" { channel="ipcamera:hikvision:FURTKA:updateGif" }
Switch CamFurtkaEnableLineCrossing "Line Crossing Alarm on/off" { channel="ipcamera:hikvision:FURTKA:enableLineCrossingAlarm" }
Switch CamFurtkaLineCrossingAlarm "Line Crossing detected" { channel="ipcamera:hikvision:FURTKA:lineCrossingAlarm" }
DateTime CamFurtkaLastMotionTime "Time motion was last detected [%1$ta %1$tR]"
String CamFurtkaLastMotionType "Last Motion Type" { channel="ipcamera:hikvision:FURTKA:lastMotionType" }

Can anyone help me?

Look about six posts above for a newer build. The binding that is merged has an issue with recording GIF that is fixed in that build.

Instance is not a IpCamera class
To fix that reboot openhab, I think this is caused by the order things start when you use textual config. Recommend u move towards using auto discovery now the binding is merged.

I wrote that I use newest binding you have mentioned: 2.5.10.202011141152 . It is from post number: 2205:

$ unzip -t ipcamera-2020-11-15.zip
Archive:  ipcamera-2020-11-15.zip
    testing: netty-buffer-4.1.42.Final.jar   OK
    testing: netty-codec-4.1.42.Final.jar   OK
    testing: netty-codec-http-4.1.42.Final.jar   OK
    testing: netty-common-4.1.42.Final.jar   OK
    testing: netty-handler-4.1.42.Final.jar   OK
    testing: netty-resolver-4.1.42.Final.jar   OK
    testing: netty-transport-4.1.42.Final.jar   OK
    testing: org.openhab.binding.ipcamera-2.5.10-SNAPSHOT.jar   OK
No errors detected in compressed data of ipcamera-2020-11-15.zip.

My config always was without quotes. I wrote, that I even try quotes, but get still the same error.

I do not want (and it is useless for me) to use autodiscovery, becasue I have several networks (VLANs) with router/firewall between them, so I have to use static configuration.

While I was writing this I restarted openhab. Yesterday I replace the ipcamera binding, without restarting openhab. Now, generating GIF works gine, but the “decimal error” persists.

==> /opt/openhab/userdata/logs/openhab.log <==
2020-12-10 10:21:50.595 [WARN ] [me.config.core.internal.ConfigMapper] - Could not set field value for field 'updateImageWhen': Can not set java.lang.String field org.openhab.binding.ipcamera.internal.CameraConfig.updateImageWhen to java.math.BigDecimal
java.lang.IllegalArgumentException: Can not set java.lang.String field org.openhab.binding.ipcamera.internal.CameraConfig.updateImageWhen to java.math.BigDecimal
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[?:1.8.0_265]
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[?:1.8.0_265]
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) ~[?:1.8.0_265]
        at java.lang.reflect.Field.set(Field.java:764) ~[?:1.8.0_265]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523) ~[bundleFile:2.6]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500) ~[bundleFile:2.6]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560) ~[bundleFile:2.6]
        at org.eclipse.smarthome.config.core.internal.ConfigMapper.as(ConfigMapper.java:101) [bundleFile:?]
        at org.eclipse.smarthome.config.core.Configuration.as(Configuration.java:80) [bundleFile:?]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.getConfigAs(BaseThingHandler.java:232) [bundleFile:?]
        at org.openhab.binding.ipcamera.internal.handler.IpCameraHandler.initialize(IpCameraHandler.java:1595) [bundleFile:?]
        at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_265]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_265]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_265]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_265]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_265]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]
2020-12-10 10:21:50.677 [WARN ] [me.config.core.internal.ConfigMapper] - Could not set field value for field 'updateImageWhen': Can not set java.lang.String field org.openhab.binding.ipcamera.internal.CameraConfig.updateImageWhen to java.math.BigDecimal
java.lang.IllegalArgumentException: Can not set java.lang.String field org.openhab.binding.ipcamera.internal.CameraConfig.updateImageWhen to java.math.BigDecimal
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[?:1.8.0_265]
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[?:1.8.0_265]
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) ~[?:1.8.0_265]

And I have correct config, without quotas.

Previously (in April, using previous version of the binding), generating GIF I think was faster…

Now it took for me, about 12-15 seconds…

2020-12-10 17:52:43.231 [vent.ItemStateChangedEvent] - CamFurtkaLineCrossingAlarm changed from OFF to ON
2020-12-10 17:52:43.232 [vent.ItemStateChangedEvent] - CamFurtkaLastMotionTime changed from 2020-12-10T17:47:38.073+0100 to 2020-12-10T17:52:43.229+0100
2020-12-10 17:52:43.245 [vent.ItemStateChangedEvent] - CamFurtkaRecordingGif changed from 0 to 3
2020-12-10 17:52:54.337 [vent.ItemStateChangedEvent] - CamFurtkaLineCrossingAlarm changed from ON to OFF
2020-12-10 17:52:57.229 [vent.ItemStateChangedEvent] - CamFurtkaRecordingGif changed from 3 to 0

Like I write I set:

    gifPreroll=0,
    gifPostroll=3,

and generate GIF using rule:

rule "FURTKA Line Crossing detected"
when
  Item CamFurtkaLineCrossingAlarm changed to ON
then
  if (CamFurtkaRecordingGif.state == 0 || CamFurtkaRecordingGif.state == NULL ) {
    getActions("ipcamera", "ipcamera:hikvision:FURTKA").recordGIF("ipcamera",3)
  }
end

Server is the same and it never took so long…

Have you cleaned the cache and tmp folders?
It is the exact same code just triggered in a different way so the delay is weird and may be an indication you need to clean out the cache. Lastly you should stop using the image channel and use one of the methods the readme covers.

@majherek
I looked at the code and this is what I found:

updateImageWhen
I checked and this needs to be a string (sorry I was wrong earlier) and hence will need the correct quotes around it to work without the error your reporting.

gifPostroll=3,
This no longer exists in the binding, but it wont hurt if left there. Recording time is set by the action parameter.

Any hint how can I do this?

/openhab/userdata$ ls -al
total 36
drwxrwxr-x  9 openhab openhab 4096 lis 27 13:29 .
drwxrwxr-x 11 openhab openhab 4096 gru 10 11:49 ..
drwxr-xr-x  2 openhab openhab 4096 lis 27 13:29 backup
drwxr-xr-x  5 openhab openhab 4096 lis 27 13:34 cache
drwxrwxr-x  5 openhab openhab 4096 lis 27 13:34 config
drwxrwxr-x  3 openhab openhab 4096 paź 28 23:06 etc
drwxrwxr-x  3 openhab openhab 4096 gru 10 10:46 jsondb
drwxrwxr-x  2 openhab openhab 4096 gru  5 11:42 logs
drwxr-xr-x 20 openhab openhab 4096 gru 10 14:09 tmp

Delete everything from tmp folder?

I thought that if i have set gifPreroll=0 I use RSTP stream to generate GIF. Yes, I have defined Image channel, but normally I don’t use it.

What are the other methods?

My sitemap (for testing purpose only) looks like this:

    Text label="FURTKA" icon="camera"{
        Image item=CamFurtkaImage refresh=1000
        Switch item=CamFurtkaUpdateImage

        Default item=CamFurtkaRecordingGif
        Default item=CamFurtkaStartHLS

        Default item=CamFurtkaEnableLineCrossing
        Default item=CamFurtkaLineCrossingAlarm

        Default item=CamFurtkaLastMotionTime
        Default item=CamFurtkaLastMotionType

        Text label="Cameras Mjpeg Stream" icon="camera"{Video url="http://192.168.XXX.YYY:50011/ipcamera.mjpeg" encoding="mjpeg"}
        Text label="Snapshot 1FPS Stream" icon="camera"{Video url="http://192.168.XXX.YYY:50011/snapshots.mjpeg" encoding="mjpeg"}
        Text label="autofps Stream" icon="camera"{Video url="http://192.168.XXX.YYY:50011/autofps.mjpeg" encoding="mjpeg"}
        Text label="HLS Video Stream" icon="camera"{Video url="http://192.168.XXX.YYY:50011/ipcamera.m3u8" encoding="hls"}
        Text label="HLS Webview Stream" icon="camera"{Webview url="http://192.168.XXX.YYY:50011/ipcamera.m3u8" height=15}
        Text label="Image using jpg method" icon="camera"{Image url="http://192.168.XXX.YYY:50011/ipcamera.jpg" refresh=1000}
        Text label="Animated GIF" icon="camera"{Image url="http://192.168.199.251:50011/ipcamera.gif" }
    }

I remove send line and add quotes:

    updateImageWhen="1"

Clean tmp and restarted openhab. No I do not see any errors with updateImageWhen.

But still generating GIF take long time.

Guys im struggling at step 1. How to install this binding??
I can see it in the add-ons list on openhab.org, but when using PaperUI i cannot see the binding listed to enable me to install?

Feeling a bit silly here as i must be missing something.
Colin

Upgrade to openHAB 2.5.10 or higher
If your new to openHAB consider going straight to V3.0

1 Like

Hi, I am getting frustrated, since I am not able to integrate my Axis Cam ( P3225-LVE Mk II ) in Openhab.
The binding seems to work fine. The parameter I used:

The status of the Thing is online.
I tried in sidemap several links and no of them is working:

Text label="Mjpeg Stream" icon="camera"{Video url="http://192.168.178.79:30001/ipcamera.mjpeg" encoding="mjpeg"}
			Image url="http://192.168.178.79:30001/ipcamera.jpg" refresh=900000 //Every 15 minutes
			Video url="http://192.168.178.79:30001/ipcamera.mjpeg" encoding="mjpeg"
			Video url="http://192.168.178.79:30001/snapshots.mjpeg" encoding="mjpeg"

Does somebody has any idea what I am doing wrong?