Generic IP Camera binding


(Thomas Hartwig) #41

There is a new version for download which supports authentication. My test cam is an Axis camera. Currently only static image URL is supported, which can be fetched in a configurable interval.

Regards
Thomas


(The Squid) #42

When might you anticipate supporting ONVIF, as this would open up a great deal of cameras from many different manufacturers?


(Thomas Hartwig) #43

Hi, ONVIF is by definition "only" a discovery layer, which does not offer any decoding details, however it is a nice protocol for detecting cameras available of course. I will see if I can add this detection support. But every camera which offers ONVIF offers image fetching via HTTP which is already supported by the addon.

Thanks
Thomas


(Oggerschummer) #44

Hello @_Thomas,
unfortunately the version of the binding containing authentication code (downloaded from the link above) does not work for me.
I´m running OpenHabian, latest snapshot with the Zulu JVM (default).

After checking google it seems Apache commons-codec is somewhere missing as in the openhab log you see things like:

2017-05-31 10:28:43.271 [ERROR] [ore.internal.events.OSGiEventManager] - Dispatching/filtering event for subscriber 'org.eclipse.smarthome.core.events.EventSubscriber' failed: java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64

java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64

...

Caused by: java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64

at org.apache.http.impl.auth.BasicScheme.authenticate(BasicScheme.java:168)

at org.apache.http.impl.auth.HttpAuthenticator.doAuth(HttpAuthenticator.java:239)

at org.apache.http.impl.auth.HttpAuthenticator.generateAuthResponse(HttpAuthenticator.java:218)

at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:262)

at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)

at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)

at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)

at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)

at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)

at org.openhab.binding.camera.handler.CameraHandler.readImage(CameraHandler.java:177)

at org.openhab.binding.camera.handler.CameraHandler.refreshData(CameraHandler.java:120)

at org.openhab.binding.camera.handler.CameraHandler.handleCommand(CameraHandler.java:64)

at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:207)

at org.eclipse.smarthome.core.thing.link.ThingLinkManager.informHandlerAboutLinkedChannel(ThingLinkManager.java:264)

at org.eclipse.smarthome.core.thing.link.ThingLinkManager.receiveTypedEvent(ThingLinkManager.java:304)

at org.eclipse.smarthome.core.thing.link.ThingLinkManager.receiveTypedEvent(ThingLinkManager.java:1)

at org.eclipse.smarthome.core.events.AbstractTypedEventSubscriber.receive(AbstractTypedEventSubscriber.java:50)

at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:192)

at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1)

at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:181)

... 4 more


Any ideas how to solve this ? I require the authentication feature as embedding the credentials in the URL does not work for me.

Regards,
Thomas


(Thomas Hartwig) #45

Hi, I assume it is a version problem, the OpenHabian is 2.0.0 based and probably stripped further which I have no experience with. I would suggest to try to get the a commons.codec jar into your installation. Please let me know if this works.


(Oggerschummer) #46

Hi @_Thomas,

snapshot version shows:

