Proxying images and videos through openHAB

7,736 views
Skip to first unread message

Kai Kreuzer

unread,
May 5, 2013, 3:55:18 PM5/5/13
to ope...@googlegroups.com
Hi all,

As it might be an interesting new feature for some of you, this is fyi: I have just implemented and pushed https://code.google.com/p/openhab/issues/detail?id=210.

Here is an excerpt from its JavaDoc:

 * The proxy servlet is used by image and video widgets. As its name suggests, it proxies the content, so
 * that it is possible to include resources (images/videos) from the LAN in the openHAB UI. This is
 * especially useful for webcams as you would not want to make them directly available to the internet.
 * 
 * The servlet registers as "/proxy" and expects the two parameters "sitemap" and "widgetId". It will
 * hence provide the data of the url specified in the according widget. Note that it does NOT allow
 * general access to any servers in the LAN - only urls that are specified in a sitemap are accessible.
 * 
 * It is also possible to use credentials in a url, e.g. "http://user:pwd@localserver/image.jpg" -
 * the proxy servlet will be able to access the content and provide it to the openHAB UIs through the
 * standard openHAB authentication mechanism (if enabled).
 * 
 * This servlet also supports data streams, such as a webcam video stream etc.

I know finally do not have to expose my webcams through portforwarding in my router and can still access them through the openHAB UIs. Note that the REST API directly delivers uris to the proxy servlet, so it transparently works also with iOS client and HABDroid without requiring any changes in those apps.

The only difference to before is that you have to use absolute urls in your image and video widgets in the sitemap definition - relative urls won't work anymore.

Best regards,
Kai

Kristian

unread,
May 5, 2013, 3:57:39 PM5/5/13
to ope...@googlegroups.com
Sounds superb, I'll have to try!

Ben Jones

unread,
May 6, 2013, 1:06:50 AM5/6/13
to ope...@googlegroups.com
This sounds great - I am about to take delivery of a Z-Wave USB stick + IP camera (with motion detection). I really want to hook this up at my front door and for openHAB to notify me when someone comes to the front door while I am away from the house. I would then want to open up the iOS app and somehow view a still taken from the camera of whoever was at the door.

The camera can operate standalone so I am thinking I will probably set it up this way initially, since the Z-Wave binding is still in its infancy.

Are there any examples people have of hooking up an IP camera to openHAB and displaying the results in the UI? I don't have the details just yet, but I am guessing I may need to write a new binding for this camera? Unless I can do all I want/need using HTTP bindings?

Really loving this software - so easy to extend and configure, yet so powerful!!

Victor Belov

unread,
May 6, 2013, 4:06:03 PM5/6/13
to ope...@googlegroups.com
Hi,

Cool! That's what we were all waiting for!

BR,
VB
> --
> You received this message because you are subscribed to the Google Groups
> "openhab" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to openhab+u...@googlegroups.com.
> To post to this group, send email to ope...@googlegroups.com.
> Visit this group at http://groups.google.com/group/openhab?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Pablo Romeu

unread,
May 7, 2013, 5:43:28 AM5/7/13
to ope...@googlegroups.com
Hahhahaa xDDDD Thanks for the no-changes-needed stuff. I would love to test this feature too :)

Kai Kreuzer

unread,
May 7, 2013, 3:48:57 PM5/7/13
to ope...@googlegroups.com
Hi Ben,

Are there any examples people have of hooking up an IP camera to openHAB and displaying the results in the UI? I don't have the details just yet, but I am guessing I may need to write a new binding for this camera? Unless I can do all I want/need using HTTP bindings?

Well, the solution I use as a notification is to e-mail a picture from the webcam. This works quite well. To be immediately notified that something happened at my door I am using an XMPP notification (for my Android phone) or Prowl for my iPhone.

Regards,
Kai

Ben Jones

unread,
May 7, 2013, 4:52:15 PM5/7/13
to ope...@googlegroups.com
Hi Kai


Well, the solution I use as a notification is to e-mail a picture from the webcam. This works quite well. To be immediately notified that something happened at my door I am using an XMPP notification (for my Android phone) or Prowl for my iPhone.

Are you getting the email directly from the camera itself, or is this being handled by openHAB? I received my camera yesterday and currently have it setup to email me a snap when the motion sensor is triggered, but this is all independent of openHAB. I would prefer to integrate into openHAB - then I can use the XMPP notifications etc.

Cheers,
Ben

Kai Kreuzer

unread,
May 8, 2013, 2:25:19 AM5/8/13
to ope...@googlegroups.com
Hi Ben,

Are you getting the email directly from the camera itself, or is this being handled by openHAB? 

Of course directly by openHAB :-)

I am simply using this statement in a rule:

sendMail("m...@domain.com", "Frontdoor", "", "http://192.168.0.x/jpg/image.jpg")

which will attach the referenced jpg from the webcam to the e-mail.

Regards,
Kai

Victor Belov

unread,
May 9, 2013, 1:29:39 PM5/9/13
to ope...@googlegroups.com
Hi,

