IpCamera: New IP Camera Binding

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?

You use the IP of the openhab server and not the cameras in the sitemap, also the server port is 2079 in the cameras setup and your using 3001 on the cameras IP which will not work for the two separate reasons.

Also look at the logs in debug and trace level if you need further help.

Thanks for your reply. No, my openhab server does have a different IP address. 192.168.178.79 is the address of the Axis camera.
You are right. Server Port I changed for testing purporses and its correct set to 2079 in the sitemap.

Could you let me know which logs you are referring to? Appreciate your support

Understood, this is why using the IP of 192.168.178.79 is wrong in your sitemap file and anywhere else you want the binding to provide the images from the camera. The binding creates a file server at your openhab IP address.

Two links for you to read, regarding logs…

I’m using thebinding with the newly release OH3 - clean install and setting things up - I have a strong suspicion (mainly through trial and error/process of elimination) that changes made to the parameters of the binding aren’t being saved correctly once the initial binding is created - and that even that isn’t saving its initial parameters correctly - for example if I manually set the ImageURL/MPEG URL - to URLs that I know work - or on an alternate try deliberatly don’t work - they don’t seem to get set and the binding doesn’t use them.

I’ve not tried creating it using text as I’m just getting used to OH3…

I’ve had it working then in the logs - suddenly I get this:

“Camera is reporting your username and/or password is wrong.”

then the camera gets locked out due to bad username/pw combinations

Is there anything that could be causing this?

Cheers

I’ve never seen that, have you done a reboot after the install completed? If it happens after a reboot can you list the steps you are taking to create this and I will test.

@matt1 Thank you. Finally I was able to run the camera. My Mistake was, that I forgot to add the Port for ffmpegInput

Hi, this looks very promising. Do you know if I run openhab with docker, will I need to build my own docker file to include ffmpeg? Or do I specify the ffmpeg path on my host system?

Additionally, do I need to create the output path in my docker container and mounted to my host machine? Or do I specify the output path just as my system path?

Sorry, I am not very familiar with docker.

Thank you for your help.

Hello,
one question:
my ESP 32 cam, before upgrade OH3 was woring good.
After update, with same code line in the Sitemap, no resoults:

Text label="Camera" icon="camera" {
			Video url="http://192.168.178.100:54333/ipcamera.mjpeg" encoding="mjpeg"
		}

Can you help me to make it work again ???

There may be a bug with the video element, try using the webview element instead. I don’t think this is a binding issue.

Just a heads up that there are now 2 camera widgets created for the new OH3 main UI. This makes it very easy to get PTZ cameras moving.

I’m struggeling in getting my D-Link DCS-6511 to work with the IP camera binding in OH3.

I used the cameras successfully in OH2 and OH3 sitemaps with Basic UI as follows:

Video url="http://user:pwd@192.168.0.15:80/video2.mjpg" encoding="mjpeg"

Mjpeg streams are natively supprted by this model !

For OH3 Main UI I was recommended to go with the IPCamera binding…

The cams were successfully autodetected by the binding:
Identifier: ipcamera:onvif:192168015

I added:

  • user/pwd
  • server port: -1 (I honestly don’t know how to use this parameter)
    to get the camera to status “online”.

The output of the MJPEG URL item linked to the MJPEG URL channel is “NULL”.

The openhab log shows this:

2020-12-26 14:35:40.002 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:PullMessages
2020-12-26 14:35:40.002 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:Renew
2020-12-26 14:35:40.097 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.15:80/dms?nowprofileid=1
2020-12-26 14:35:40.271 [TRACE] [amera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"><SOAP-ENV:Header><wsa5:To SOAP-ENV:mustUnderstand="true">http://192.168.0.15/onvif/device_service?SubscriptionIdx=2</wsa5:To><wsa5:Action SOAP-ENV:mustUnderstand="true">http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/PullMessagesResponse</wsa5:Action></SOAP-ENV:Header><SOAP-ENV:Body><tev:PullMessagesResponse><tev:CurrentTime>2020-12-26T13:35:40Z</tev:CurrentTime><tev:TerminationTime>2020-12-26T13:35:48Z</tev:TerminationTime></tev:PullMessagesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
2020-12-26 14:35:40.272 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:Renew
2020-12-26 14:35:40.272 [TRACE] [amera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"><SOAP-ENV:Header><wsa5:To SOAP-ENV:mustUnderstand="true">http://192.168.0.15/onvif/device_service?SubscriptionIdx=5</wsa5:To><wsa5:Action SOAP-ENV:mustUnderstand="true">http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/PullMessagesResponse</wsa5:Action></SOAP-ENV:Header><SOAP-ENV:Body><tev:PullMessagesResponse><tev:CurrentTime>2020-12-26T13:35:39Z</tev:CurrentTime><tev:TerminationTime>2020-12-26T13:35:47Z</tev:TerminationTime></tev:PullMessagesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
2020-12-26 14:35:40.273 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:Renew
2020-12-26 14:35:40.310 [TRACE] [amera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>

As I mentioned, the camera natively supports mjpeg streams - there shouldn’t be any need for ffmpeg.

Still, I don’t know how to make use/configure the server port.
How to set this properly in the carmera and in openhab?

How to get the stream work

It’s working !!

Set server port to 54321 and I’m getting the stream via:
http://192.168.0.13:54321/ipcamera.mjpeg

One observation though:
The livestream only updates every 3 seconds - in the browser, in Basic UI and the webgui of the camera itself…

How to get a smooth stream?