openHAB 2.1.0~20170529014246-1 (Build #929)

Checking in the Karaf console it should be fine:

list | grep Commons

 27 | Active   |  80 | 1.6.0                  | Commons Codec
 28 | Active   |  80 | 3.2.1                  | Commons Collections
 29 | Active   |  80 | 1.1                    | Commons Exec
 30 | Active   |  80 | 2.2.0                  | Commons IO
 31 | Active   |  80 | 2.6                    | Commons Lang
177 | Active   |  80 | 3.2.0                  | Commons Net

@ThomDietrich: Any idea if there is something missing in openHABian ? Maybe a path not set ?

I have the tendency to think this is binding related, as openHAB did not complain about missing the class before. But who knows...

Regards,
Oggerschummer


( ) #47

I didn't go through the whole thread, so forgive me if I miss the point.
For all you need to know openHABian is a Raspbian Lite setup with a bunch of packages preinstalled and "useful" settings applied. openHAB (stable or unstable, selectable via sudo openhabian-config) is installed without modifications.


(Thomas Hartwig) #48

I have added an explicit dependency to the commons codec now. Please download the jar again and test.


(Oggerschummer) #49

I updated the binding, still showing:

2017-05-31 15:28:33.556 [ERROR] [ore.internal.events.OSGiEventManager] - Dispatching/filtering event for subscriber 'org.eclipse.smarthome.core.events.EventSubscriber' failed: java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64

...

Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64 cannot be found by org.openhab.binding.camera_2.1.0.201705311236

What I Did: Updated openhab2 to current snapshot, Installed the binding via Karaf console, activated binding in Karaf console, ran a full reboot to ensure everything is clean. Scanning for the jar file I see now this:

find / -type f -iname "*commons-codec*"
/var/lib/openhab2/cache/org.eclipse.osgi/196/0/.cp/lib/commons-codec-1.8.jar
/var/lib/openhab2/cache/org.eclipse.osgi/204/0/.cp/lib/commons-codec-1.10.jar
/srv/openhab2-sys/runtime/system/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
/srv/openhab2-userdata/cache/org.eclipse.osgi/196/0/.cp/lib/commons-codec-1.8.jar
/srv/openhab2-userdata/cache/org.eclipse.osgi/204/0/.cp/lib/commons-codec-1.10.jar

Previously there was only version 1.6 available.


(Thomas Hartwig) #50

Next try, download the jar again, the codec library is now hard included.


(Oggerschummer) #51

@_Thomas, this did the trick, I have an image now in PaperUI ! Thanks for the support !

Checking the event log I see that numerous "item changed" events get fired, even if I set the refresh parameter to e.g. 20 sec:

2017-06-01 09:01:12.295 [ItemStateChangedEvent     ] - camera_camera_15c52d5ccdd_image changed from raw type (image/jpeg): 277505 bytes to raw type (image/jpeg): 277236 bytes
2017-06-01 09:01:15.494 [ItemStateChangedEvent     ] - camera_camera_15c52d5ccdd_image changed from raw type (image/jpeg): 277236 bytes to raw type (image/jpeg): 277418 bytes
2017-06-01 09:01:17.297 [ItemStateChangedEvent     ] - camera_camera_15c52d5ccdd_image changed from raw type (image/jpeg): 277418 bytes to raw type (image/jpeg): 277468 bytes
2017-06-01 09:01:21.487 [ItemStateChangedEvent     ] - camera_camera_15c52d5ccdd_image changed from raw type (image/jpeg): 277468 bytes to raw type (image/jpeg): 277569 bytes

Those should only happen when refreshing the item. As it is a "pull" the camera does not trigger the update, right?
Besides that the "Refresh" in Paper UI is not yet working, I see the event fired but the UI does not respond.
So currently I only get one static image when opening the UI, after this independent of item change or refresh it stays the same.
Only switching between different "locations" in the PaperUI Control section it updates the image.

Small suggestion: A parameter "Image Scale Factor" would be nice as the UI only shows a small version of the image a lot of data is being transferred in OH (See the log above) without being used.

Kind Regards,
Oggerschummer


(Oggerschummer) #52

Just checked in BasicUI, there the image updates frequently. But it does not respect the refresh intervall paramter.


(Thomas Hartwig) #53

Hi,I updated the package now, this should fix the refresh interval. Regarding the UI I can not do much about it. My test environment is the PaperUI and it works well. The addon is not responsible for rendering the thing.

Many Thanks for check and feedback
Thomas


(Thomas Hartwig) #54

Regarding the UI more details: The rendering is out of scope of the addon. Also the scaling should not handled by the addon since it is very camera dependent. I recommend to tweak the image size via the calling URL or the camera setup itself.
What do do with the image and where to display it is the matter of the OpenHab user. The Paper UI and all others default UI are only at a basic level of showing things for demonstration purpose.

BR
Thomas


(Oggerschummer) #55

The fix for the refresh intervall is working fine, thank you very much.

I agree that rendering itself should not be done by the binding. But it may make sense to reduce the size of the data before handing it over to OH. It´s not always possible to reduce image size on the camera itself.

Nevertheless, a big "Thanks" for the work done. I know there are still a lot of things on the list e.g. ONVIF and discovery, but this overall looks promising.

Cheers,
Oggerschummer


(Stefaan Bolle) #56

How do you integrate the camera binding in a manual sitemap config? The Image property requires an URL.
The binding works with my Time2 and Sony cam using authentication


(HomeAutomation) #57

Is it planed to support rtsp:// in url too?

Would be very nice.


(Thomas Hartwig) #58

Hi Stefan, I am sorry, I can not be of much help in this topic, please refer to the official documentation and the forum regarding customized maps. If you have a solution I am very interested for a short description.

Regards
Thomas


(Thomas Hartwig) #59

Hi,

rtsp is one of my top priority since it is most common for for H.264 based streaming. I have the components working already but have to repackage into a distributable structure still. My rough time target is about 4 weeks from now. Also I am in little doubt if the UI is really capable of handling video stream display. Probably an expert reading this can blow my sceptic into the wind. But for motion detection and even snapshot is rtsp nice to have.

BR
Thomas


(Muplex) #60

Must be in the next official bindings release!!!

Thanks for your work!!!