Kai, would you please add this to examples wiki? :-)

Kai Kreuzer

unread,
May 9, 2013, 3:56:21 PM5/9/13
to ope...@googlegroups.com
> Kai, would you please add this to examples wiki? :-)

Done: https://code.google.com/p/openhab-samples/wiki/Rules#Send_an_image_from_your_webcam_by_e-mail

Ben Jones

unread,
May 8, 2013, 5:50:05 AM5/8/13
to ope...@googlegroups.com
Perfect. Works like a charm, like most things in openHAB!

Did you see I pushed a Twitter action today? Hopefully it is up to your standards! Not sure how your review/test process works for putting stuff into core. 

Cheers,
Ben
--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/eag6cUqRTaU/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.

Kristian

unread,
May 13, 2013, 3:47:27 AM5/13/13
to ope...@googlegroups.com
This works, and it is a very nice feature! Wow and thanks!
I do have some cheap foscam cameras, their downside is that they are slow. That is not the proxys fault.

I'm using the classic UI, and tried to embed the ip camera video stream into a page containing some light switches. The page showed up as expected including the video. Then I tried to push a light switch, which caused the video picture to disappear. Is there anything that could be done to avoid it?

Is this caused by the slowness of my cameras?

Best regards,
Kristian



Kai Kreuzer

unread,
May 13, 2013, 1:31:19 PM5/13/13
to ope...@googlegroups.com
Then I tried to push a light switch, which caused the video picture to disappear. Is there anything that could be done to avoid it?

I would have to test and analyze this myself. May I ask you to enter an issue, so that I won't forget it?

Cheers,
Kai

Kristian

unread,
May 14, 2013, 1:50:21 AM5/14/13
to ope...@googlegroups.com

Brian Crosby

unread,
Aug 14, 2014, 8:56:46 PM8/14/14
to ope...@googlegroups.com
Kia

What does your rule look like that triggers this?

Michael Belleville

unread,
Apr 1, 2015, 11:33:13 AM4/1/15
to ope...@googlegroups.com
Is there anything special that needs to be done to activate the proxy servlet feature?

I have the following in my sitemap:

It works fine in the web UI, but in the android and iphone apps there is nothing displayed.  does that mean the proxy servlet is not working properly?

Kai Kreuzer

unread,
Apr 1, 2015, 3:14:00 PM4/1/15
to ope...@googlegroups.com
I would assume that the problem is that your url does not deliver an image, but a video stream.
For videos, you should use the video widget, but even then the supported formats in the native apps might be quite limited.

Best regards,
Kai

Michael Belleville

unread,
Apr 2, 2015, 2:21:45 AM4/2/15
to ope...@googlegroups.com
If I use the video widget then it doesn't work.  In the web UI I see an interface to play the video, but clicking the play button does nothing.  When I open it in the android app it says "Can't play this video."  In the iPhone app just a blank screen.

I figured I was closer to my goal with the Image widget since that at least displays the stream in the web UI.

What formats are supported in the native apps?  I would think that the mjpeg image stream delivered by my camera would be pretty easy for most devices to display...

I am trying to use this to display security camera feeds.  Is there a better way of doing this?  Is there a better camera to use or a better stream type than mjpeg?  I am using a foscam fi8910w....

If I can't watch the feeds on the iphone/android apps then it is not nearly as useful to me.

Kai Kreuzer

unread,
Apr 2, 2015, 8:35:53 AM4/2/15
to ope...@googlegroups.com
As I said, streams should be done through the Video widget, see https://github.com/openhab/openhab/wiki/Explanation-of-Sitemaps#element-video
Mjpeg works for me in the Classic UI and it is also supposed to work in the native apps (see e.g. https://github.com/openhab/openhab/issues/374)

If you have problems, I'd suggest to enter a dedicated issue for the native apps in the respective issue trackers (https://github.com/openhab/openhab.android/issues and https://github.com/openhab/openhab.ios/issues).

Best regards,
Kai

Michael Belleville

unread,
Apr 2, 2015, 10:09:35 PM4/2/15
to ope...@googlegroups.com
ok, I got it working with the Video widget both in the web UI and in the native apps.  I had to specify the mjpeg encoding.  I guess the auto-selection does not work very well, at least for mjpeg.

Now I think my issue is with the proxy servlet as I can not see the stream when I connect externally.  I have 8443 forwarded from my router to my openhab box.  I am able to connect in fine with the android app, everything works as expected except for the video stream.  I just get a blank screen.  I am not able to try it at the moment with the web UI, but if it doesn't work with the android app I am guessing the web UI won't work either since both of them work fine when I am connected internally.

Is there anything I can provide in the way of debug information? Would you like me to open an issue?

Michael Belleville

unread,
Apr 6, 2015, 3:29:33 PM4/6/15
to ope...@googlegroups.com
I tried a simple jpg image to test the proxy servlet and it seems to work fine.  I have the following in my sitemap:


Both are on the lan.  The IP of my openhab box is 192.168.69.110, so neither is hosted directly on my openhab box.

Internally both work fine.  Externally I can see the image, but I can not see the video stream.  

Could it be a bandwidth issue?  I only get a little over 1 Mb/s upload speed, and I am trying to view a 320x240 MJPEG stream.  I was hoping I would see something from the video stream even if I lost some frames, but I get nothing at all when I connect externally.

Michael Belleville

unread,
Apr 8, 2015, 1:59:49 AM4/8/15
to ope...@googlegroups.com
it looks like it is an SSL issue.  I am able to view the streams if I use http externally instead of https.  I opened another topic if there is any interest...

Russ Reimann

unread,
Apr 10, 2015, 12:24:34 AM4/10/15
to ope...@googlegroups.com
I have the video widget with mjpeg encoding specified, but I still see a blank box in the ios app. Any other tips to make this work? I believe we have the same camera.

Mike Cayouette

unread,
Apr 20, 2015, 9:29:57 PM4/20/15
to ope...@googlegroups.com
Hi, is it possible this change does not apply to OH 1.6?  I can't seem to locate many of the files that need to be modified and the ones I do find there are multiple copies in different locations.  If there a way to proxy video through OH?

Thank you,

Mike

arman...@gmail.com

unread,
Jul 1, 2015, 9:03:04 PM7/1/15
to ope...@googlegroups.com
Has anyone been successful in getting this to work with 1.7.0?

Mark Cornhill

unread,
Aug 4, 2015, 7:45:43 AM8/4/15
to openhab
Yes I have this working with OpenHAB 1.7 using a Foscam 8905W wireless IP camera. It works with the Classis UI and Habdroid app also.

Foscam 8905W firmware details as follows.
Firmware version: 11.35.2.51
Device embedded Web UI version: 2.4.20.6

I used the video widget and specified the URL as mentioned above in this post.

http://192.168.7.211/videostream.cgi?user=admin&pwd={xxxx}" encoding="mjpeg"

Without the encoding option at the end it did not work for me.

Has anyone had issues adding more than one camera feed to their sitemap?  If I try adding them in a separate group even, it does not display anything.

Regards
Mark

wolffromthenorth

unread,
Aug 5, 2015, 6:13:44 AM8/5/15
to openhab
hey marc, does your solution also work outside your house, so not on internal network ?
can you post a small piece of you sitemap cause whn i try this  i get no immage at all and i can't choose the size of the camera image displayed.

kind regards
 

Mark Cornhill

unread,
Aug 5, 2015, 7:22:24 AM8/5/15
to ope...@googlegroups.com
Hi there,

Here is the portion of sitemap for the camera. It does not work outside the LAN.

Group label="Carport Cam" icon="shield" {
                        Video url="http://192.168.7.211/videostream.cgi?user=admin&pwd=xxx

--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.

To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

wolffromthenorth

unread,
Aug 5, 2015, 10:00:40 AM8/5/15
to openhab
and this works in the android app ?
because i tried this allready without succes and the whole topic is about getting it external , on the internal network i allready got it working in the classic
webinterface.

kind regards 
 

wolffromthenorth

unread,
Aug 12, 2015, 2:45:35 PM8/12/15
to openhab
Hi all problem is resolved in new openhab version 
i'm running 1.8 now and now all works as designd, even remote in hab droid all is good ;-)
i'm testing with foscams.

kind regards 

Ben Jones

unread,
Aug 12, 2015, 4:11:12 PM8/12/15
to openhab
Hey Wolf - would you mind sharing you item/sitemap config? What model Foscam do you have? Cheers, Ben.

wolffromthenorth

unread,
Aug 12, 2015, 4:37:21 PM8/12/15
to openhab
offcourse no problem
i'm using as test a foscam C1
this is one of the new cameras of foscam.
all the HD foscam cameras now use the same CGI so the same command can be used.

Frame label="VoorDeur" icon="frontdoor" {
Text item=Deurbel_LastUpdate {
Frame {

where the xxxx's are is Ip adress or dns name ( noip, dyndns) and offcourse the password ( no special caracters allowd )

i did not change any setting for mjpeg as this is not possible on the C1.
i updated to the latest cloudbees release yesterday and noticed it started working, also the google agenda is now beeing proxied correctly.
my setup test is involging a doorbell i'm creating with zwave and camera image.

kind regards

Ben Jones

unread,
Aug 12, 2015, 4:44:22 PM8/12/15
to ope...@googlegroups.com
Thanks Wolf - so it is only snapshots, not video?
--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/eag6cUqRTaU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.

Christophe Van Vossel

unread,
Aug 12, 2015, 5:01:26 PM8/12/15
to ope...@googlegroups.com

With this camera there is no feed i have to test with my other one. I have now moving images by the refresh so its kinda like a stream.
Before i could get no image at all so i believe that with a camera that does mjpeg streaming thus should work. Solething did change with the 1.8 version as i have never got it to work before.

Op 12-aug.-2015 22:44 schreef "Ben Jones" <ben.j...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages